Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with ChatGoogleGenerativeAI #6

Open
his-maj-esty opened this issue Jun 12, 2024 · 6 comments
Open

Not working with ChatGoogleGenerativeAI #6

his-maj-esty opened this issue Jun 12, 2024 · 6 comments

Comments

@his-maj-esty
Copy link

his-maj-esty commented Jun 12, 2024

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);`

@his-maj-esty
Copy link
Author

@bracesproul please help me resolving this

@dylanmclane
Copy link

@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

@his-maj-esty
Copy link
Author

@dylanmclane I think langchain handles that under the hood, by providing a unified api for all the providers

@rossanodr
Copy link

@dylanmclane I think langchain handles that under the hood, by providing a unified api for all the providers

that's what I thought

@rossanodr
Copy link

I tried using import { ChatGoogle } from "@langchain/google-webauth"; with the configuration apiVersion: "v1beta", and I had the same error.

@DevDeepakBhattarai
Copy link

DevDeepakBhattarai commented Jul 12, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants