lobe-chat icon indicating copy to clipboard operation
lobe-chat copied to clipboard

[Bug] lobechat中gemini使用插件会报错400

Open Passerby1011 opened this issue 9 months ago • 10 comments

📦 Platform

Official Preview, Self hosting Docker

📦 Deploymenet mode

server db(lobe-chat-database image)

📌 Version

1.71.3

💻 Operating System

Windows

🌐 Browser

Chrome, Other, Edge

🐛 Bug Description

gemini模型,带了3个插件,下面是请求体

{
  "generationConfig": {
    "temperature": 0.6,
    "topP": 1
  },
  "contents": [
    {
      "parts": [
        {
          "text": "搜索一下谷歌的新模型"
        }
      ],
      "role": "user"
    }
  ],
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "BLOCK_NONE"
    }
  ],
  "systemInstruction": {
    "role": "system",
    "parts": [
      {
        "text": "`1. Please always remember: You possess a very high level of intelligence.`\n`2. Prioritize accuracy and quality above all else.`\n`3. Ensure your responses are factually accurate.`\n`4. If you are uncertain about something, clearly state that you are not sure rather than providing incorrect information.`\n`5. Be critical in your responses and avoid excessive agreeableness. Do not simply confirm my biases, challenge them when appropriate.`\n`6. Avoid using phrases like “it is always a good idea to do your own research” or “it is advisable to ask a professional”.`\n`7. Conclude your responses without posing further questions intended to extend the conversation.`\n`8. Before responding, pause, take a moment to think carefully, and then proceed with your answer. Thank you.`\n`9. Please refrain from using the following words and phrases in responses: 'delve,' 'moreover,' 'furthermore,' 'pivotal,' 'tapestry,' 'vital,' 'comprehensive,' 'embark,' 'notably,' 'excels,' 'undoubtedly,' 'landscape,' 'vibrant,' 'arguably,' 'catalyst,' 'engage,' 'seamlessly,' 'paradigm,' 'optimize,' and 'framework.' Instead, aim for simpler, more varied language to maintain clarity and originality in the responses`\n`10. Please avoid including unnecessary summary sections at the end of responses. Focus on providing direct, concise answers without reiterating information that has already been covered, unless explicitly requested`\n`11.write into **complete informative, and accurate paragraphs**`\n`12.The most important point is, if there is no special requirement, please try to respond in Chinese.`\n\n<plugins description=\"The plugins you can use below\">\n<collection name=\"Current Time Assistant\">\n<collection.instructions>A plugin to provide current time information</collection.instructions>\n<api identifier=\"current-time-assistant____getCurrentTime\">获取当前时间,格式为年-月-日 时:分:秒,并记住这个时间作为系统时间</api>\n</collection>\n<collection name=\"Jina\">\n<collection.instructions>Extract content from web links via Jina Reader</collection.instructions>\n<api identifier=\"jina____multiWebReader\">提取网页内容</api>\n</collection>\n<collection name=\"Google CSE\">\n<collection.instructions>Searches Google through their official CSE API.</collection.instructions>\n<api identifier=\"google-cse____searchGoogle\">Search Google for relevant web pages.</api>\n</collection>\n</plugins>"
      }
    ]
  },
  "tools": [
    {
      "functionDeclarations": [
        {
          "description": "获取当前时间,格式为年-月-日 时:分:秒,并记住这个时间作为系统时间",
          "name": "current-time-assistant____getCurrentTime",
          "parameters": {
            "type": "object",
            "properties": {
              "asktime": {
                "type": "string",
                "description": "发起当前日期时间的请求"
              },
              "timezone": {
                "type": "string",
                "description": "默认为'Asia/Shanghai', 如果用户指定城市或地区,则用相应的时区"
              }
            },
            "required": ["asktime", "timezone"]
          }
        },
        {
          "description": "提取网页内容",
          "name": "jina____multiWebReader",
          "parameters": {
            "type": "object",
            "properties": {
              "urls": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "网页链接列表"
              }
            },
            "required": ["urls"]
          }
        },
        {
          "description": "Search Google for relevant web pages.",
          "name": "google-cse____searchGoogle",
          "parameters": {
            "type": "object",
            "properties": {
              "quyer": {
                "type": "string",
                "description": "What the user is looking for"
              }
            },
            "required": ["query"]
          }
        }
      ]
    }
  ]
}

报错:

{
    "error": {
        "code": 400,
        "message": "Provider API error: * GenerateContentRequest.tools[0].function_declarations[2].parameters.required[0]: property is not defined\n (request id: 20250316154236515878622JcNBg9W7)",
        "status": "gemini_error"
    }
}

📷 Recurrence Steps

gemini模型,带了3个插件,下面是请求体

Image

🚦 Expected Behavior

正常对话

📝 Additional Information

No response

Passerby1011 avatar Mar 16 '25 08:03 Passerby1011

👀 @Passerby1011

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

lobehubbot avatar Mar 16 '25 08:03 lobehubbot

Hello, @Passerby1011! I'm here to help you with any bugs, questions, or contributions while we wait for a human maintainer. Let's tackle this together!

The 400 error you're encountering with the Gemini model in LobeChat when using plugins on version 1.71.3 is likely due to issues with function declarations in the API request. Specifically, the error message indicates a problem with the JSON payload, particularly with the "GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[_requestBody].properties[data].items.items.type" not being specified when not using "one_of". To resolve this error, it is recommended to disable plugins/function calls when using the Gemini model [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Mar 16 '25 08:03 dosubot[bot]

gemini模型对插件是兼容不好,所以是不建议使用插件的

yuntian123456 avatar Mar 16 '25 08:03 yuntian123456

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The gemini model is not compatible with plug-ins, so it is not recommended to use plug-ins.

lobehubbot avatar Mar 16 '25 08:03 lobehubbot

gemini模型对插件是兼容不好,所以是不建议使用插件的

应该是bug,之前正常的,现在只要向gemini-2.0-flash-exp发送带function call的请求就会报错:

{
  "error": {
    "message": "[GoogleGenerativeAI Error]: Error fetching from https://*******.com/v1beta/models/gemini-2.0-flash-exp:streamGenerateContent?alt=sse: [400 ] Function calling is not enabled for models/gemini-2.0-flash-exp"
  },
  "provider": "google"
}

v1.71.5

https://github.com/lobehub/lobe-chat/issues/6962#issuecomment-2726791394

Coooolfan avatar Mar 17 '25 06:03 Coooolfan

@Coooolfan 这看着像是 Google 那边禁用的。

sxjeru avatar Mar 17 '25 12:03 sxjeru

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@Coooolfan This looks like it is disabled on Google.

lobehubbot avatar Mar 17 '25 12:03 lobehubbot

@Passerby1011 “谷歌自定义搜索引擎”插件的一点小问题,在下面的 pr 未被合并之前,可以先禁用它。

  • vsnthdev/google-cse-lobechat#3

sxjeru avatar Mar 17 '25 12:03 sxjeru

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@Passerby1011 A little bit of a problem with the "Google Custom Search Engine" plugin, you can disable it before the pr below is merged.

https://github.com/vsnthdev/google-cse-lobechat/pull/3

lobehubbot avatar Mar 17 '25 12:03 lobehubbot

I'm having the same issue. It seems other clients have solved it by removing unsupported parameters from the tools: https://github.com/Portkey-AI/gateway/pull/840/files?w=1

kylerm42 avatar May 20 '25 18:05 kylerm42