refactor(api): shared chat-completion core + report real version - #28
Merged
Conversation
Shared chat core (hfl.api.chat_core.resolve_chat_output): the OpenAI and Ollama chat routes each decided independently whether the model emitted a tool call (engine tool_calls vs parsing markers vs tool_choice="none"). That duplication is where the OpenAI route once drifted behind and lost tool calling. The decision now lives in one tested function returning the canonical tool-call shape; each route only translates to its wire format. Behaviour preserved on both paths. /api/version + the FastAPI app version now report hfl.__version__ instead of a stale hardcoded "0.1.0". Full suite green (3525), coverage 89.5%, ruff (C4/PIE/B904) + type-check clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dos follow-ups del análisis arquitectónico.
1. Núcleo de chat compartido (
hfl.api.chat_core)Las rutas OpenAI y Ollama decidían por separado si el modelo emitió una tool call — la duplicación donde la ruta OpenAI se quedó atrás en su día. Ahora
resolve_chat_output(...) → ChatOutputcentraliza la decisión (forma canónica); cada ruta solo traduce a su wire-format. Comportamiento preservado + 6 tests unitarios.2.
/api/version→hfl.__version__Devolvía
"0.1.0"hardcodeado; ahora reporta la versión real (0.13.0), igual queFastAPI(version=...).Verificación
Suite 3525 passed, cobertura 89.5%;
ruff(incl. C4/PIE/B904) + format + Type Check limpios.🤖 Generated with Claude Code