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.
68 lines
1.5 KiB
68 lines
1.5 KiB
import os
|
|
from swarms import Agent
|
|
from swarm_models import OpenAIChat
|
|
from swarms.prompts.finance_agent_sys_prompt import (
|
|
FINANCIAL_AGENT_SYS_PROMPT,
|
|
)
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
# Get the OpenAI API key from the environment variable
|
|
api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
# Create an instance of the OpenAIChat class
|
|
model = OpenAIChat(
|
|
openai_api_key=api_key,
|
|
model_name="gpt-4o-mini",
|
|
temperature=0.1,
|
|
max_tokens=2000,
|
|
)
|
|
|
|
# Initialize the agent
|
|
agent = Agent(
|
|
agent_name="Financial-Analysis-Agent",
|
|
system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
|
|
llm=model,
|
|
max_loops=1,
|
|
autosave=True,
|
|
dashboard=False,
|
|
verbose=True,
|
|
dynamic_temperature_enabled=True,
|
|
saved_state_path="finance_agent.json",
|
|
user_name="swarms_corp",
|
|
retry_attempts=1,
|
|
context_length=200000,
|
|
return_step_meta=False,
|
|
# output_type="json",
|
|
output_type=str,
|
|
)
|
|
|
|
|
|
out = agent.run(
|
|
"How can I establish a ROTH IRA to buy stocks and get a tax break? What are the criteria"
|
|
)
|
|
print(out)
|
|
|
|
|
|
def log_agent_data(data: dict):
|
|
import requests
|
|
|
|
data_dict = {
|
|
"data": data,
|
|
}
|
|
|
|
url = "https://swarms.world/api/get-agents/log-agents"
|
|
headers = {
|
|
"Content-Type": "application/json",
|
|
"Authorization": "Bearer sk-f24a13ed139f757d99cdd9cdcae710fccead92681606a97086d9711f69d44869",
|
|
}
|
|
|
|
response = requests.post(url, json=data_dict, headers=headers)
|
|
|
|
return response.json()
|
|
|
|
|
|
out = log_agent_data(agent.to_dict())
|
|
print(out)
|