-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatcmpl-deepseek.py
More file actions
33 lines (28 loc) · 829 Bytes
/
chatcmpl-deepseek.py
File metadata and controls
33 lines (28 loc) · 829 Bytes
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
from agents import Agent, ModelSettings, Runner, function_tool, OpenAIChatCompletionsModel
from openai import AsyncOpenAI
import os
custom_client = AsyncOpenAI(
base_url="https://api.deepseek.com",
api_key=os.getenv("DEEPSEEK_API_KEY")
)
my_model = OpenAIChatCompletionsModel(
model="deepseek-reasoner",
openai_client=custom_client,
)
@function_tool
def echo_tool(input: str) -> str:
print("called echo_tool")
return input
agent = Agent(
name="Assistant",
instructions="You are a helpful assistant",
model=my_model,
tools=[echo_tool],
# model_settings=ModelSettings(reasoning=Reasoning(effort="low"))
)
result = Runner.run_sync(
agent, "Use the echo_tool to echo the message 'Hello, world!"
)
print(result.final_output)
print("------")
print(result.to_input_list())