chore: Modernize server-ai package and provider READMEs to current SDK#184
Merged
Conversation
- 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>
ee5a82e to
d62ee1d
Compare
…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>
andrewklatzke
approved these changes
May 14, 2026
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
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+ APIsfrom ldai import init/init(ld_client)(in both provider READMEs) withfrom ldai import LDAIClient/LDAIClient(ld_client)model.invoke()→model.run();.message.content→.content(ManagedResult is flat); remove nonexistentmodel.get_messages()(replace withmodel.get_config().messages)LangChainProviderclass throughout server-ai README with currentcreate_langchain_modeland bareget_ai_metrics_from_responsehelpertrack_metrics_of/track_metrics_of_asyncarg order to(extractor, callable)per 0.19 signaturefrom ldai.providers.types→from ldai.providers(LDAIMetrics) +from ldai.tracker(TokenUsage)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
🤖 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 usemodel.run()and the flattenedresult.content.Refreshes provider-centric examples to remove outdated
LangChainProviderreferences in favor ofcreate_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 useLangChainModelRunner.Reviewed by Cursor Bugbot for commit cc7dc8a. Bugbot is set up for automated code reviews on this repo. Configure here.