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

   ## Summary
   
   `camel explain` produced no output when using an OpenAI-compatible or Gemini 
provider. The explanation was silently dropped.
   
   ## Root Cause
   
   `Explain.stream` defaults to `true`. `handleExplanationResult()` (line 250) 
only printed the returned text when `!stream`. Meanwhile `generateOpenAi()` and 
`generateGemini()` in `LlmClient` always issue a single blocking request and 
return the full response as a `String` — they never stream tokens to stdout. So 
when `stream=true` (the default), those providers correctly returned the 
answer, but `handleExplanationResult()` skipped printing it.
   
   Ollama and Anthropic were unaffected because they actually write tokens 
inline when `stream=true`.
   
   ## Fix
   
   `LlmClient.generate()` now returns a `GenerateResponse(text, streamed)` 
record. The `streamed` flag is `true` only when the provider wrote tokens to 
stdout incrementally (Ollama and Anthropic with `stream=true`); it is `false` 
for OpenAI-compatible and Gemini providers. `Explain.handleExplanationResult()` 
checks `!response.streamed()` instead of `!stream`, so it prints the answer 
regardless of the `--stream` flag when the provider did not actually stream.
   
   `Overview` (the only other caller of `generate()`) is updated to call 
`.text()` on the new return type.
   
   ## Test
   
   A new `ExplainTest.anExplanationWithOpenAiIsDisplayed()` test covers the 
broken path end-to-end against a fake HTTP server with `--api-type=openai`.
   
   ## Checklist
   
   - [x] Tests added / updated
   - [x] Code formatted (`formatter:format impsort:sort`)
   
   _Hermès on behalf of gnodet_


-- 
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