zuisong / gemini-openai-proxy

OpenAI to Google Gemini https://gemini-openai-proxy.deno.dev
https://gemini-openai-proxy.zuisong.workers.dev
MIT License
312 stars 88 forks source link

tool/function calls not working?? #52

Closed gaurishmehra closed 5 months ago

gaurishmehra commented 5 months ago

can anyone share a working example of the tool or function calls working?? no matter what i do it just gives an empty response when it should call a tool

zuisong commented 5 months ago

example:

curl --request POST \
  --url https://gemini-openai-proxy.deno.dev/v1/chat/completions \
  --header 'Authorization: Bearer $YOUR_GEMINI_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "messages": [
        {
            "role": "user",
            "content": "I spent $6 on Coke today"
        }
    ],
    "model": "gpt-4",
    "max_tokens": null,
    "stream": false,
    "n": 1,
    "temperature": 0.0,
    "functions": [
        {
            "name": "bookkeeping",
            "description": "bookkeeping assistant",
            "parameters": {
                "type": "object",
                "properties": {
                    "category": {
                        "type": "string",
                        "description": "type"
                    },
                    "price": {
                        "type": "string",
                        "description": "amount"
                    }
                },
                "required": [
                    "category",
                    "price"
                ]
            }
        }
    ]
}'

response:

{
    "id": "chatcmpl-abc123",
    "object": "chat.completion",
    "created": 1717037343,
    "model": "gpt-4",
    "choices": [
        {
            "message": {
                "role": "assistant",
                "content": null,
                "function_call": {
                    "name": "bookkeeping",
                    "arguments": "{\"category\":\"drinks\",\"price\":\"$6\"}"
                }
            },
            "finish_reason": "function_call",
            "index": 0,
            "logprobs": null
        }
    ]
}