Rimuovi la classe Predictor e aggiorna le importazioni in Pipeline e __init__.py
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from app.agents.predictor import PredictorInput, PredictorOutput
|
|
||||||
from app.agents.pipeline import Pipeline, PipelineInputs, PipelineEvent
|
from app.agents.pipeline import Pipeline, PipelineInputs, PipelineEvent
|
||||||
|
from app.agents.core import PipelineInputs, QueryOutputs
|
||||||
|
|
||||||
__all__ = ["PredictorInput", "PredictorOutput", "Pipeline", "PipelineInputs", "PipelineEvent"]
|
__all__ = ["Pipeline", "PipelineInputs", "PipelineEvent", "QueryOutputs"]
|
||||||
|
|||||||
72
src/app/agents/core.py
Normal file
72
src/app/agents/core.py
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
from app.configs import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class QueryOutputs(BaseModel):
|
||||||
|
response: str
|
||||||
|
is_ok: bool
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PipelineInputs:
|
||||||
|
"""
|
||||||
|
Classe necessaria per passare gli input alla Pipeline.
|
||||||
|
Serve per raggruppare i parametri e semplificare l'inizializzazione.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, configs: AppConfig | None = None) -> None:
|
||||||
|
"""
|
||||||
|
Inputs per la Pipeline di agenti.
|
||||||
|
Setta i valori di default se non specificati.
|
||||||
|
"""
|
||||||
|
self.configs = configs if configs else AppConfig()
|
||||||
|
|
||||||
|
agents = self.configs.agents
|
||||||
|
self.team_model = self.configs.get_model_by_name(agents.team_model)
|
||||||
|
self.team_leader_model = self.configs.get_model_by_name(agents.team_leader_model)
|
||||||
|
self.predictor_model = self.configs.get_model_by_name(agents.predictor_model)
|
||||||
|
self.strategy = self.configs.get_strategy_by_name(agents.strategy)
|
||||||
|
self.user_query = ""
|
||||||
|
|
||||||
|
# ======================
|
||||||
|
# Dropdown handlers
|
||||||
|
# ======================
|
||||||
|
def choose_team_leader(self, index: int):
|
||||||
|
"""
|
||||||
|
Sceglie il modello LLM da usare per il Team Leader.
|
||||||
|
"""
|
||||||
|
self.leader_model = self.configs.models.all_models[index]
|
||||||
|
|
||||||
|
def choose_team(self, index: int):
|
||||||
|
"""
|
||||||
|
Sceglie il modello LLM da usare per il Team.
|
||||||
|
"""
|
||||||
|
self.team_model = self.configs.models.all_models[index]
|
||||||
|
|
||||||
|
def choose_strategy(self, index: int):
|
||||||
|
"""
|
||||||
|
Sceglie la strategia da usare per il Team.
|
||||||
|
"""
|
||||||
|
self.strategy = self.configs.strategies[index]
|
||||||
|
|
||||||
|
# ======================
|
||||||
|
# Helpers
|
||||||
|
# ======================
|
||||||
|
def list_models_names(self) -> list[str]:
|
||||||
|
"""
|
||||||
|
Restituisce la lista dei nomi dei modelli disponibili.
|
||||||
|
"""
|
||||||
|
return [model.label for model in self.configs.models.all_models]
|
||||||
|
|
||||||
|
def list_strategies_names(self) -> list[str]:
|
||||||
|
"""
|
||||||
|
Restituisce la lista delle strategie disponibili.
|
||||||
|
"""
|
||||||
|
return [strat.label for strat in self.configs.strategies]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ from agno.workflow.workflow import Workflow
|
|||||||
|
|
||||||
from app.api.tools import *
|
from app.api.tools import *
|
||||||
from app.agents.prompts import *
|
from app.agents.prompts import *
|
||||||
from app.configs import AppConfig
|
from app.agents.core import PipelineInputs
|
||||||
|
|
||||||
logging = logging.getLogger("pipeline")
|
logging = logging.getLogger("pipeline")
|
||||||
|
|
||||||
@@ -28,63 +28,6 @@ class PipelineEvent(str, Enum):
|
|||||||
return event == self.value or (WorkflowRunEvent.step_completed and step_name == self.value)
|
return event == self.value or (WorkflowRunEvent.step_completed and step_name == self.value)
|
||||||
|
|
||||||
|
|
||||||
class PipelineInputs:
|
|
||||||
"""
|
|
||||||
Classe necessaria per passare gli input alla Pipeline.
|
|
||||||
Serve per raggruppare i parametri e semplificare l'inizializzazione.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, configs: AppConfig | None = None) -> None:
|
|
||||||
"""
|
|
||||||
Inputs per la Pipeline di agenti.
|
|
||||||
Setta i valori di default se non specificati.
|
|
||||||
"""
|
|
||||||
self.configs = configs if configs else AppConfig()
|
|
||||||
|
|
||||||
agents = self.configs.agents
|
|
||||||
self.team_model = self.configs.get_model_by_name(agents.team_model)
|
|
||||||
self.team_leader_model = self.configs.get_model_by_name(agents.team_leader_model)
|
|
||||||
self.predictor_model = self.configs.get_model_by_name(agents.predictor_model)
|
|
||||||
self.strategy = self.configs.get_strategy_by_name(agents.strategy)
|
|
||||||
self.user_query = ""
|
|
||||||
|
|
||||||
# ======================
|
|
||||||
# Dropdown handlers
|
|
||||||
# ======================
|
|
||||||
def choose_team_leader(self, index: int):
|
|
||||||
"""
|
|
||||||
Sceglie il modello LLM da usare per il Team Leader.
|
|
||||||
"""
|
|
||||||
self.leader_model = self.configs.models.all_models[index]
|
|
||||||
|
|
||||||
def choose_team(self, index: int):
|
|
||||||
"""
|
|
||||||
Sceglie il modello LLM da usare per il Team.
|
|
||||||
"""
|
|
||||||
self.team_model = self.configs.models.all_models[index]
|
|
||||||
|
|
||||||
def choose_strategy(self, index: int):
|
|
||||||
"""
|
|
||||||
Sceglie la strategia da usare per il Team.
|
|
||||||
"""
|
|
||||||
self.strategy = self.configs.strategies[index]
|
|
||||||
|
|
||||||
# ======================
|
|
||||||
# Helpers
|
|
||||||
# ======================
|
|
||||||
def list_models_names(self) -> list[str]:
|
|
||||||
"""
|
|
||||||
Restituisce la lista dei nomi dei modelli disponibili.
|
|
||||||
"""
|
|
||||||
return [model.label for model in self.configs.models.all_models]
|
|
||||||
|
|
||||||
def list_strategies_names(self) -> list[str]:
|
|
||||||
"""
|
|
||||||
Restituisce la lista delle strategie disponibili.
|
|
||||||
"""
|
|
||||||
return [strat.label for strat in self.configs.strategies]
|
|
||||||
|
|
||||||
|
|
||||||
class Pipeline:
|
class Pipeline:
|
||||||
"""
|
"""
|
||||||
Coordina gli agenti di servizio (Market, News, Social) e il Predictor finale.
|
Coordina gli agenti di servizio (Market, News, Social) e il Predictor finale.
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
from pydantic import BaseModel, Field
|
|
||||||
from app.api.core.markets import ProductInfo
|
|
||||||
|
|
||||||
class PredictorInput(BaseModel):
|
|
||||||
data: list[ProductInfo] = Field(..., description="Market data as a list of ProductInfo")
|
|
||||||
style: str = Field(..., description="Prediction style")
|
|
||||||
sentiment: str = Field(..., description="Aggregated sentiment from news and social analysis")
|
|
||||||
|
|
||||||
class ItemPortfolio(BaseModel):
|
|
||||||
asset: str = Field(..., description="Name of the asset")
|
|
||||||
percentage: float = Field(..., description="Percentage allocation to the asset")
|
|
||||||
motivation: str = Field(..., description="Motivation for the allocation")
|
|
||||||
|
|
||||||
class PredictorOutput(BaseModel):
|
|
||||||
strategy: str = Field(..., description="Concise operational strategy in Italian")
|
|
||||||
portfolio: list[ItemPortfolio] = Field(..., description="List of portfolio items with allocations")
|
|
||||||
Reference in New Issue
Block a user