diff --git a/src/app/agents/pipeline.py b/src/app/agents/pipeline.py index d69d7f1..6acaa58 100644 --- a/src/app/agents/pipeline.py +++ b/src/app/agents/pipeline.py @@ -107,7 +107,12 @@ class Pipeline: def condition_query_ok(step_input: StepInput) -> StepOutput: val = step_input.previous_step_content stop = (not val.is_crypto) if isinstance(val, QueryOutputs) else True - return StepOutput(stop=stop) + return StepOutput(stop=stop, content=step_input.input) + + def sanitization_output(step_input: StepInput) -> StepOutput: + val = step_input.previous_step_content + content = f"Query: {step_input.input}\n\nRetrieved data: {self.remove_think(str(val))}" + return StepOutput(content=content) query_check = Step(name=PipelineEvent.QUERY_CHECK, agent=query_check) info_recovery = Step(name=PipelineEvent.INFO_RECOVERY, team=team) @@ -118,6 +123,7 @@ class Pipeline: query_check, condition_query_ok, info_recovery, + sanitization_output, report_generation ]) @@ -150,11 +156,22 @@ class Pipeline: # Restituisce la risposta finale if content and isinstance(content, str): - think_str = "" - think = content.rfind(think_str) - yield content[(think + len(think_str)):] if think != -1 else content + yield cls.remove_think(content) elif content and isinstance(content, QueryOutputs): yield content.response else: logging.error(f"No output from workflow: {content}") yield "Nessun output dal workflow, qualcosa รจ andato storto." + + @classmethod + def remove_think(cls, text: str) -> str: + """ + Rimuove la sezione di pensiero dal testo. + Args: + text: Il testo da pulire. + Returns: + Il testo senza la sezione di pensiero. + """ + think_str = "" + think = text.rfind(think_str) + return text[(think + len(think_str)):] if think != -1 else text diff --git a/src/app/agents/prompts/query_check.md b/src/app/agents/prompts/query_check.md index 83d6293..9896ec8 100644 --- a/src/app/agents/prompts/query_check.md +++ b/src/app/agents/prompts/query_check.md @@ -13,3 +13,8 @@ - IS_CRYPTO: (empty) - NOT_CRYPTO: "I can only analyze cryptocurrency topics." - AMBIGUOUS: "Which cryptocurrency? (e.g., Bitcoin, Ethereum)" + +**RULES:** +- DO NOT ANSWER the query. +- DO NOT PROVIDE ADDITIONAL INFORMATION. +- STOP instantly WHEN YOU CLASSIFY the query. diff --git a/src/app/agents/prompts/report_generation.md b/src/app/agents/prompts/report_generation.md index 1f12b6d..b1e233b 100644 --- a/src/app/agents/prompts/report_generation.md +++ b/src/app/agents/prompts/report_generation.md @@ -8,7 +8,7 @@ - NEVER use placeholders ("N/A", "Data not available") - OMIT section instead - NO example/placeholder data -**INPUT:** Structured report from Team Leader with optional sections: +**INPUT:** You will get the original user query and a structured report with optional sections: - Overall Summary - Market & Price Data (opt) - News & Market Sentiment (opt) diff --git a/src/app/agents/prompts/team_leader.md b/src/app/agents/prompts/team_leader.md index 84d2f68..649fb96 100644 --- a/src/app/agents/prompts/team_leader.md +++ b/src/app/agents/prompts/team_leader.md @@ -79,4 +79,6 @@ Timestamp: {{CURRENT_DATE}} - Never modify MarketAgent prices - Include all timestamps/sources - Retry failed tasks (max 3) -- Only report agent data \ No newline at end of file +- Only report agent data +- DO NOT fabricate or add info +- DO NOT add sources if none provided diff --git a/src/app/agents/prompts/team_market.md b/src/app/agents/prompts/team_market.md index d3777f4..2bbebb5 100644 --- a/src/app/agents/prompts/team_market.md +++ b/src/app/agents/prompts/team_market.md @@ -19,7 +19,7 @@ Historical: `{Asset, Period: {Start, End}, Data Points, Price Range: {Low, High} **MANDATORY RULES:** 1. **Include timestamps** for every price data point 2. **Never fabricate** prices or dates - only report tool outputs -3. **Always specify the data source** (which API provided the data) +3. **Specify the data source** if provided, else state "source unavailable" 4. **Report data completeness**: If user asks for 30 days but got 7, state this explicitly 5. **Current date context**: Remind that data is as of {{CURRENT_DATE}} 6. **Token Optimization**: Be extremely concise to save tokens. Provide all necessary data using as few words as possible. Exceed 100 words ONLY if absolutely necessary to include all required data points.