-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
core[patch]: support final AIMessage responses in tool_example_to_messages
#28267
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
This reverts commit b270ffb.
@@ -495,20 +495,25 @@ def convert_to_openai_tool( | |||
|
|||
|
|||
def tool_example_to_messages( |
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.
This utility was added 8 months ago but is not documented. Thoughts on retroactively marking it @beta
?
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.
Sure I don't mind!
hmm tool calls are also limited to BaseModel / should probably supported typed dicts
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.
Marked beta
Looked into supporting TypedDict but we need a way of getting the tool name from an instance of TypedDict
from typing_extensions import TypedDict
class Apple(TypedDict):
color: str
tool_call = Apple(color="red")
tool_call.__class__.__name__
'dict'
We have a test test_structured_few_shot_examples in standard integration tests that implements a version of tool-calling few shot examples that works with ~all tested providers. The formulation supported by ~all providers is:
human message, tool call, tool message, AI reponse
.Here we update
langchain_core.utils.function_calling.tool_example_to_messages
to support this formulation.The
tool_example_to_messages
util is undocumented outside of our API reference. IMO, if we are testing that this function works across all providers, it can be helpful to feature it in our guides. The structured few-shot examples we document at the moment require users to implement this function and can be simplified.