Skip to content

chore: Modernize server-ai package and provider READMEs to current SDK#184

Merged
jsonbailey merged 3 commits into
mainfrom
jb/aic-2383/modernize-server-ai-readmes
May 14, 2026
Merged

chore: Modernize server-ai package and provider READMEs to current SDK#184
jsonbailey merged 3 commits into
mainfrom
jb/aic-2383/modernize-server-ai-readmes

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

@jsonbailey jsonbailey commented May 14, 2026

Summary

  • Modernize three READMEs (packages/sdk/server-ai/README.md, packages/ai-providers/server-ai-openai/README.md, packages/ai-providers/server-ai-langchain/README.md) to current Python AI SDK 0.19+ APIs
  • Replace nonexistent from ldai import init / init(ld_client) (in both provider READMEs) with from ldai import LDAIClient / LDAIClient(ld_client)
  • Update server-ai README managed-model example: model.invoke()model.run(); .message.content.content (ManagedResult is flat); remove nonexistent model.get_messages() (replace with model.get_config().messages)
  • Replace nonexistent LangChainProvider class throughout server-ai README with current create_langchain_model and bare get_ai_metrics_from_response helper
  • Swap track_metrics_of / track_metrics_of_async arg order to (extractor, callable) per 0.19 signature
  • Canonicalize imports: from ldai.providers.typesfrom ldai.providers (LDAIMetrics) + from ldai.tracker (TokenUsage)
  • Align LangChain README's manual-runner example to import LangChainModelRunner (which it actually instantiates)

Refs AIC-2383. This PR is part of the AI Configs docs/example modernization sweep tracked in `python-agent-work/all-docs-review.md`.

Test plan

  • Grep sweep confirms zero remaining `from ldai import init`, `LangChainProvider`, `model.invoke(`, `.message.content`, `model.get_messages`, `track_metrics_of(lambda:` in the 3 modified files
  • Each Python snippet in the READMEs is syntactically valid (manual paste-into-REPL or `python -m py_compile` via a temp file)
  • At least one provider snippet runs end-to-end against current SDK to confirm no runtime errors

🤖 Generated with Claude Code


Note

Low Risk
Documentation-only changes that update example code to match current SDK APIs; low risk aside from potentially breaking copy/paste snippets if any call signatures were misunderstood.

Overview
Modernizes the Python AI SDK and provider READMEs to current APIs by switching initialization to LDAIClient(ld_client) and updating ManagedModel examples to use model.run() and the flattened result.content.

Refreshes provider-centric examples to remove outdated LangChainProvider references in favor of create_langchain_model/get_ai_metrics_from_response, fixes tracking helper call signatures (track_metrics_of/track_metrics_of_async), and updates imports/types (LDAIMetrics, TokenUsage) and the LangChain manual-runner example to use LangChainModelRunner.

Reviewed by Cursor Bugbot for commit cc7dc8a. Bugbot is set up for automated code reviews on this repo. Configure here.

jsonbailey and others added 2 commits May 14, 2026 11:15
- packages/sdk/server-ai/README.md, packages/ai-providers/server-ai-openai/README.md, packages/ai-providers/server-ai-langchain/README.md
- Replace nonexistent `from ldai import init` / `init(ld_client)` with `from ldai import LDAIClient` / `LDAIClient(ld_client)` in both provider READMEs
- Update server-ai README: model.invoke() -> model.run() and .message.content -> .content; remove nonexistent model.get_messages(); replace nonexistent LangChainProvider class with create_langchain_model + bare get_ai_metrics_from_response; swap track_metrics_of / track_metrics_of_async arg order to (extractor, callable); canonicalize from ldai.providers.types -> from ldai.providers + from ldai.tracker
- Fix LangChain README: align manual-runner example to import LangChainModelRunner that it actually uses
- Fix `result.metrics.tokens` -> `result.metrics.usage` in both provider READMEs (Python LDAIMetricSummary uses .usage; the input LDAIMetrics dataclass uses .tokens - asymmetric)

Refs AIC-2383

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…mples

LDAIMetricSummary's token field is `tokens`, not `usage` (verified at
packages/sdk/server-ai/src/ldai/tracker.py — the `@property def tokens`
on LDAIMetricSummary). The earlier change to `.usage` was a regression
based on an unverified asymmetry claim; reverting.

Refs AIC-2383

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-2383/modernize-server-ai-readmes branch from ee5a82e to d62ee1d Compare May 14, 2026 16:16
…ADME

`ManagedModel.get_config().messages` returns the configured/templated
system messages from the AI Config, not the conversation history the
model accumulated across run() calls. Drop the block rather than imply
otherwise.

Refs AIC-2383

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jsonbailey jsonbailey marked this pull request as ready for review May 14, 2026 16:56
@jsonbailey jsonbailey requested a review from a team as a code owner May 14, 2026 16:56
@jsonbailey jsonbailey changed the title fix: Modernize server-ai package and provider READMEs to current SDK chore: Modernize server-ai package and provider READMEs to current SDK May 14, 2026
@jsonbailey jsonbailey merged commit cbe3802 into main May 14, 2026
7 checks passed
@jsonbailey jsonbailey deleted the jb/aic-2383/modernize-server-ai-readmes branch May 14, 2026 21:00
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