Skip to content

Not working with ChatGoogleGenerativeAI #6

Description

@his-maj-esty

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

Activity

  1. his-maj-esty commented on Jun 14, 2024

    @his-maj-esty
    Author

    @bracesproul please help me resolving this

  2. dylanmclane commented on Jun 17, 2024

    @dylanmclane

    @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

  3. his-maj-esty commented on Jun 18, 2024

    @his-maj-esty
    Author

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

  4. rossanodr commented on Jul 4, 2024

    @rossanodr

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

    that's what I thought

  5. rossanodr commented on Jul 4, 2024

    @rossanodr

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

  6. DevDeepakBhattarai commented on Jul 12, 2024

    @DevDeepakBhattarai

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions