From 3e6baf25f04e1d49b0c10b00aee798ebca86a90f Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Tue, 21 Jan 2025 18:57:38 -0500 Subject: [PATCH] [DOCS][Yahoo finance] --- docs/mkdocs.yml | 1 + docs/swarms/examples/yahoo_finance.md | 42 +++++++++++++++++++++++++++ financial_news_agent.py | 30 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 docs/swarms/examples/yahoo_finance.md create mode 100644 financial_news_agent.py diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index f33f78e7..1fdf39b7 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -211,6 +211,7 @@ nav: - Swarms Tools: - Agent with HTX + CoinGecko: "swarms/examples/swarms_tools_htx.md" - Agent with HTX + CoinGecko Function Calling: "swarms/examples/swarms_tools_htx_gecko.md" + - Agent with Yahoo Finance: "swarms/examples/yahoo_finance.md" - Swarm Models: - Overview: "swarms/models/index.md" # - Models Available: "swarms/models/index.md" diff --git a/docs/swarms/examples/yahoo_finance.md b/docs/swarms/examples/yahoo_finance.md new file mode 100644 index 00000000..7b6e9706 --- /dev/null +++ b/docs/swarms/examples/yahoo_finance.md @@ -0,0 +1,42 @@ +# Swarms Tools Example with Yahoo Finance + +- `pip3 install swarms swarms-tools` +- Add `OPENAI_API_KEY` to your `.env` file +- Run `yahoo_finance_agent.py` +- Agent will make a function call to the desired tool +- The tool will be executed and the result will be returned to the agent +- The agent will then analyze the result and return the final output + + +```python +from swarms import Agent +from swarms.prompts.finance_agent_sys_prompt import ( + FINANCIAL_AGENT_SYS_PROMPT, +) +from swarms_tools import ( + yahoo_finance_api, +) + +# Initialize the agent +agent = Agent( + agent_name="Financial-Analysis-Agent", + agent_description="Personal finance advisor agent", + system_prompt=FINANCIAL_AGENT_SYS_PROMPT, + max_loops=1, + model_name="gpt-4o", + dynamic_temperature_enabled=True, + user_name="swarms_corp", + retry_attempts=3, + context_length=8192, + return_step_meta=False, + output_type="str", # "json", "dict", "csv" OR "string" "yaml" and + auto_generate_prompt=False, # Auto generate prompt for the agent based on name, description, and system prompt, task + max_tokens=4000, # max output tokens + saved_state_path="agent_00.json", + interactive=False, + tools=[yahoo_finance_api], +) + +agent.run("Analyze the latest metrics for nvidia") +# Less than 30 lines of code.... +``` \ No newline at end of file diff --git a/financial_news_agent.py b/financial_news_agent.py new file mode 100644 index 00000000..e8d30eff --- /dev/null +++ b/financial_news_agent.py @@ -0,0 +1,30 @@ +from swarms import Agent +from swarms.prompts.finance_agent_sys_prompt import ( + FINANCIAL_AGENT_SYS_PROMPT, +) +from swarms_tools import ( + yahoo_finance_api, +) + +# Initialize the agent +agent = Agent( + agent_name="Financial-Analysis-Agent", + agent_description="Personal finance advisor agent", + system_prompt=FINANCIAL_AGENT_SYS_PROMPT, + max_loops=1, + model_name="gpt-4o", + dynamic_temperature_enabled=True, + user_name="swarms_corp", + retry_attempts=3, + context_length=8192, + return_step_meta=False, + output_type="str", # "json", "dict", "csv" OR "string" "yaml" and + auto_generate_prompt=False, # Auto generate prompt for the agent based on name, description, and system prompt, task + max_tokens=4000, # max output tokens + saved_state_path="agent_00.json", + interactive=False, + tools=[yahoo_finance_api], +) + +agent.run("Analyze the latest metrics for nvidia") +# Less than 30 lines of code.... \ No newline at end of file