|
|
!pip install phi |
|
|
import os |
|
|
import streamlit as st |
|
|
from dotenv import load_dotenv |
|
|
from phi.agent import Agent |
|
|
from phi.model.groq import Groq |
|
|
from phi.tools.duckduckgo import DuckDuckGo |
|
|
from phi.tools.yfinance import YFinanceTools |
|
|
|
|
|
|
|
|
load_dotenv() |
|
|
|
|
|
|
|
|
deepseek_api_key = os.getenv("GROQ_DEEPSEEK_API_KEY") |
|
|
qwen_api_key = os.getenv("GROQ_QWEN_API_KEY") |
|
|
|
|
|
|
|
|
st.set_page_config(page_title="AI Agent Hub", layout="wide") |
|
|
st.title("🤖 AI Agent Hub") |
|
|
|
|
|
|
|
|
if not deepseek_api_key or not qwen_api_key: |
|
|
st.error("Missing API keys. Ensure they are set in the Hugging Face Secrets.") |
|
|
st.stop() |
|
|
|
|
|
|
|
|
web_agent = Agent( |
|
|
name="Web Agent", |
|
|
model=Groq(id="qwen-2.5-coder-32b", api_key=qwen_api_key), |
|
|
tools=[DuckDuckGo()], |
|
|
instructions=["Always include sources"], |
|
|
show_tool_calls=True, |
|
|
markdown=True, |
|
|
) |
|
|
|
|
|
|
|
|
finance_agent = Agent( |
|
|
name="Finance Agent", |
|
|
role="Get financial data", |
|
|
model=Groq(id="qwen-2.5-coder-32b", api_key=qwen_api_key), |
|
|
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)], |
|
|
instructions=["Use tables to display data"], |
|
|
show_tool_calls=True, |
|
|
markdown=True, |
|
|
) |
|
|
|
|
|
|
|
|
agent_team = Agent( |
|
|
model=Groq(id="deepseek-r1-distill-llama-70b", api_key=deepseek_api_key), |
|
|
team=[web_agent, finance_agent], |
|
|
instructions=["Always include sources", "Use tables to display data"], |
|
|
show_tool_calls=True, |
|
|
markdown=True, |
|
|
) |
|
|
|
|
|
|
|
|
query = st.text_input("Enter your query:") |
|
|
|
|
|
if query: |
|
|
with st.spinner("Fetching results..."): |
|
|
try: |
|
|
response = agent_team.respond(query) |
|
|
st.write(response) |
|
|
except Exception as e: |
|
|
st.error(f"Error: {str(e)}") |
|
|
|