Replies: 2 comments 8 replies
-
Consider this message transcript as a motivating example:
|
Beta Was this translation helpful? Give feedback.
6 replies
-
hello langchain. I want to use openai to perform a web search using their web search tool and have the response in a particular json format. This works with vanial openai client and their web playground. In langchain, the most natural way you would expect to use this is to chain .bind_tools with a .with_structured_output. This is not allowed, at least not in the js version of langchain |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
I would like to be able to use ChatOpenAI to provide both tools and a response_format schema. The OpenAI API allows this directly by simply providing both tools and response format. It seems to provide a good mechanism for ensuring structured responses--especially taking advantage of constrained decoding--that both expect results from tool calls and do not.
Currently this seems to be possible if I manually bind result format and tools to the model, but that looses the helper functionality provided by the
with_structured_output
andbind_tools
helpers.https://openai.com/index/introducing-structured-outputs-in-the-api/
Motivation
I would like to directly take advantage of the model's choice of whether to call a tool or not based on the context, while still ensuring that if a tool call is not necessary the resulting message is structured.
Proposal (If applicable)
I think an ideal option would be to allow
with_structured_output
to accept a tools parameter, which, if provided, first binds the tools and then binds the response format, and builds the appropriate parser chain.Beta Was this translation helpful? Give feedback.
All reactions