-
Notifications
You must be signed in to change notification settings - Fork 2.2k
refactor: Refactor HuggingFaceLocalChatGenerator
#9455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
HFLocalChatGenerator
HFLocalChatGenerator
HuggingFaceLocalChatGenerator
Pull Request Test Coverage Report for Build 15634575323Details
💛 - Coveralls |
@@ -138,7 +138,7 @@ def __init__( # pylint: disable=too-many-positional-arguments | |||
tools: Optional[Union[List[Tool], Toolset]] = None, | |||
tool_parsing_function: Optional[Callable[[str], Optional[List[ToolCall]]]] = None, | |||
async_executor: Optional[ThreadPoolExecutor] = None, | |||
): | |||
) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own knowledge, is this now required by linter? I remember having a similar error recently and we didnt specify return types for init
in other components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh no I don't think it's required right @anakin87 ? At least not yet. It's more just to start getting used to always adding return types to functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case there is at least one argument annotated, it's not required. https://mypy.readthedocs.io/en/stable/class_basics.html#annotating-init-methods
) | ||
|
||
# We know it's not None because we check it in _prepare_inputs | ||
assert self.pipeline is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use # type: ignore[misc]
to replace this like we do in run_async
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but I also think it's fine to leave the assert. It's what @anakin87 and others have been doing else where in the code to help mypy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG!
Related Issues
Proposed Changes:
HuggingFaceLocalChatGenerator
to reuse code where possible between therun
andrun_async
methods.How did you test it?
Existing tests
Notes for the reviewer
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
and added!
in case the PR includes breaking changes.