instrument: LLM provider adapters (M1.B + M8 port)#94
Closed
mmercuri wants to merge 1 commit into
Closed
Conversation
Ports the nine LLM provider adapters from the ateam reference
implementation onto the new layerlens.instrument base layer:
OpenAI, Anthropic, Azure OpenAI, AWS Bedrock, Google Vertex,
Ollama, LiteLLM, Cohere, Mistral
This rolls M1.B (the seven original providers) and M8 (Cohere +
Mistral) into a single PR because they share the same provider _base
helpers (pricing, token counters, provider mixin) and per-PR they would
all be sub-1k LOC.
Scope
-----
- src/layerlens/instrument/adapters/providers/_base/: shared provider
mixin (pricing.py, provider.py, tokens.py)
- src/layerlens/instrument/adapters/providers/{openai,anthropic,
azure_openai,bedrock,google_vertex,ollama,litellm,cohere,mistral}_
adapter.py: per-provider adapter
- tests/instrument/adapters/providers/: unit + live tests for all nine
providers (live tests skip when no API key is set)
- tests/instrument/adapters/test_pydantic_compat.py: shared compat
surface used by every provider
- samples/instrument/{openai,anthropic,cohere,mistral}/: runnable
samples
- docs/adapters/providers-*.md: per-provider integration guide
- pyproject.toml: nine new optional extras
(providers-openai, providers-anthropic, providers-azure-openai,
providers-bedrock, providers-vertex, providers-ollama,
providers-litellm, providers-cohere, providers-mistral) plus the
providers-all umbrella
Blast radius
------------
- Default `pip install layerlens` install set is unchanged. Each
provider's heavy dep (openai, anthropic, boto3, etc.) is gated
behind its own `providers-<name>` extra.
- No changes to existing public API surface.
- Importing layerlens.instrument still does NOT pull in any provider
module (lazy registry lookup).
Test plan
---------
- uv run pytest tests/instrument/adapters/providers/ -x -> 122 passed,
4 skipped (live-only without keys)
- uv run pytest tests/instrument/adapters/test_pydantic_compat.py -x
-> 62 passed
Stacks on
---------
- feat/instrument-base-foundation (M1.A) — required for the BaseAdapter
surface this PR consumes.
LAY-3400 umbrella (M1.B + M8).
Contributor
Author
|
Linear: https://linear.app/layerlens/issue/LAY-3400 (LLM providers slice — 9 providers including Cohere + Mistral [M8]). Stacked on PR #93. Under Apollo M1 epic LAY-3423. |
4 tasks
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
Ports the nine LLM provider adapters from the ateam reference
implementation onto the new
layerlens.instrumentbase layer:OpenAI, Anthropic, Azure OpenAI, AWS Bedrock, Google Vertex,
Ollama, LiteLLM, Cohere, Mistral
This rolls M1.B (the seven original providers) and M8
(Cohere + Mistral) into a single PR because they share the same
provider
_basehelpers (pricing, token counters, provider mixin)and per-PR they would all be sub-1k LOC.
Scope
src/layerlens/instrument/adapters/providers/_base/— sharedprovider mixin (
pricing.py,provider.py,tokens.py)src/layerlens/instrument/adapters/providers/{openai,anthropic,azure_openai,bedrock,google_vertex,ollama,litellm,cohere,mistral}_adapter.py— per-provider adapter
tests/instrument/adapters/providers/— unit + live tests for allnine providers (live tests skip when no API key is set)
tests/instrument/adapters/test_pydantic_compat.py— shared compatsurface used by every provider
samples/instrument/{openai,anthropic,cohere,mistral}/— runnablesamples
docs/adapters/providers-*.md— per-provider integration guidepyproject.toml— nine new optional extras(
providers-openai,providers-anthropic,providers-azure-openai,providers-bedrock,providers-vertex,providers-ollama,providers-litellm,providers-cohere,providers-mistral) plusthe
providers-allumbrellaBlast radius
pip install layerlensinstall set is unchanged. Eachprovider's heavy dep (openai, anthropic, boto3, etc.) is gated
behind its own
providers-<name>extra.layerlens.instrumentstill does NOT pull in anyprovider module (lazy registry lookup).
Test plan
uv run pytest tests/instrument/adapters/providers/ -x—122 passed, 4 skipped (live-only without keys)
uv run pytest tests/instrument/adapters/test_pydantic_compat.py -x— 62 passed
m-peko) verifies provider scope rules + tokenaccounting
Stacks on
feat/instrument-base-foundation(M1.A) — required for theBaseAdaptersurface this PR consumes.Linear
LAY-3400 umbrella (M1.B + M8).