-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlitellm-claude.py
More file actions
44 lines (33 loc) · 1.01 KB
/
litellm-claude.py
File metadata and controls
44 lines (33 loc) · 1.01 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
from agents import Agent, ModelSettings, Runner, function_tool
from agents.extensions.models.litellm_model import LitellmModel
from openai.types.shared import Reasoning
@function_tool
def echo_tool(input: str) -> str:
return input
model = LitellmModel(
model="claude-opus-4-5-20251101",
)
agent = Agent(
name="Assistant",
instructions="You are a helpful assistant",
model=model,
tools=[echo_tool],
model_settings=ModelSettings(reasoning=Reasoning(effort="low"))
)
print("================ Turn 1")
result = Runner.run_sync(
agent, "Can you use the echo_tool to echo the message 'Hello, world!'?"
)
print(result.final_output)
print("------")
print(result.to_input_list())
print("------")
print("================ Turn 2")
messages = result.to_input_list()
messages.append( { "role": "user", "content": "Can you use the echo_tool to echo the message 'Hello, world!'?"})
result = Runner.run_sync(
agent, messages
)
print(result.final_output)
print("------")
print(result.to_input_list())