Skip to content

feat: update examples for AI SDK ManagedResult and tracker factory APIs#26

Open
jsonbailey wants to merge 2 commits intomainfrom
jb/aic-2388/update-examples
Open

feat: update examples for AI SDK ManagedResult and tracker factory APIs#26
jsonbailey wants to merge 2 commits intomainfrom
jb/aic-2388/update-examples

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

Summary

  • Migrate all 7 hello-python-ai examples to the AI SDK API surface introduced by the upcoming launchdarkly-server-sdk-ai 0.18 / -openai 0.4 / -langchain 0.5 release stack
  • Bump version pins (^0.17^0.18, ^0.3^0.4, ^0.4^0.5)
  • Add the missing launchdarkly-server-sdk-ai-openai dependency to chat_observability (the example calls aiclient.create_model() which dispatches via the runner factory)

API changes covered

  • ManagedModel.invoke().run(); ModelResponse.message.contentManagedResult.content
  • chat_response.evaluations is now a single asyncio.Task[List[JudgeResult]]await it directly instead of asyncio.gather over a list
  • JudgeResult is a single value with direct fields (sampled, success, metric_key, score, reasoning, error_message)
  • AIConfig.tracker field → AIConfig.create_tracker() factory
  • tracker.track_metrics_of(metrics_extractor, func) parameter order; use track_metrics_of_async for awaited callables (langchain example)
  • aiclient.create_judge() is sync — drop the unnecessary await
  • direct-judge default judge key updated to sample-ai-judge (the prior default key isn't configured in the shared LD project)

Test plan

  • chat-judge-example — PASS (chat + judge eval with score + reasoning)
  • direct-judge-example — PASS (judge eval with score + reasoning)
  • chat-observability-example — PASS (two chat turns + awaited judge tasks)
  • openai-example — PASS (sync OpenAI completion via tracker)
  • langchain-example — PASS (async LangChain ainvoke via track_metrics_of_async)
  • langgraph-agent-example — PASS (single-agent React agent with tool call)
  • langgraph-multi-agent-example — PASS (multi-node graph; final report generated)

All seven verified end-to-end against the upstream SDK worktree.

🤖 Generated with Claude Code

Migrate examples to the AI SDK API surface introduced by the upcoming
ldai 0.18 / openai 0.4 / langchain 0.5 release stack:

- ManagedModel.invoke() -> .run(); ModelResponse.message.content -> ManagedResult.content
- chat_response.evaluations is a single asyncio.Task[List[JudgeResult]];
  await it directly instead of asyncio.gather over a list
- JudgeResult is a single value (not List); access .sampled / .success /
  .metric_key / .score / .reasoning / .error_message directly
- AIConfig.tracker (field) -> AIConfig.create_tracker() (factory)
- track_metrics_of(metrics_extractor, func) parameter order; use
  track_metrics_of_async for awaited callables (langchain example)
- aiclient.create_judge() is sync; drop the unnecessary `await`
- direct_judge default key updated to `sample-ai-judge` (configured)
- chat_observability now declares launchdarkly-server-sdk-ai-openai as a
  dependency since it uses aiclient.create_model() which loads providers
  via the runner factory

Bumps published version pins to ^0.18 / ^0.4 / ^0.5 to match the new API.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-2388/update-examples branch from c0e0eac to 0c57793 Compare May 5, 2026 17:24
@jsonbailey jsonbailey marked this pull request as ready for review May 6, 2026 00:44
@jsonbailey jsonbailey requested a review from a team as a code owner May 6, 2026 00:44
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