Spaces:
Build error
Build error
Upload 3 files
Browse files- .env +3 -0
- financial_agent.py +56 -0
- requirements.txt +9 -0
.env
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GROQ_API_KEY = "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"
|
| 2 |
+
PHI_API_KEY = "phi-NaPw0k2gpmyUIhyzCvz0tV0uT0xu9WEdbZ229mI2pWs"
|
| 3 |
+
OPENAI_API_KEY = "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"
|
financial_agent.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from phi.agent import Agent
|
| 2 |
+
from phi.model.groq import Groq
|
| 3 |
+
from phi.tools.yfinance import YFinanceTools
|
| 4 |
+
from phi.tools.duckduckgo import DuckDuckGo
|
| 5 |
+
import openai
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
from dotenv import load_dotenv
|
| 9 |
+
load_dotenv()
|
| 10 |
+
groq_api_key=os.getenv("GROQ_API_KEY")
|
| 11 |
+
|
| 12 |
+
# Inside phi/some_module.py
|
| 13 |
+
DEFAULT_MODEL = "groq-llama-3.2-3b-preview" # or similar
|
| 14 |
+
|
| 15 |
+
def get_model(model_id=None):
|
| 16 |
+
if model_id is None:
|
| 17 |
+
model_id = DEFAULT_MODEL
|
| 18 |
+
|
| 19 |
+
if model_id.startswith("openai-"):
|
| 20 |
+
# Use OpenAI
|
| 21 |
+
raise ValueError("OpenAI is disabled. Use a Groq model.") #CHANGED
|
| 22 |
+
elif model_id.startswith("groq-"):
|
| 23 |
+
# Use Groq
|
| 24 |
+
pass # Groq code
|
| 25 |
+
else:
|
| 26 |
+
raise ValueError("Unsupported model")
|
| 27 |
+
#WEB SERACH AGENT
|
| 28 |
+
web_search_agent=Agent(
|
| 29 |
+
name = "Web search agent",
|
| 30 |
+
role = "search the web for the information",
|
| 31 |
+
model = Groq(id="llama-3.2-3b-preview"),
|
| 32 |
+
tools = [DuckDuckGo()],
|
| 33 |
+
instructions = ["Always include sources"],
|
| 34 |
+
show_tools_call = True,
|
| 35 |
+
markdown = True,
|
| 36 |
+
)
|
| 37 |
+
#FINANCIAL AGENT
|
| 38 |
+
finance_agent = Agent(
|
| 39 |
+
name = "Finance AI agent",
|
| 40 |
+
role = "",
|
| 41 |
+
model = Groq(id="llama-3.2-3b-preview"),
|
| 42 |
+
tools =[YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=True,
|
| 43 |
+
company_news = True)
|
| 44 |
+
],
|
| 45 |
+
instructions=["Use tables to display the data"],
|
| 46 |
+
show_tool_calls=True,
|
| 47 |
+
markdown=True,
|
| 48 |
+
)
|
| 49 |
+
multi_ai_agent = Agent(
|
| 50 |
+
team = [web_search_agent,finance_agent],
|
| 51 |
+
instructions=["always include sources","use table to display the data"],
|
| 52 |
+
show_tools_call = True,
|
| 53 |
+
markdown = True,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
multi_ai_agent.print_response("Summarize analyst recommendation and share the latest news for NVDA",stream=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
phidata
|
| 2 |
+
python-dotenv
|
| 3 |
+
yfinance
|
| 4 |
+
packaging
|
| 5 |
+
duckduckgo-search
|
| 6 |
+
fastapi
|
| 7 |
+
uvicorn
|
| 8 |
+
groq
|
| 9 |
+
openai
|