lplalbert opened a new pull request, #413:
URL: https://github.com/apache/hugegraph-ai/pull/413

   Refs #107 (Tiny Task: fix TODO/FIXME in LLM code)
   
   ## What
   `BaseLLM.agenerate_streaming` was declared `async def ... -> 
AsyncGenerator[str, None]` with
   a docstring-only body, so type checkers resolve the call as
   `Coroutine[..., AsyncGenerator[...]]` — exactly the FIXME in 
`answer_synthesize.py`
   ("Expected type 'AsyncIterable', got 'Coroutine[Any, Any, 
AsyncGenerator[str, None]]'
   instead"). Every implementation (hugegraph-llm-sdk openai/ollama/litellm 
providers) is a
   true async generator function, and every call site uses plain `async for`. 
The declaration
   was the only thing disagreeing with the runtime contract.
   
   ## Changes
   - `BaseLLM.agenerate_streaming`: `async def` → `def`, documented as 
"implement as an async
     generator function; the call result is directly async-iterable and must 
not be awaited".
   - `BaseLLM.num_tokens_from_string`: return annotation `-> str` → `-> int` 
(implementations
     return token counts).
   - Removed the now-stale FIXME in `answer_synthesize.py`.
   - Added `src/tests/models/llms/test_base_llm_contract.py` pinning both 
contracts.
   
   ## Validation (actually run; offline only)
   - red→green (demonstrated via stash): 2 failed on the old declaration → 2 
passed after
   - `SKIP_EXTERNAL_SERVICES=true uv run pytest src/tests/models/ 
src/tests/operators/llm_op/`
     → 231 passed, 4 skipped
   - `ruff format --check` / `ruff check` → clean
   - `ty check` → the FIXME's Coroutine-vs-AsyncIterable diagnostic is gone 
(stash-compared;
     remaining `answer_synthesize` hits are pre-existing `str | None` prompt 
noise)
   - Real-provider verification: none (offline tests only)
   
   Refs #107
   
   🤖 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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to