You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/example.py

51 lines
1.3 KiB

5 months ago
import os
4 months ago
from dotenv import load_dotenv
2 months ago
from swarm_models import OpenAIChat
from swarms import Agent
from swarms.prompts.finance_agent_sys_prompt import (
FINANCIAL_AGENT_SYS_PROMPT,
)
4 months ago
load_dotenv()
5 months ago
# Get the OpenAI API key from the environment variable
api_key = os.getenv("OPENAI_API_KEY")
5 months ago
# Create an instance of the OpenAIChat class
5 months ago
model = OpenAIChat(
openai_api_key=api_key, model_name="gpt-4o-mini", temperature=0.1
5 months ago
)
# Initialize the agent
agent = Agent(
4 months ago
agent_name="Financial-Analysis-Agent",
2 months ago
system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
5 months ago
llm=model,
2 months ago
max_loops=1,
5 months ago
autosave=True,
dashboard=False,
verbose=True,
dynamic_temperature_enabled=True,
saved_state_path="finance_agent.json",
user_name="swarms_corp",
retry_attempts=1,
5 months ago
context_length=200000,
return_step_meta=True,
2 months ago
output_type="json", # "json", "dict", "csv" OR "string" soon "yaml" and
streaming_on=False,
2 months ago
auto_generate_prompt=False, # Auto generate prompt for the agent based on name, description, and system prompt, task
2 months ago
artifacts_on=True,
artifacts_output_path="roth_ira_report",
artifacts_file_extension=".txt",
2 months ago
max_tokens=8000,
5 months ago
)
2 months ago
print(
agent.run(
2 months ago
"How can I establish a ROTH IRA to buy stocks and get a tax break? What are the criteria. Create a report on this question."
2 months ago
)
5 months ago
)