File size: 1,601 Bytes
9318644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2e8e45d
9318644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from agno.agent import Agent
from agno.models.groq import Groq
from agno.tools.yfinance import YFinanceTools
from agno.tools.duckduckgo import DuckDuckGoTools
import os
import groq
import pandas as pd
import matplotlib.pyplot as plt
from textblob import TextBlob
import yfinance as yf
from dotenv import load_dotenv

load_dotenv()
groq.api_key = os.getenv("GROQ_API_KEY")

class MultiAgent:
    def __init__(self, finance_agent, web_search_agent):
        self.finance_agent = finance_agent
        self.web_search_agent = web_search_agent
        self.multi_ai_agent = Agent(
            team=[web_search_agent.agent, finance_agent.agent],
            model=Groq(id="deepseek-r1-distill-llama-70b"),
            instructions=[
                "Always include sources",
                "Use tables to display data",
                "Aggregate results from multiple tools"
            ],
            show_tool_calls=True,
            markdown=True,
        )
    
    def get_analyst_recommendations_and_news(self, ticker_symbol):
        response = self.multi_ai_agent.print_response(
            f"Summarize analyst recommendations and share the latest news for {ticker_symbol}. " 
            f"Search for any recent significant developments about this company.",
            stream=False
        )
        return response
    
    def get_market_insights(self, query):
        response = self.multi_ai_agent.print_response(
            f"Provide comprehensive market insights on {query}, including both financial data and news analysis.", 
            stream=False
        )
        return response