-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsales_analyst.py
More file actions
38 lines (31 loc) · 1.31 KB
/
Copy pathsales_analyst.py
File metadata and controls
38 lines (31 loc) · 1.31 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
"""
In this example, we create an agent that analyzes sales data and writes a report to a markdown file.
Please note that the agent will create a python script to analyze the data, in case of missing packages,
it will automatically install any necessary python packages to make the analysis possible (like pandas, matplotlib, etc.).
Finally, it will run the script to generate the report as well as the images.
"""
from deepagents import create_deep_agent
from deepagents_docker import DockerSandbox
backend = DockerSandbox(
shared_dir="examples/data",
allow_outbound_traffic=True,
)
agent = create_deep_agent(
model="openai:gpt-5.5",
backend=backend,
system_prompt="""You are a sales analyst assistant.""",
)
if __name__ == "__main__":
for step in agent.stream(
{
"messages": """
Analyze the "sales.csv" data and write a report (with charts) into a file called "sales_report.md".
Do not write any temporary files in our "shared" directory: write only the final report and put the images into a "img" directory.
"""
},
stream_mode="updates",
):
for update in step.values():
if update and (messages := update.get("messages")):
for message in messages:
message.pretty_print()