-
Notifications
You must be signed in to change notification settings - Fork 677
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
fix(langchain): structured output response parsing #2214
Conversation
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.
Cool, though I'm not sure how it fixes structured outputs - it seems like you're fixing tool calling and not structured outputs - unless I'm missing something?
Also, I'd add tests for this
if dataclasses.is_dataclass(o): | ||
return dataclasses.asdict(o) | ||
|
||
if hasattr(o, "to_json"): | ||
return o.to_json() | ||
|
||
# check if o is a pydantic model |
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.
pydantic should be handled with the to_json
, no?
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.
depends on the version. in pydantic v1 (which is apparently installed in my env) it won't.. they method was throwing an exception which was caught by the @dont_throw
decorator, took me a while to find it.
@@ -585,7 +593,7 @@ def on_llm_end( | |||
) | |||
|
|||
_set_chat_response(span, response) | |||
span.end() | |||
self._end_span(span, run_id) |
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.
you're right - but it won't change anything since an LLM span is a leaf span anyway
No description provided.