-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.py
More file actions
45 lines (38 loc) · 1.27 KB
/
example.py
File metadata and controls
45 lines (38 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from dotenv import load_dotenv
from openai import AsyncOpenAI
from rich import print
from tooluser import make_tool_user
load_dotenv()
async def main():
oai = make_tool_user(AsyncOpenAI())
res = await oai.chat.completions.create(
model="deepseek/deepseek-chat-v3-0324", # From OpenRouter https://openrouter.ai/deepseek/deepseek-chat-v3-0324
messages=[
{
"role": "user",
"content": "What's the time in Shanghai? Firstly describe your thinking and then use the tools.",
}
],
tools=[
{
"type": "function",
"function": {
"name": "get_time",
"description": "Get the time in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The location to get the time for",
},
},
},
},
}
],
)
print(res.choices[0].message)
if __name__ == "__main__":
import asyncio
asyncio.run(main())