Skip to content

Commit 667b4b7

Browse files
chore: update LaunchDarkly AI SDK and langchain dependencies to latest versions (#20)
## Summary Updates LaunchDarkly AI SDK dependencies and the langchain ecosystem to their latest versions. The `ldai_langchain` 0.4.0 release removed the `LangChainProvider` class in favor of top-level helper functions, so the three langchain-based examples are updated accordingly. **Dependency changes in `pyproject.toml`:** | Package | Old | New | |---|---|---| | `launchdarkly-server-sdk-ai` | ^0.16.1 | ^0.17.0 | | `launchdarkly-server-sdk-ai-langchain` | ^0.3.2 | ^0.4.0 | | `launchdarkly-server-sdk-ai-openai` | ^0.2.1 | ^0.3.0 | | `langchain` | ^0.3.0 | ^1.0.0 | | `langchain-core` | ^0.3.0 | ^1.0.0 | | `langchain-aws` | ^0.2.30 | ^1.0.0 | | `langchain-openai` | ^0.3.30 | ^1.0.0 | | `langchain-google-genai` | ^2.1.9 | ^4.0.0 | | `langgraph` | ^0.2.0 | ^1.0.0 | **Code changes:** `LangChainProvider.get_ai_metrics_from_response` → `get_ai_metrics_from_response` (now a top-level import from `ldai_langchain`) in `langchain_example.py`, `langgraph_agent_example.py`, and `langgraph_multi_agent_example.py`. ## Review & Testing Checklist for Human - [ ] Verify the langchain 0.x → 1.x migration doesn't break other APIs used in the examples (e.g., `init_chat_model`, message dict format, `ainvoke`). Only the `LangChainProvider` import was updated — other langchain usage was left as-is. - [ ] Confirm `langchain-google-genai` ^4.0.0 is correct — this skips the 3.x line. Check that the `gemini_example.py` still works with this version. - [ ] Verify `poetry.lock` is either committed or intentionally gitignored. It is not included in this diff. - [ ] Run at least one example end-to-end (e.g., `poetry run openai-example` or `poetry run langchain-example`) to confirm the updated SDKs work with a real LaunchDarkly AI config. ### Notes - The non-langchain examples (`openai_example.py`, `bedrock_example.py`, `gemini_example.py`, `chat_judge_example.py`, `chat_observability_example.py`, `direct_judge_example.py`) were not modified. Their imports were verified to still resolve, but they were not tested end-to-end. - The langchain ecosystem bump from 0.x to 1.x was required because `ldai_langchain` 0.4.0 itself depends on `langchain >=1.0.0`. Link to Devin session: https://app.devin.ai/sessions/c8cf47d46e3f464290a65b6c05862c86 Requested by: @kinyoklion --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent ce84fe5 commit 667b4b7

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

examples/langchain_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ldclient import Context
55
from ldclient.config import Config
66
from ldai.client import LDAIClient
7-
from ldai_langchain import LangChainProvider
7+
from ldai_langchain import get_ai_metrics_from_response
88
from langchain.chat_models import init_chat_model
99

1010
# Set sdk_key to your LaunchDarkly SDK key.
@@ -89,7 +89,7 @@ async def async_main():
8989
# Track the LangChain completion with LaunchDarkly metrics using the LD LangChain provider's extractor
9090
completion = await tracker.track_metrics_of(
9191
lambda: llm.ainvoke(messages),
92-
LangChainProvider.get_ai_metrics_from_response,
92+
get_ai_metrics_from_response,
9393
)
9494
ai_response = completion.content
9595

examples/langgraph_agent_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ldclient.config import Config
66
from ldai.client import LDAIClient
77
from ldai.tracker import TokenUsage
8-
from ldai_langchain import LangChainProvider
8+
from ldai_langchain import get_ai_metrics_from_response
99
from langchain.chat_models import init_chat_model
1010
from langgraph.prebuilt import create_react_agent
1111

@@ -36,7 +36,7 @@ def track_langgraph_metrics(tracker, func):
3636
total_tokens = 0
3737
if "messages" in result:
3838
for message in result["messages"]:
39-
metrics = LangChainProvider.get_ai_metrics_from_response(message)
39+
metrics = get_ai_metrics_from_response(message)
4040
if metrics.usage:
4141
total_input_tokens += metrics.usage.input
4242
total_output_tokens += metrics.usage.output

examples/langgraph_multi_agent_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ldclient.config import Config
55
from ldai.client import LDAIClient
66
from ldai.tracker import TokenUsage
7-
from ldai_langchain import LangChainProvider
7+
from ldai_langchain import get_ai_metrics_from_response
88
from langchain.chat_models import init_chat_model
99
from langgraph.prebuilt import create_react_agent
1010
from langgraph.graph import StateGraph, END
@@ -47,7 +47,7 @@ def track_langgraph_metrics(tracker, func, prev_message_count=0):
4747
if "messages" in result:
4848
new_messages = result["messages"][prev_message_count:]
4949
for message in new_messages:
50-
metrics = LangChainProvider.get_ai_metrics_from_response(message)
50+
metrics = get_ai_metrics_from_response(message)
5151
if metrics.usage:
5252
total_input_tokens += metrics.usage.input
5353
total_output_tokens += metrics.usage.output

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ direct-judge-example = 'examples.direct_judge_example:main'
2020

2121
[tool.poetry.dependencies]
2222
python = "^3.10"
23-
launchdarkly-server-sdk-ai = "^0.16.1"
24-
launchdarkly-server-sdk-ai-langchain = "^0.3.2"
25-
launchdarkly-server-sdk-ai-openai = "^0.2.1"
23+
launchdarkly-server-sdk-ai = "^0.17.0"
24+
launchdarkly-server-sdk-ai-langchain = "^0.4.0"
25+
launchdarkly-server-sdk-ai-openai = "^0.3.0"
2626
launchdarkly-observability = { version = ">=0.1.0", optional = true }
2727

2828
boto3 = { version = ">=0.2.0", optional = true }
2929
openai = { version = ">=0.2.0", optional = true }
3030
google-genai = { version = "^1.30.0", optional = true }
31-
langchain = {version = "^0.3.0", optional = true}
32-
langchain-aws = {version = "^0.2.30", optional = true}
33-
langchain-core = {version = "^0.3.0", optional = true}
34-
langchain-google-genai = {version = "^2.1.9", optional = true}
35-
langchain-openai = {version = "^0.3.30", optional = true}
36-
langgraph = {version = "^0.2.0", optional = true}
31+
langchain = {version = "^1.0.0", optional = true}
32+
langchain-aws = {version = "^1.0.0", optional = true}
33+
langchain-core = {version = "^1.0.0", optional = true}
34+
langchain-google-genai = {version = "^4.0.0", optional = true}
35+
langchain-openai = {version = "^1.0.0", optional = true}
36+
langgraph = {version = "^1.0.0", optional = true}
3737

3838
[tool.poetry.extras]
3939
bedrock = ["boto3"]

0 commit comments

Comments
 (0)