pre merge con phil
This commit is contained in:
14
src/app.py
14
src/app.py
@@ -1,7 +1,7 @@
|
||||
import gradio as gr
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from app.tool import ToolAgent
|
||||
from app.pipeline import Pipeline
|
||||
from agno.utils.log import log_info
|
||||
|
||||
########################################
|
||||
@@ -16,31 +16,31 @@ if __name__ == "__main__":
|
||||
load_dotenv()
|
||||
######################################
|
||||
|
||||
tool_agent = ToolAgent()
|
||||
pipeline = Pipeline()
|
||||
|
||||
with gr.Blocks() as demo:
|
||||
gr.Markdown("# 🤖 Agente di Analisi e Consulenza Crypto")
|
||||
|
||||
with gr.Row():
|
||||
provider = gr.Dropdown(
|
||||
choices=tool_agent.list_providers(),
|
||||
choices=pipeline.list_providers(),
|
||||
type="index",
|
||||
label="Modello da usare"
|
||||
)
|
||||
provider.change(fn=tool_agent.choose_provider, inputs=provider, outputs=None)
|
||||
provider.change(fn=pipeline.choose_provider, inputs=provider, outputs=None)
|
||||
|
||||
style = gr.Dropdown(
|
||||
choices=tool_agent.list_styles(),
|
||||
choices=pipeline.list_styles(),
|
||||
type="index",
|
||||
label="Stile di investimento"
|
||||
)
|
||||
style.change(fn=tool_agent.choose_style, inputs=style, outputs=None)
|
||||
style.change(fn=pipeline.choose_style, inputs=style, outputs=None)
|
||||
|
||||
user_input = gr.Textbox(label="Richiesta utente")
|
||||
output = gr.Textbox(label="Risultato analisi", lines=12)
|
||||
|
||||
analyze_btn = gr.Button("🔎 Analizza")
|
||||
analyze_btn.click(fn=tool_agent.interact, inputs=[user_input], outputs=output)
|
||||
analyze_btn.click(fn=pipeline.interact, inputs=[user_input], outputs=output)
|
||||
|
||||
server, port = ("0.0.0.0", 8000)
|
||||
log_info(f"Starting UPO AppAI on http://{server}:{port}")
|
||||
|
||||
35
src/app/agents/market_agent.py
Normal file
35
src/app/agents/market_agent.py
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
from agno.agent import Agent
|
||||
from src.app.toolkits.market_toolkit import MarketToolkit
|
||||
|
||||
|
||||
class MarketAgent(Agent):
|
||||
"""
|
||||
Wrapper che trasforma MarketToolkit in un Agent compatibile con Team.
|
||||
Espone un metodo run(query) che restituisce dati di mercato.
|
||||
"""
|
||||
|
||||
def __init__(self, currency: str = "USD"):
|
||||
self.toolkit = MarketToolkit()
|
||||
self.currency = currency
|
||||
self.name = "MarketAgent"
|
||||
|
||||
def run(self, query: str) -> str:
|
||||
# Heuristica semplice: se la query cita simboli specifici, recupera quelli
|
||||
symbols = []
|
||||
for token in query.upper().split():
|
||||
if token in ("BTC", "ETH", "XRP", "LTC", "BCH"): # TODO: estendere dinamicamente
|
||||
symbols.append(token)
|
||||
|
||||
if not symbols:
|
||||
symbols = ["BTC", "ETH"] # default
|
||||
|
||||
results = []
|
||||
for sym in symbols:
|
||||
try:
|
||||
price = self.toolkit.get_current_price(sym)
|
||||
results.append(f"{sym}: {price}")
|
||||
except Exception as e:
|
||||
results.append(f"{sym}: errore ({e})")
|
||||
|
||||
return "📊 Dati di mercato:\n" + "\n".join(results)
|
||||
@@ -1,11 +1,11 @@
|
||||
from app.agents.news_agent import NewsAgent
|
||||
from app.agents.social_agent import SocialAgent
|
||||
from app.agents.predictor import PredictorStyle, PredictorInput, PredictorOutput, PREDICTOR_INSTRUCTIONS
|
||||
from app.predictor import PredictorStyle, PredictorInput, PredictorOutput, PREDICTOR_INSTRUCTIONS
|
||||
from app.markets import MarketAPIs
|
||||
from app.models import AppModels
|
||||
from agno.utils.log import log_info
|
||||
|
||||
class ToolAgent:
|
||||
class Pipeline:
|
||||
"""
|
||||
Classe principale che coordina gli agenti per rispondere alle richieste dell'utente.
|
||||
"""
|
||||
0
src/app/toolkits/__init__.py
Normal file
0
src/app/toolkits/__init__.py
Normal file
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from app.agents.predictor import PREDICTOR_INSTRUCTIONS, PredictorInput, PredictorOutput, PredictorStyle
|
||||
from app.predictor import PREDICTOR_INSTRUCTIONS, PredictorInput, PredictorOutput, PredictorStyle
|
||||
from app.markets.base import ProductInfo
|
||||
from app.models import AppModels
|
||||
|
||||
|
||||
Reference in New Issue
Block a user