-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_usage.py
More file actions
65 lines (57 loc) · 2.25 KB
/
Copy pathbasic_usage.py
File metadata and controls
65 lines (57 loc) · 2.25 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""Basic usage example for the Lumo SDK."""
from lumo_sdk import LumoClient, Message, MessageRole
# Initialize the client
client = LumoClient(api_key="your-api-key-here")
# Example 1: Simple task
print("Example 1: Simple task")
response = client.run_task(
task="What is the weather in Berlin?",
model="gpt-4.1-nano",
base_url="https://api.openai.com/v1/chat/completions",
tools=["ExaSearchTool", "VisitWebsite"],
)
print(f"Final Answer: {response.final_answer}")
print(f"Number of steps: {len(response.steps)}")
for i, step in enumerate(response.steps, 1):
print(f" Step {i}:")
if step.llm_output:
print(f" LLM Output: {step.llm_output[:100]}...")
if step.tool_calls:
print(f" Tools used: {len(step.tool_calls)}")
for tool_call in step.tool_calls:
tool_name = tool_call.function.name
arguments = tool_call.function.arguments
print(f" - {tool_name} (ID: {tool_call.id}, Type: {tool_call.type}, Arguments: {arguments})")
if step.token_usage:
print(f" Token Usage: {step.token_usage.total_tokens} tokens")
else:
print(" Tools used: None")
print(f"Total Token Usage: {response.token_usage.total_tokens} tokens")
print()
# Example 2: Task with conversation history
print("Example 2: Task with conversation history")
history = [
Message(role=MessageRole.USER, content="Hello!"),
Message(role=MessageRole.ASSISTANT, content="Hi! How can I help you?"),
]
response = client.run_task(
task="What did I just say?",
model="gpt-4.1-nano",
base_url="https://api.openai.com/v1/chat/completions",
history=history,
)
print(f"Final Answer: {response.final_answer}")
print(f"Number of steps: {len(response.steps)}")
for i, step in enumerate(response.steps, 1):
print(f" Step {i}:")
if step.llm_output:
print(f" LLM Output: {step.llm_output[:100]}...")
if step.tool_calls:
print(f" Tools used: {len(step.tool_calls)}")
for tool_call in step.tool_calls:
tool_name = tool_call.function.name
arguments = tool_call.function.arguments
print(f" - {tool_name} (ID: {tool_call.id}, Type: {tool_call.type}, Arguments: {arguments})")
else:
print(" Tools used: None")
print()