Update chat interface #70

Merged
trojanhorse47 merged 9 commits from 47-update-chat-interface into main 2025-10-31 14:24:39 +01:00
trojanhorse47 commented 2025-10-30 18:03:56 +01:00 (Migrated from github.com)
No description provided.
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-10-30 20:22:23 +01:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR implements asynchronous streaming support for the chat interface to provide real-time progress updates to users during pipeline execution. The changes enable the application to display step-by-step status messages as the AI agents work through market data retrieval, news gathering, and report generation.

Key changes:

  • Refactored pipeline execution to support async streaming with intermediate status updates
  • Added action registry system to map tool calls to user-friendly messages
  • Updated chat interface to handle async streaming responses
  • Improved code style consistency in assertion statements

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/app/interface/chat.py Converted gradio_respond to async streaming function and added fill_height/fill_width parameters to Gradio interface
src/app/agents/pipeline.py Added interact_stream and run_stream methods to yield intermediate status updates and refactored run to consume the stream
src/app/agents/action_registry.py New file implementing global registry for mapping tool names to user-friendly descriptions
src/app/api/tools/market_tool.py Registered user-friendly action descriptions for market tool methods
src/app/api/tools/news_tool.py Registered user-friendly action descriptions for news tool methods
src/app/api/tools/social_tool.py Registered user-friendly action descriptions for social tool methods
src/app/agents/core.py Refactored assertion conditions to use chained comparison style and enabled stream_intermediate_steps for Team
src/app/agents/plan_memory_tool.py Added blank line for code formatting consistency
src/app/api/tools/symbols_tool.py Added blank line for code formatting consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull Request Overview This PR implements asynchronous streaming support for the chat interface to provide real-time progress updates to users during pipeline execution. The changes enable the application to display step-by-step status messages as the AI agents work through market data retrieval, news gathering, and report generation. Key changes: - Refactored pipeline execution to support async streaming with intermediate status updates - Added action registry system to map tool calls to user-friendly messages - Updated chat interface to handle async streaming responses - Improved code style consistency in assertion statements ### Reviewed Changes Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | src/app/interface/chat.py | Converted `gradio_respond` to async streaming function and added `fill_height`/`fill_width` parameters to Gradio interface | | src/app/agents/pipeline.py | Added `interact_stream` and `run_stream` methods to yield intermediate status updates and refactored `run` to consume the stream | | src/app/agents/action_registry.py | New file implementing global registry for mapping tool names to user-friendly descriptions | | src/app/api/tools/market_tool.py | Registered user-friendly action descriptions for market tool methods | | src/app/api/tools/news_tool.py | Registered user-friendly action descriptions for news tool methods | | src/app/api/tools/social_tool.py | Registered user-friendly action descriptions for social tool methods | | src/app/agents/core.py | Refactored assertion conditions to use chained comparison style and enabled `stream_intermediate_steps` for Team | | src/app/agents/plan_memory_tool.py | Added blank line for code formatting consistency | | src/app/api/tools/symbols_tool.py | Added blank line for code formatting consistency | </details> --- 💡 <a href="/Berack96/upo-appAI/new/main/.github?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@@ -86,2 +92,3 @@
async for item in self.run_stream(workflow, query, events=events):
yield item
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-30 20:22:23 +01:00

[nitpick] The comment describes the function as 'ESEGUE (yield)' which is inconsistent with the style used in similar comments. The word 'ESEGUE' (executes) appears to be emphasized but doesn't align well with the yield concept. Consider clarifying that it 'yields' or 'streams' intermediate results and the final response.

        Versione asincrona in streaming che restituisce (yield) gli aggiornamenti di stato intermedi
        e il risultato finale della pipeline.
[nitpick] The comment describes the function as 'ESEGUE (yield)' which is inconsistent with the style used in similar comments. The word 'ESEGUE' (executes) appears to be emphasized but doesn't align well with the yield concept. Consider clarifying that it 'yields' or 'streams' intermediate results and the final response. ```suggestion Versione asincrona in streaming che restituisce (yield) gli aggiornamenti di stato intermedi e il risultato finale della pipeline. ```
@@ -132,2 +140,4 @@
# Chiama i listeners (se presenti) per ogni evento
for app_event, listener in events:
if app_event.check_event(event.event, step_name):
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-30 20:22:22 +01:00

The ellipsis '...' at the end of the string is inconsistent with other yield statements. Line 196 has three dots while lines 181, 183, 185, and 194 use '...' (ellipsis character). Consider using the ellipsis character for consistency.

                        yield f"Sto usando uno strumento sconosciuto…"
The ellipsis '...' at the end of the string is inconsistent with other yield statements. Line 196 has three dots while lines 181, 183, 185, and 194 use '...' (ellipsis character). Consider using the ellipsis character for consistency. ```suggestion yield f"Sto usando uno strumento sconosciuto…" ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-30 20:22:23 +01:00

[nitpick] The default error message 'Errore durante l'esecuzione del workflow.' may not be reached in practice since the stream should always yield at least one item (the error message from line 213). This initialization could be misleading. Consider using a more descriptive default or documenting why this fallback exists.

        # Fallback: if the workflow yields no results, return a descriptive error.
        final_result = "[Pipeline Error] Nessun risultato prodotto dal workflow. (Fallback: run_stream non ha generato output)"
[nitpick] The default error message 'Errore durante l'esecuzione del workflow.' may not be reached in practice since the stream should always yield at least one item (the error message from line 213). This initialization could be misleading. Consider using a more descriptive default or documenting why this fallback exists. ```suggestion # Fallback: if the workflow yields no results, return a descriptive error. final_result = "[Pipeline Error] Nessun risultato prodotto dal workflow. (Fallback: run_stream non ha generato output)" ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-30 20:22:23 +01:00

All chunks (including intermediate status messages) are yielded to Gradio, but only the final response is saved to history. This could be confusing because intermediate status updates like '🔍 Sto controllando la tua richiesta...' will be displayed but not the actual final answer if the stream doesn't clearly differentiate between status updates and the final response. Consider adding logic to distinguish between status messages and the final answer, or document this behavior clearly.

All chunks (including intermediate status messages) are yielded to Gradio, but only the final response is saved to history. This could be confusing because intermediate status updates like '🔍 Sto controllando la tua richiesta...' will be displayed but not the actual final answer if the stream doesn't clearly differentiate between status updates and the final response. Consider adding logic to distinguish between status messages and the final answer, or document this behavior clearly.
Berack96 (Migrated from github.com) requested changes 2025-10-30 22:53:09 +01:00
Berack96 (Migrated from github.com) left a comment

Ho controllato il codice e ho fatto un commit modificando alcune cose della pipeline in modo che vengano usati gli eventi passati in input invece che scriverli dentro staticamente.

Il resto mi sembra giusto tranne per alcune cose:

  1. Differenza di risposte tra Gradio e Telegram: per telegram viene usata la classe RunMessage per mostrare il progresso tramite checklist e tool usati, mentre per Gradio viene solo aggiornato il messaggio (mostrando in quel momento cosa stà facendo l'app) senza checklist.
  2. Posizione errata del Registro: la posizione più corretta è core.py. Inoltre si può migliorare mettendola come decorator, in questo modo è più semplice capire quali tool sono tracciati e quali no.

Se è un comportamento desiderato allora si può risolvere i due commenti e approverò la PR

Ho controllato il codice e ho fatto un commit modificando alcune cose della pipeline in modo che vengano usati gli eventi passati in input invece che scriverli dentro staticamente. Il resto mi sembra giusto tranne per alcune cose: 1. **Differenza di risposte tra Gradio e Telegram**: per telegram viene usata la classe RunMessage per mostrare il progresso tramite checklist e tool usati, mentre per Gradio viene solo aggiornato il messaggio (mostrando in quel momento cosa stà facendo l'app) senza checklist. 2. **Posizione errata del Registro**: la posizione più corretta è core.py. Inoltre si può migliorare mettendola come decorator, in questo modo è più semplice capire quali tool sono tracciati e quali no. Se è un comportamento desiderato allora si può risolvere i due commenti e approverò la PR
@@ -0,0 +2,4 @@
# Registro centrale popolato da tutti i file Toolkit all'avvio.
ACTION_DESCRIPTIONS: dict[str, str] = {}
Berack96 (Migrated from github.com) commented 2025-10-30 22:33:07 +01:00

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

@register_user_interaction("Recupero informazioni del mercato")
def funzione_di_ricerca():
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 ```python @register_user_interaction("Recupero informazioni del mercato") def funzione_di_ricerca(): ```
Berack96 (Migrated from github.com) commented 2025-10-30 21:28:33 +01:00

Per mostrare i messagi si può usare la classe RunMessage in modo da uniformare le risposte sia per Telegram che per Gradio

Per mostrare i messagi si può usare la classe RunMessage in modo da uniformare le risposte sia per Telegram che per Gradio
trojanhorse47 (Migrated from github.com) reviewed 2025-10-30 23:18:12 +01:00
@@ -0,0 +2,4 @@
# Registro centrale popolato da tutti i file Toolkit all'avvio.
ACTION_DESCRIPTIONS: dict[str, str] = {}
trojanhorse47 (Migrated from github.com) commented 2025-10-30 23:18:12 +01:00

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.

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.
trojanhorse47 (Migrated from github.com) reviewed 2025-10-30 23:20:28 +01:00
trojanhorse47 (Migrated from github.com) commented 2025-10-30 23:20:28 +01:00

Volendo sì, ma mi piaceva l'idea di aggiornare in tempo reale in stile chatGPT/Gemini più che la checklist che fa telegram

Volendo sì, ma mi piaceva l'idea di aggiornare in tempo reale in stile chatGPT/Gemini più che la checklist che fa telegram
Berack96 (Migrated from github.com) reviewed 2025-10-30 23:25:34 +01:00
Berack96 (Migrated from github.com) commented 2025-10-30 23:25:34 +01:00

Beh infatti se l'idea principale era fare proprio questo va bene, ho messo il commento solo per avere la certezza

Beh infatti se l'idea principale era fare proprio questo va bene, ho messo il commento solo per avere la certezza
trojanhorse47 (Migrated from github.com) reviewed 2025-10-30 23:33:53 +01:00
@@ -0,0 +2,4 @@
# Registro centrale popolato da tutti i file Toolkit all'avvio.
ACTION_DESCRIPTIONS: dict[str, str] = {}
trojanhorse47 (Migrated from github.com) commented 2025-10-30 23:33:53 +01:00

Non chiudere ancora la pull request che domani provo a fare un decoratore custom così evitiamo quel registro che ho improvvisato

Non chiudere ancora la pull request che domani provo a fare un decoratore custom così evitiamo quel registro che ho improvvisato
Berack96 (Migrated from github.com) reviewed 2025-10-30 23:37:55 +01:00
Berack96 commented 2025-10-30 23:39:48 +01:00 (Migrated from github.com)

Ho approvato la PR, se ti vanno bene le due cose dei commenti, marcale come risolte e verrà fatta la merge in automatico.
Se vuoi ancora fare delle modifiche, per esempio il decorator, lasciale li finché non hai fatto

Ho approvato la PR, se ti vanno bene le due cose dei commenti, marcale come risolte e verrà fatta la merge in automatico. Se vuoi ancora fare delle modifiche, per esempio il decorator, lasciale li finché non hai fatto
Berack96 (Migrated from github.com) approved these changes 2025-10-31 14:24:38 +01:00
Sign in to join this conversation.