Skip to content

docs(samples): backfill READMEs for anthropic + cohere + mistral provider samples#160

Closed
mmercuri wants to merge 3 commits into
feat/instrument-llm-providersfrom
docs/sample-readmes-llm-providers-branch
Closed

docs(samples): backfill READMEs for anthropic + cohere + mistral provider samples#160
mmercuri wants to merge 3 commits into
feat/instrument-llm-providersfrom
docs/sample-readmes-llm-providers-branch

Conversation

@mmercuri

Copy link
Copy Markdown
Contributor

Summary

Backfills missing README.md for three provider samples on
feat/instrument-llm-providers (PR #94). Per the sample audit at
A:/tmp/adapter-samples-audit.md, anthropic, cohere, and mistral
all had working main.py files but no README. openai (CLEAN per
audit) is the canonical reference shape that the new READMEs match.

azure_openai and ollama are not present under samples/instrument/
on this branch (they live on feat/instrument-providers-azure-openai
and feat/instrument-providers-ollama respectively, per gh pr list),
so this PR does not touch them.

Per-provider features demonstrated (source-traced)

All claims trace to main.py for each sample and the corresponding
adapter at src/layerlens/instrument/adapters/providers/<name>_adapter.py.

anthropic

  • Wraps client.messages.create and client.messages.stream via
    method substitution in AnthropicAdapter.connect_client.
  • Sample exercises client.messages.create against
    claude-haiku-4-5-20251001.
  • Emits model.invoke, cost.record, and (when tool_use blocks are
    present) tool.call. Anthropic's system kwarg is captured in
    request parameters; response.content is iterated as typed blocks.

cohere

  • Wraps client.chat (v1), client.v2.chat (v2), and client.embed
    via method substitution in CohereAdapter.connect_client.
  • Sample exercises Cohere v1 Chat (client.chat(...)) against
    command-r-plus.
  • Token usage normalized from response.meta.billed_units; pricing
    falls back to pricing_unavailable: True for unknown models.

mistral

  • Wraps client.chat.complete, client.chat.stream, and
    client.embeddings.create via method substitution in
    MistralAdapter.connect_client.
  • Sample exercises client.chat.complete against
    mistral-small-latest using the native mistralai.Mistral
    client (not the OpenAI-compatible REST shim).
  • Captures Mistral-native params: random_seed, response_format,
    safe_prompt, tool_choice.

PR #154 note

Each README carries a NOTE that the sample predates PR #154's
typed-events migration. Verified by reading
src/layerlens/instrument/adapters/providers/_base/provider.py on this
branch — _emit_model_invoke still calls self.emit_dict_event(...),
so dict-shaped events are still the current contract on
feat/instrument-llm-providers. PR #154 is open (not merged) and is
based off a different parent branch.

Test plan

  • Sanity-render each README locally
  • Cross-check every "what this demonstrates" bullet against
    main.py and the adapter source
  • Confirm audit accuracy: anthropic, cohere, mistral each
    have main.py + __init__.py and no prior README.md on this
    branch via git ls-tree -r origin/feat/instrument-llm-providers
  • Reviewer eyeball: provider-specific notes accurate (Cohere v1
    vs v2, Mistral native vs OpenAI-compatible, Claude version pin)

Out of scope

@mmercuri mmercuri requested a review from m-peko May 10, 2026 23:42
@m-peko m-peko closed this May 21, 2026
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