forked from kyegomez/swarms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsvagent_example.py
48 lines (41 loc) · 1.44 KB
/
csvagent_example.py
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
# Example usage
from pathlib import Path
from swarms.structs.csv_to_agent import AgentLoader, AgentValidationError
if __name__ == "__main__":
# Example agent configurations
agent_configs = [
{
"agent_name": "Financial-Analysis-Agent",
"system_prompt": "You are a financial expert...",
"model_name": "gpt-4o-mini", # Updated to correct model name
"max_loops": 1,
"autosave": True,
"dashboard": False,
"verbose": True,
"dynamic_temperature": True,
"saved_state_path": "finance_agent.json",
"user_name": "swarms_corp",
"retry_attempts": 3,
"context_length": 200000,
"return_step_meta": False,
"output_type": "string",
"streaming": False,
}
]
try:
# Initialize CSV manager
csv_manager = AgentLoader(Path("agents.csv"))
# Create CSV with initial agents
csv_manager.create_agent_csv(agent_configs)
# Load agents from CSV
agents = csv_manager.load_agents()
# Use an agent
if agents:
financial_agent = agents[0]
financial_agent.run(
"How can I establish a ROTH IRA to buy stocks and get a tax break?"
)
except AgentValidationError as e:
print(f"Validation error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")