-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_agent_ecommerce.py
More file actions
40 lines (34 loc) · 1.38 KB
/
code_agent_ecommerce.py
File metadata and controls
40 lines (34 loc) · 1.38 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
"""Code Agent example: dynamic e-commerce search/filter workflow."""
from pathlib import Path
from lumo_sdk import LumoClient
# Initialize the client (replace with your real key)
client = LumoClient(api_key="sk-")
# Load workflow from markdown file
workflow_path = Path(__file__).parent / "ecommerce_workflow.md"
with open(workflow_path, "r", encoding="utf-8") as f:
content = f.read()
# Extract the workflow content (skip the markdown header)
task_description = "\n".join(content.split("\n")[2:]).strip()
# Run the task with a Code Agent and web-capable tools
response = client.run_task(
task=task_description,
model="gpt-4.1-mini",
base_url="https://api.openai.com/v1/chat/completions",
tools=["ExaSearchTool", "VisitWebsite"],
agent_type="code-agent",
max_steps=8,
)
# Display results
print("Final Answer:\n", response.final_answer)
print("\nSteps taken:", len(response.steps))
for i, step in enumerate(response.steps, 1):
print(f"\nStep {i}:")
if step.llm_output:
print(" LLM Output:", step.llm_output[:160], "...")
if step.tool_calls:
print(f" Tools used: {len(step.tool_calls)}")
for call in step.tool_calls:
print(f" - {call.function.name} args={call.function.arguments}")
else:
print(" Tools used: None")
print("\nToken usage:", response.token_usage.total_tokens if response.token_usage else "n/a")