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

v3 repetitive function call ? #15

Open
smallufo opened this issue Dec 27, 2024 · 2 comments
Open

v3 repetitive function call ? #15

smallufo opened this issue Dec 27, 2024 · 2 comments

Comments

@smallufo
Copy link

This is my function call (simulate weather service)

request

{
    "messages": [
        {
            "role": "user",
            "content": "What's the weather like today in New York?"
        }
    ],
    "model": "deepseek-chat",
    "stream": false,
    "temperature": 1.0,
    "top_p": 1.0,
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_current_weather",
                "description": "Get the current weather",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "The city and state, e.g. San Francisco, CA"
                        },
                        "format": {
                            "type": "string",
                            "description": "The temperature unit to use. C for Celsius, F for Fahrenheit"
                        }
                    },
                    "required": [
                        "location",
                        "format"
                    ]
                }
            }
        }
    ]
}

deepseek reply (with funCall request)

{
   "id":"c2724bf2-2773-48f7-85d6-3e93f2c6f154",
   "object":"chat.completion",
   "created":1735311015,
   "model":"deepseek-chat",
   "choices":[
      {
         "index":0,
         "message":{
            "role":"assistant",
            "content":"",
            "tool_calls":[
               {
                  "index":0,
                  "id":"call_0_f70089f7-46dc-49b5-b031-a6c70ec53fa8",
                  "type":"function",
                  "function":{
                     "name":"get_current_weather",
                     "arguments":"{\"location\":\"New York, NY\",\"format\":\"F\"}"
                  }
               }
            ]
         },
         "logprobs":null,
         "finish_reason":"tool_calls"
      }
   ],
   "usage":{
      "prompt_tokens":167,
      "completion_tokens":27,
      "total_tokens":194,
      "prompt_cache_hit_tokens":128,
      "prompt_cache_miss_tokens":39
   },
   "system_fingerprint":"fp_f1afce2943"
}

And I reply :

{
    "messages": [
        {
            "role": "user",
            "content": "What's the weather like today in New York?"
        },
        {
            "role": "assistant",
            "content": "",
            "tool_calls": [
                {
                    "id": "call_0_f70089f7-46dc-49b5-b031-a6c70ec53fa8",
                    "type": "function",
                    "function": {
                        "name": "get_current_weather",
                        "arguments": "{\"location\":\"New York, NY\",\"format\":\"F\"}"
                    }
                }
            ]
        },
        {
            "role": "tool",
            "content": "73 degrees Fahrenheit",
            "tool_call_id": "call_0_f70089f7-46dc-49b5-b031-a6c70ec53fa8"
        }
    ],
    "model": "deepseek-chat",
    "stream": false,
    "temperature": 1.0,
    "top_p": 1.0,
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_current_weather",
                "description": "Get the current weather",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "The city and state, e.g. San Francisco, CA"
                        },
                        "format": {
                            "type": "string",
                            "description": "The temperature unit to use. C for Celsius, F for Fahrenheit"
                        }
                    },
                    "required": [
                        "location",
                        "format"
                    ]
                }
            }
        }
    ]
}

BUT deepseek asks again !!! Instead of summarize the weather data.

{
   "id":"8040b2c7-0936-43d6-a290-a6e2d23932eb",
   "object":"chat.completion",
   "created":1735311016,
   "model":"deepseek-chat",
   "choices":[
      {
         "index":0,
         "message":{
            "role":"assistant",
            "content":"",
            "tool_calls":[
               {
                  "index":0,
                  "id":"call_0_6b19ba9e-cabb-4a69-bf35-9170f1143abb",
                  "type":"function",
                  "function":{
                     "name":"get_current_weather",
                     "arguments":"{\"location\":\"New York\",\"format\":\"F\"}"
                  }
               }
            ]
         },
         "logprobs":null,
         "finish_reason":"tool_calls"
      }
   ],
   "usage":{
      "prompt_tokens":175,
      "completion_tokens":25,
      "total_tokens":200,
      "prompt_cache_hit_tokens":128,
      "prompt_cache_miss_tokens":47
   },
   "system_fingerprint":"fp_f1afce2943"
}

This situation won't occur on OpenAI's function calling.
Is there anything wrong ?

Thanks.

@witherleaves
Copy link

I also encountered this issue when calling it in lobechat, where the function kept being called repeatedly

@whisper-bye
Copy link

whisper-bye commented Dec 28, 2024

Please improve support for tool calls, preferably openai's beta.chat.completions.parse, which is critical for agent-related uses.

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

3 participants