Skip to content

Configurable message parsing #223

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Configurable message parsing #223

wants to merge 5 commits into from

Conversation

sidnarayanan
Copy link
Collaborator

LocalLLMCallOp previously hardcoded llama 3.1-friendly message parsing logic. This PR makes that configurable by the user.

@sidnarayanan sidnarayanan requested review from a team and kwanUm January 25, 2025 02:48
Copy link
Collaborator

@jamesbraza jamesbraza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, added some optional comments

"""

supported_templates: ClassVar[set[str]] = {
"llama2_chat_template_ori.jinja",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No one but us is going to know what an Ori template is. Any chance you can rename this file, or add a comment explaining it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's on my to-do list to rename this, and there's documentation in chat_templates/README.md for all of the chat templates. I'll leave it for a later PR to sort this out.

Comment on lines +89 to +91
assert len(msg.tool_calls) == 1, (
"Support parsing only single tool call for now"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is about supporting something, I would rather see raise NotImplementedError than assert

self.model_name = model_config.model
@classmethod
@abstractmethod
def prep_tools_for_tokenizer(cls, tools: Tools | None) -> list[dict] | None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to prepare tools, why are we then passing None tools?

Just pointing out, Tools | None doesn't really make sense, imo this should be something like *tools: Tool or tools: Tools

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because tools can be None here:

tools: list[Tool] | None = None,
- this method just mirrors the typing of the arguments that can be passed to [Local]LLMCallOp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants