T045: iris-adapter-llm-openai#44
Open
likith1908 wants to merge 8 commits into
Open
Conversation
…s/LlmParams gap fix - Add packages/iris-adapters/llm-shared/ with OpenAICompatProvider abstract base class and RetryConfig/with_retry exponential backoff helper. Internal workspace package; consumed only by llm-azure-openai, llm-openai, and llm-local. - Add OcrParams and LlmParams to AdaptersSchema in iris-config, closing a gap from WS003/WS004 where both were specified as "consumed from WS002" but never defined. All fields have safe defaults so existing product YAMLs remain valid. - Regenerate docs/schemas/product.schema.json to include the new param blocks. - Register iris_llm_shared in root_packages (pyproject.toml) and update workspace membership tests; exclude it from concrete-adapter contracts since it is a shared helper, not an independent adapter.
…C base Address two required changes and one optional nit from Anmol's review on PR #41. - retry.py: with_retry now returns (result, retry_count) where retry_count is the number of retries performed (0 means first attempt succeeded) - openai_compat.py: unpack tuple from with_retry and set llm.retry_count on the OTEL span; inherit abc.ABC so missing abstract methods fail at instantiation - pyproject.toml: add iris_adapter_llm_shared to [tool.coverage.run] source - tests/test_unit.py: update with_retry tests to unpack and assert retry_count; add two span-attribute tests (retry_count 0 and 1) - tests/conftest.py: span_exporter fixture that attaches to the active TracerProvider
Implements AzureOpenAIProvider via OpenAICompatProvider base class. Two-deployment routing (chat/extract) via ContextVar; api-key auth; api-version configurable via IRIS_LLM_AZURE_API_VERSION env var. 23 unit tests + 3 live tests (gated on IRIS_LLM_LIVE_AZURE=1).
…, fix _run() loop close
… in error message
Implements OpenAIProvider via OpenAICompatProvider base class. Bearer auth; single api.openai.com/v1 endpoint; model routing via model_hint (extraction vs chat). 23 unit tests covering C-LLM-001..010; 3 live tests gated on IRIS_LLM_LIVE_OPENAI=1 (untested pending API key).
ed0e32a to
c14d589
Compare
12 tasks
Merged
12 tasks
anmolg1997
approved these changes
Jun 25, 2026
anmolg1997
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed on the stack (own diff against T044-llm-azure-openai). Same verdict as the Azure adapter: a clean minimal subclass that proves out the base class.
- Constant endpoint https://api.openai.com/v1/chat/completions and Authorization: Bearer header. Correct.
- _model_for_hint routes extraction vs chat to the two configured models; everything else inherited from the tested base.
- from_env / _require_env mirror the Azure adapter, no credential leak.
Coverage 94% with the single miss being the _require_env raise, consistent with the others. Error mapping, retry, and structured output are all inherited from llm-shared and already covered there, so there is nothing adapter-specific left untested here.
Stacked on #43, so it rebases up the chain as the zipper proceeds. Approving the content; will re-confirm on rebase onto main.
f1f0d45 to
34184cf
Compare
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
Implements T045 - the
iris-adapter-llm-openaiworkspace package providing the OpenAI LLM adapter. ExtendsOpenAICompatProviderfrom T043 (iris_adapter_llm_shared). Stacked on #43.packages/iris-adapters/llm-openai/src/iris_adapter_llm_openai/client.py:OpenAIProviderimplementingid,_base_url(),_auth_headers(), and_model_for_hint(). Single endpointhttps://api.openai.com/v1/chat/completions. Auth viaAuthorization: Bearerheader. Two model slots (chat + extract) selected bymodel_hintfield, no ContextVar needed (model goes in request body, not URL).packages/iris-adapters/llm-openai/tests/test_unit.py: 23 unit tests covering all C-LLM-001..010 contract points using a mockhttpx.AsyncClient.packages/iris-adapters/llm-openai/tests/test_live.py: 3 live tests gated onIRIS_LLM_LIVE_OPENAI=1, verified against real OpenAI endpoint.pyproject.toml:iris_adapter_llm_openairegistered in importlinter root_packages, layers, independence, forbidden, mypy strict overrides, and coverage source.tests/001-project-scaffold/: workspace, import-linter, and mypy scaffold tests updated for the renamed module..env.example:IRIS_LLM_OPENAI_API_KEYand optional model env vars documented.Task reference
T045004-llm-adapter-setAcceptance criteria
T045
OpenAIProvider.from_env()constructs from env vars; raisesRuntimeErrorifIRIS_LLM_OPENAI_API_KEYis missinghttps://api.openai.com/v1/chat/completionsAuthorization: Bearer <key>header, noapi-keyheadermodel_hint="extraction"routes tomodel_extract; all other hints route tomodel_chatIRIS_LLM_LIVE_OPENAI=1): 3/3 passedPR checklist
tasks.mdentry is satisfied.docs-ciworkflow passes (markdown lint + tasks structural check).Rebase note
This PR is stacked on #43. Once #43 merges, rebase onto
mainbefore merging this one.Notes for the reviewer
Module rename: Scaffold was
iris_llm_openai; renamed toiris_adapter_llm_openaito match theiris_adapter_*naming convention.No ContextVar: Unlike Azure, OpenAI sends the model in the request body JSON field, so no per-request routing state is needed.
_model_for_hint()simply returns the model string and_base_url()always returns the same constant URL.Live tests: Verified against real OpenAI endpoint with
gpt-4o-mini. All 3 tests passed.