mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2025-09-09 13:55:27 +00:00
roll back ktransformers backend, add max_tokens, max_completion_tokens param
This commit is contained in:
parent
a1162eea01
commit
03a65d6bea
10 changed files with 144 additions and 161 deletions
45
ktransformers/tests/function_call_test.py
Normal file
45
ktransformers/tests/function_call_test.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
from openai import OpenAI
|
||||
|
||||
def send_messages(messages):
|
||||
response = client.chat.completions.create(
|
||||
model="deepseek-chat",
|
||||
messages=messages,
|
||||
tools=tools
|
||||
)
|
||||
return response.choices[0].message
|
||||
|
||||
client = OpenAI(
|
||||
api_key="placeholder",
|
||||
base_url="http://0.0.0.0:10002/v1",
|
||||
)
|
||||
|
||||
tools = [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"description": "Get weather of an location, the user shoud supply a location first",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"description": "The city and state, e.g. San Francisco, CA",
|
||||
}
|
||||
},
|
||||
"required": ["location"]
|
||||
},
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
messages = [{"role": "user", "content": "How's the weather in Hangzhou?"}]
|
||||
message = send_messages(messages)
|
||||
print(f"User>\t {messages[0]['content']}")
|
||||
print(message)
|
||||
tool = message.tool_calls[0]
|
||||
messages.append(message)
|
||||
|
||||
messages.append({"role": "tool", "tool_call_id": tool.id, "content": "24℃"})
|
||||
message = send_messages(messages)
|
||||
print(f"Model>\t {message.content}")
|
Loading…
Add table
Add a link
Reference in a new issue