Cannot simultaneously use tools (bindTools to bind) and structured output (withStructuredOutput) with Langchainjs #7702
Replies: 1 comment 2 replies
-
@ameramayreh Hello there! I'm here to help you out with any bugs, questions, or contributions you might have. Let's crush those bugs together! In LangChainJS, the To achieve the functionality you are looking for, you might need to implement a custom solution that manually handles both tool invocation and structured output parsing. This could involve invoking the tools separately and then applying the structured output schema to the results manually. For now, you can consider handling the tool calls and structured output separately in your application logic, ensuring that the results from the tools are processed according to your structured output requirements before being passed back to the model or user. This approach would require more manual handling but can achieve the desired outcome until the framework potentially supports this feature natively in future updates. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
I'm trying to use tools and structured output with
ChatOpenAI
simultaneously but each method to support tools or structured outputs returns a runnable that does not support the other methods.This works with OpenAI official SDK (see the example), but not for langchainjs (see below).
Is there a way to implement the example in langchainjs?
System Info
[email protected] | MIT | deps: 12 | versions: 310
Typescript bindings for langchain
https://github.com/langchain-ai/langchainjs/tree/main/langchain/
keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores
dist
.tarball: https://registry.npmjs.org/langchain/-/langchain-0.3.15.tgz
.shasum: c6c8b17bf20c870795e31515f48abde7d13ccc9d
.integrity: sha512-+DQ4I2iy4b5sErkxo6jAkgmumvhgqLwLB2fmiGl3yDt8+VVZdB1MUULZMzf+6ubarNc7Mwn/sxHUqK4GhEndhg==
.unpackedSize: 2.9 MB
dependencies:
@langchain/openai: >=0.1.0 <0.5.0 jsonpointer: ^5.0.1 uuid: ^10.0.0
@langchain/textsplitters: >=0.0.0 <0.2.0 langsmith: >=0.2.8 <0.4.0 yaml: ^2.2.1
js-tiktoken: ^1.0.12 openapi-types: ^12.1.3 zod-to-json-schema: ^3.22.3
js-yaml: ^4.1.0 p-retry: 4 zod: ^3.22.4
published 2 weeks ago by jacoblee93
Windows 10 pro
Node: v20.12.2
Npm: 10.5.0
Beta Was this translation helpful? Give feedback.
All reactions