Update chat interface #70
@@ -1,3 +1,6 @@
|
|||||||
|
from typing import Any, Callable
|
||||||
|
|
||||||
|
|
||||||
# Registro centrale popolato da tutti i file Toolkit all'avvio.
|
# Registro centrale popolato da tutti i file Toolkit all'avvio.
|
||||||
ACTION_DESCRIPTIONS: dict[str, str] = {}
|
ACTION_DESCRIPTIONS: dict[str, str] = {}
|
||||||
|
|
|||||||
|
|
||||||
@@ -9,7 +12,7 @@ def get_user_friendly_action(tool_name: str) -> str:
|
|||||||
# Usa il dizionario ACTION_DESCRIPTIONS importato
|
# Usa il dizionario ACTION_DESCRIPTIONS importato
|
||||||
return ACTION_DESCRIPTIONS.get(tool_name, f"⚙️ Eseguo l'operazione: {tool_name}...")
|
return ACTION_DESCRIPTIONS.get(tool_name, f"⚙️ Eseguo l'operazione: {tool_name}...")
|
||||||
|
|
||||||
def friendly_action(description: str):
|
def friendly_action(description: str) -> Callable[..., Any]:
|
||||||
"""
|
"""
|
||||||
Decoratore che registra automaticamente la descrizione "user-friendly"
|
Decoratore che registra automaticamente la descrizione "user-friendly"
|
||||||
di un metodo nel registro globale.
|
di un metodo nel registro globale.
|
||||||
@@ -20,7 +23,7 @@ def friendly_action(description: str):
|
|||||||
Restituisce la funzione originale non modificata.
|
Restituisce la funzione originale non modificata.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
|
||||||
# Registra l'azione
|
# Registra l'azione
|
||||||
tool_name = func.__name__
|
tool_name = func.__name__
|
||||||
if tool_name in ACTION_DESCRIPTIONS:
|
if tool_name in ACTION_DESCRIPTIONS:
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ class PipelineInputs:
|
|||||||
name="CryptoAnalysisTeam",
|
name="CryptoAnalysisTeam",
|
||||||
tools=[ReasoningTools(), PlanMemoryTool(), CryptoSymbolsTools()],
|
tools=[ReasoningTools(), PlanMemoryTool(), CryptoSymbolsTools()],
|
||||||
members=[market_agent, news_agent, social_agent],
|
members=[market_agent, news_agent, social_agent],
|
||||||
stream_intermediate_steps=True
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_agent_query_checker(self) -> Agent:
|
def get_agent_query_checker(self) -> Agent:
|
||||||
@@ -152,11 +151,11 @@ class RunMessage:
|
|||||||
prefix (str, optional): Prefisso del messaggio. Defaults to ""
|
prefix (str, optional): Prefisso del messaggio. Defaults to ""
|
||||||
suffix (str, optional): Suffisso del messaggio. Defaults to ""
|
suffix (str, optional): Suffisso del messaggio. Defaults to ""
|
||||||
"""
|
"""
|
||||||
self.current = None
|
|
||||||
self.steps_total = None
|
|
||||||
self.base_message = f"Running configurations: \n{prefix}{inputs}{suffix}\n\n"
|
self.base_message = f"Running configurations: \n{prefix}{inputs}{suffix}\n\n"
|
||||||
self.emojis = ['🔳', '➡️', '✅']
|
self.emojis = ['🔳', '➡️', '✅']
|
||||||
self.placeholder = '<<<>>>'
|
self.placeholder = '<<<>>>'
|
||||||
|
self.current = 0
|
||||||
|
self.steps_total: list[tuple[str, int]] = []
|
||||||
self.set_steps(["Query Check", "Info Recovery", "Report Generation"])
|
self.set_steps(["Query Check", "Info Recovery", "Report Generation"])
|
||||||
|
|
||||||
def set_steps(self, steps: list[str]) -> 'RunMessage':
|
def set_steps(self, steps: list[str]) -> 'RunMessage':
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ class Pipeline:
|
|||||||
# Step 2: Crea gli steps
|
# Step 2: Crea gli steps
|
||||||
def condition_query_ok(step_input: StepInput) -> StepOutput:
|
def condition_query_ok(step_input: StepInput) -> StepOutput:
|
||||||
val = step_input.previous_step_content
|
val = step_input.previous_step_content
|
||||||
return StepOutput(stop=not val.is_crypto) if isinstance(val, QueryOutputs) else StepOutput(stop=True)
|
stop = (not val.is_crypto) if isinstance(val, QueryOutputs) else True
|
||||||
|
return StepOutput(stop=stop)
|
||||||
|
|
||||||
query_check = Step(name=PipelineEvent.QUERY_CHECK, agent=query_check)
|
query_check = Step(name=PipelineEvent.QUERY_CHECK, agent=query_check)
|
||||||
info_recovery = Step(name=PipelineEvent.INFO_RECOVERY, team=team)
|
info_recovery = Step(name=PipelineEvent.INFO_RECOVERY, team=team)
|
||||||
|
|||||||
Reference in New Issue
Block a user
Sarebbe più corretto metterlo dentro il file core.py dato che ci sono tutte le interazioni core con la pipeline.
O ancor meglio che sia un decorator da mettere su ogni funzione di cui si vuole avere una descrizione e che aggiorna il registro, che sia dentro la classe RunMessage o che sia libero
Stavo tentando di farne un decorator, ma sfruttando il decorator @tool di agno che però sminchiava il Toolkit. Alla fine ho fatto questo accrocchio che non mi soddisfa in pieno, ma non avevo più tempo e funziona.
Non chiudere ancora la pull request che domani provo a fare un decoratore custom così evitiamo quel registro che ho improvvisato