fix(eos_ai): LLMClient URL normalization, env var support, and unit test suite - #127
Open
iamsayanmandal wants to merge 1 commit into
Conversation
…h header - Add _normalize_openai_url() helper: prevents /v1/v1/chat/completions when base_url already contains /v1 (e.g. from OPENAI_BASE_URL env var) - Add _ensure_scheme() helper: prepends http:// to bare Ollama hosts like '192.168.1.50:11434' so urllib does not choke - Add _build_headers() method: omits Authorization header when api_key is empty, fixing compatibility with local servers (vLLM, llama.cpp) that reject a stray 'Bearer ' header - Add _parse_openai_response() method: returns success=False with a clear error message when choices is empty, instead of silently succeeding with empty text - Honour OLLAMA_HOST, OLLAMA_MODEL, OPENAI_BASE_URL, OPENAI_MODEL, EOS_LLM_URL, EOS_LLM_API_KEY, EOS_LLM_MODEL environment variables so the client is configurable without source changes - LLMClient.auto() picks up OLLAMA_MODEL and OPENAI_MODEL from env
iamsayanmandal
requested review from
hshanmug12 and
srpatcha
as code owners
September 10, 2026 21:00
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.
Summary
Three related fixes that make the AI/LLM subsystem production-ready and restore a green CI gate on master.
1. LLMClient URL bugs —
_call_openai_compatappended/v1/chat/completionsunconditionally, causing/v1/v1/chat/completionswhenOPENAI_BASE_URLalready contains/v1. Bare Ollama hosts withouthttp://crashed urllib. Emptyapi_keysent a strayAuthorization: Bearerheader that local servers (vLLM, llama.cpp) reject. Emptychoiceslist returnedsuccess=Truesilently.2. LLMClient has zero unit tests — added the first-ever test suite (35 tests, fully offline with mocks).
3. CI lint gate broken —
ruff check .failed on 4 findings before running any test. Also added missingPackageRecipe.to_dict()which causedebuild update-indexto crash.Type of Change
Changes
_normalize_openai_url(): strips trailing slash, detects existing/v1, appends correct suffix — prevents/v1/v1/chat/completionsdouble-path_ensure_scheme(): prependshttp://to bare Ollama hosts like192.168.1.50:11434_build_headers(): omitsAuthorizationheader whenapi_keyis empty_parse_openai_response(): returnssuccess=Falsewith clear message whenchoicesis emptyOLLAMA_HOST,OLLAMA_MODEL,OPENAI_BASE_URL,OPENAI_MODEL,EOS_LLM_*env varstests/unit/test_llm_client.py— 35 tests across 9 test classes, zero network callsPackageRecipe.to_dict()using external YAML key names (package,build) for round-trip correctnessimport shutilintest_build_dir_resolution.pytest_ci_gate.pytest_package_recipe.py# type: ignore[attr-defined]→[arg-type]inplugins/__init__.pyTesting
Pre-Submission Checklist
Related Issues
Addresses the same LLM URL issues noted in PR #120 (never merged).
Addresses the same lint gate issue noted in PR #122 (never merged).
Addresses the same
to_dict()gap as PRs #119 and #124 (never merged).Consolidated as a single coherent fix to keep review surface small.
Screenshots / Logs
Additional Notes
All 35 new
test_llm_clienttests run fully offline — no Ollama, no API keys needed in CI.