gemini api 使用openai 兼容的url 使用时 tool_call 有问题 #1176
Replies: 4 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
-
|
好像是说 index 的值是 undefined,这个是谷歌的兼容openai api 实现的问题,不知道能不能在下游cli-proxy-api 解决这个问题 |
Beta Was this translation helpful? Give feedback.
-
|
你再cpa中只需要填入api key即可,不用填写baseurl。然后再试试 |
Beta Was this translation helpful? Give feedback.
-
|
看懂了,这是流式(streaming)返回里 一句话结论👉 Gemini 的 streaming 具体发生了什么?你这段返回里最关键的是这里 👇 "tool_calls": [
{
"function": {
"arguments": "{\"filePath\":\"D:xxxx\\node_handler.go\"}",
"name": "read"
},
"id": "function-call-7079420158533790573",
"type": "function"
}
]问题点: 按照 OpenAI 官方 streaming 规范, {
"index": 0,
"id": "...",
"type": "function",
"function": {
"name": "...",
"arguments": "..."
}
}但 Gemini 2.5 Flash 的 chunk 返回里没有 为什么很多人都会踩这个坑?因为:
这是目前 Gemini streaming + tool calling 的一个已知兼容性坑 怎么修?给你 4 种可落地方案(从推荐到凑合)✅ 方案 1(最推荐):自己补
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
gemini api :
https://generativelanguage.googleapis.com/v1beta/openai/v1
为什么没有使用原版,因为我没有找到在ui哪里配置单独的代理
我是用openai 兼容api那里填入key 还有配置单独的代理(现在google 封的太厉害了)
然后调用工具会遇到报错
Beta Was this translation helpful? Give feedback.
All reactions