Skip to content

instrument: LLM provider adapters (M1.B + M8 port)#94

Closed
mmercuri wants to merge 1 commit into
feat/instrument-base-foundationfrom
feat/instrument-llm-providers
Closed

instrument: LLM provider adapters (M1.B + M8 port)#94
mmercuri wants to merge 1 commit into
feat/instrument-base-foundationfrom
feat/instrument-llm-providers

Conversation

@mmercuri

Copy link
Copy Markdown
Contributor

Summary

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
  • Reviewer (m-peko) verifies provider scope rules + token
    accounting

Stacks on

  • feat/instrument-base-foundation (M1.A) — required for the
    BaseAdapter surface this PR consumes.

Linear

LAY-3400 umbrella (M1.B + M8).

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).
@mmercuri mmercuri requested a review from m-peko April 26, 2026 02:19
@mmercuri

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants