davsclaus opened a new pull request, #30543:
URL: https://github.com/apache/camel/pull/30543

   _Claude Code on behalf of Claus Ibsen_
   
   ## What
   
   [CAMEL-27313](https://issues.apache.org/jira/browse/CAMEL-27313), the third 
part: the Camel TUI AI usage view (**Ctrl+U** in the AI panel) now reads the 
GenAI calls of the integration from the `genai` dev console of #30539 instead 
of the OpenTelemetry span dump:
   - It needs no tracer and no `camel run --observe`.
   - It states the integration's GenAI level instead of guessing it from span 
attributes.
   - It refreshes every 2 seconds while it is open, where before it read the 
spans once when it opened.
   
   The Spans tab and the Ollama tab still read the spans, as they show traces.
   
   **Depends on #30539 at runtime** (the console and the `genai` action of the 
CLI connector). This PR compiles and tests on main.
   
   ## Changes
   
   - **New `GenAiConsoleUsage`** turns the answer of the `genai` action into 
the per-call usage entries and the activity (agent runs, their model calls, 
tool calls, level) that the view already renders:
     - top-level model calls and the model calls inside a run each become an 
entry
     - a model call made by the route of a tool takes the route of its run
     - `/usage reset` still hides the calls made before the reset
   - **`DataRefreshService.refreshGenAiData`** sends the `genai` action. It 
runs at once when the view opens, then at most every 2 seconds while it is 
open, and it is cleared when another integration is selected.
   - **`GenAiSpanUsageExtractor` is removed;** nothing else used it.
   - **New hint:** when the integration's dev console is off, so the console 
records nothing, the view says so (`not recorded: the dev console of the 
integration is off`).
   - **New wording:** the "no data" texts point at 
`camel.aiObservability.level=detailed` instead of `--observe`.
   - `AiPanel.spanRefreshRequested` is now `usageRefreshRequested`, and the 
`AiPanel.java` cap of `SourceSizeTest` goes down by one line (the `SpanEntry` 
import is gone).
   
   ## Tried live
   
   I ran the hidden TUI of this branch against a camel-openai agent with an 
`ai-tool` route on Ollama (`llama3.2`) at level `full`, started with plain 
`camel run` (no `--observe`) and the jars of #30539. The usage view showed:
   
   ```
   Requests: 4 (TUI: 0 / integration: 4)   Total tokens: 732 (in: 676 / out: 56 
/ cached: 404)
   Avg per question: 0.8s (0.8s per request)   AI time: 3.3s
   Agent runs: 2 (model calls: 4 / tool calls: 2)   GenAI level: full
   MODEL                                       REQS   INPUT   CACHED   OUTPUT   
TOTAL   AVG/REQ
   [route:support-agent] llama3.2 (openai)     4      676     404      56       
732     0.8s
   ```
   
   With the view left open, the next runs of the timer showed up by themselves: 
4 agent runs, 8 model calls, 4 tool calls.
   
   ## Tests
   
   - `GenAiConsoleUsageTest` (new) covers:
     - no console
     - the model calls of runs and outside them, with the route of the run
     - the answer as read back from the action file
     - the activity since a reset
   - `AiPanelGenAiUsageTest` runs on console answers. A new case covers an 
integration that does not record.
   - All 2,650 tests of camel-jbang-plugin-tui pass.
   
   Docs: the AI Usage section of `camel-jbang-tui-ai.adoc`.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to