generated from kyegomez/Python-Package-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.py
52 lines (43 loc) · 1.19 KB
/
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
49
50
51
52
import os
from dotenv import load_dotenv
from swarm_models import OpenAIChat
from swarms import Agent
from news_swarm.main import NewsAgent
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
)
# Initialize the agent
base_agent = Agent(
agent_name="News-Agent-V1",
# system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
llm=model,
max_loops=1,
autosave=True,
dashboard=False,
verbose=True,
dynamic_temperature_enabled=True,
saved_state_path="news_agent.json",
user_name="swarms_corp",
retry_attempts=1,
context_length=200000,
return_step_meta=False,
# output_type="json",
)
# Agent
agent = NewsAgent(
agent_name="news-agent-v1",
agent=base_agent,
newsapi_api_key=os.getenv("NEWSAPI_API_KEY"),
system_prompt=None,
return_json=True,
# start_date="2024-08-01",
# end_date="2024-08-10"
)
# Run the agent
# print(agent.run("multi-agent collaboration"))
print(agent.run_concurrently(["OpenAI", "Anthropic"]))
# print(agent.return_sources("Science"))