Open his-maj-esty opened 3 months ago
@bracesproul please help me resolving this
@his-maj-esty You can't only replace ChatOpenAI with ChatGoogleGenerativeAI. Gemini takes different inputs than Open AI API. You'll need to read the Gemini docs to figure out the syntax to send to the Gemini API. Probably start here: https://ai.google.dev/gemini-api/docs/api-overview
@dylanmclane I think langchain handles that under the hood, by providing a unified api for all the providers
@dylanmclane I think langchain handles that under the hood, by providing a unified api for all the providers
that's what I thought
I tried using import { ChatGoogle } from "@langchain/google-webauth"; with the configuration apiVersion: "v1beta", and I had the same error.
You can you ChatVertexAI
instead of ChatGoogleGenerativeAI
,It works this way but the process of setting up vertex AI is a bit lengthy. But be carefull there won't be any tool calling in the result.tool_calls
array. You will need to manually get the tools from the results.additional_kwargs.tool_calls
Error
I am getting error like this :
unhandledRejection: GoogleGenerativeAIError: [400 Bad Request] Invalid JSON payload received. Unknown name "default" at 'tools[0].function_declarations[1].parameters.properties[1].value.items.properties[0].value': Cannot find field. Invalid JSON payload received. Unknown name "exclusiveMinimum" at 'tools[0].function_declarations[1].parameters.properties[1].value.items.properties[2].value': Cannot find field. Invalid JSON payload received. Unknown name "exclusiveMinimum" at 'tools[0].function_declarations[1].parameters.properties[1].value.items.properties[3].value': Cannot find field. Invalid JSON payload received. Unknown name "additionalProperties" at 'tools[0].function_declarations[1].parameters.properties[1].value.items': Cannot find field. [{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"tools[0].function_declarations[1].parameters.properties[1].value.items.properties[0].value","description":"Invalid JSON payload received. Unknown name \"default\" at 'tools[0].function_declarations[1].parameters.properties[1].value.items.properties[0].value': Cannot find field."},{"field":"tools[0].function_declarations[1].parameters.properties[1].value.items.properties[2].value","description":"Invalid JSON payload received. Unknown name \"exclusiveMinimum\" at 'tools[0].function_declarations[1].parameters.properties[1].value.items.properties[2].value': Cannot find field."},{"field":"tools[0].function_declarations[1].parameters.properties[1].value.items.properties[3].value","description":"Invalid JSON payload received. Unknown name \"exclusiveMinimum\" at 'tools[0].function_declarations[1].parameters.properties[1].value.items.properties[3].value': Cannot find field."},{"field":"tools[0].function_declarations[1].parameters.properties[1].value.items","description":"Invalid JSON payload received. Unknown name \"additionalProperties\" at 'tools[0].function_declarations[1].parameters.properties[1].value.items': Cannot find field."}]}] at _makeRequestInternal (webpack-internal:///(rsc)/./node_modules/@google/generative-ai/dist/index.mjs:316:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async generateContentStream (webpack-internal:///(rsc)/./node_modules/@google/generative-ai/dist/index.mjs:700:22) at async eval (webpack-internal:///(rsc)/./node_modules/@langchain/google-genai/dist/chat_models.js:274:32) at async RetryOperation.eval [as _fn] (webpack-internal:///(rsc)/./node_modules/p-retry/index.js:50:12) { attemptNumber: 7, retriesLeft: 0 }
Steps to reproduce
replace ChatOpenAi with this in graph.tsx file : `import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
// rest of the code
const llm = new ChatGoogleGenerativeAI({ temperature: 0, model: "gemini-1.5-flash-latest", streaming: true, apiVersion: "v1beta", }).bindTools(tools);`