Replies: 1 comment
-
Hey @pappitito! Great to see you back with another interesting challenge. How have you been? To integrate the LangChain OpenAI API with a large amount of JSON data while still allowing it to answer generic questions unrelated to the data, you can follow these steps:
Here's a simplified example, assuming you have created a custom tool named // Assuming JsonDataTool is a custom tool you've created for handling your JSON data
class JsonDataTool extends StructuredTool {
// Implementation of your tool...
}
// Create an instance of OpenAIAssistantRunnable with both custom and generic tools
const tools = [new WeatherTool(), new HumanReadableChecker(), new JsonDataTool()];
const agent = await OpenAIAssistantRunnable.createAssistant({
model: "gpt-3.5-turbo-1106",
instructions: "Use the provided tools to answer questions about the weather, process JSON data, or answer generic questions.",
name: "Enhanced Assistant",
tools,
asAgent: true,
});
// Use AgentExecutor to process queries
const agentExecutor = AgentExecutor.fromAgentAndTools({
agent,
tools,
});
const assistantResponse = await agentExecutor.invoke({
content: "What's the weather in San Francisco and Tokyo? Also, process this specific JSON data query...",
});
console.log(assistantResponse); This approach allows you to leverage the LangChain OpenAI API to process both specific JSON data and answer generic questions by defining custom tools and clear instructions for the assistant. Please note that the For more information, you can refer to the langchain/src/experimental/openai_assistant/tests/openai_assistant.int.test.ts file in the LangChain JS repository. Sources
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
//no code available for now
Description
please i am trying to integrate langchain openai api with large amount of JSON data, in such a way that it can still answer generic questions unrelated to the data.
System Info
"yarn info langchain"
platform ( mac)
Beta Was this translation helpful? Give feedback.
All reactions