Replies: 1 comment 2 replies
-
@bnn16 Howdy! I'm here to help you with bugs, answer questions, and make you a contributor. Let's squash those bugs together! I found a similar issue where the agent was not correctly incorporating the observations from the tool calls into its decision-making process, causing the agent to repeatedly call the same tool without using the observation for the final response [1]. Additionally, there was an issue where the response object from the To resolve the "Cannot read properties of undefined (reading 'content')" error, ensure that the response structure from the LLM is as expected and that the
const { ChatOpenAI } = require("@langchain/openai");
const model = new ChatOpenAI({
model: "gpt-4",
temperature: 0,
configuration: {
baseURL: LLM_GATEWAY_BASE_URL,
dangerouslyAllowBrowser: true,
defaultHeaders: {
blabla
},
},
azureOpenAIBasePath: `ourpath`,
azureOpenAIApiDeploymentName: model,
azureOpenAIApiVersion: '2024-02-01',
azureOpenAIApiKey: 'fake-key-we-use-auth',
});
async function invokeModel() {
try {
const result = await model.invoke("Tell me a joke about cats");
console.log("Model response:", result);
// Check if the response contains the expected structure
if (result && result.choices && result.choices[0] && result.choices[0].message && result.choices[0].message.content) {
console.log("Message content:", result.choices[0].message.content);
} else {
console.error("Unexpected response structure:", result);
}
} catch (e) {
console.error("Error invoking model:", e.message);
}
}
invokeModel();
By following these steps, you can ensure that the response is correctly structured and handled, which should help resolve the error. If the issue persists, please provide the detailed logs from the |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
I'm trying to use langchain to create an agent with openai functions/tools.
My application is living fully in the front-end. React.
In my network tab I can see the responce of the llm is SUCCESSFUL I CAN SEE THE CONTENT but the parser fails
But i can see the network tab
that the responce is there -_-
System Info
"@langchain/core": "^0.2.31",
"@langchain/openai": "^0.2.10",
"langchain": "^0.3.0",
platform macos
node version -> Node.js v20.12.2.
npm version 10.8.2
Beta Was this translation helpful? Give feedback.
All reactions