Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/langchain_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ldclient import Context
from ldclient.config import Config
from ldai.client import LDAIClient
from ldai_langchain import LangChainProvider
from ldai_langchain import get_ai_metrics_from_response
from langchain.chat_models import init_chat_model

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

Expand Down
4 changes: 2 additions & 2 deletions examples/langgraph_agent_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ldclient.config import Config
from ldai.client import LDAIClient
from ldai.tracker import TokenUsage
from ldai_langchain import LangChainProvider
from ldai_langchain import get_ai_metrics_from_response
from langchain.chat_models import init_chat_model
from langgraph.prebuilt import create_react_agent

Expand Down Expand Up @@ -36,7 +36,7 @@ def track_langgraph_metrics(tracker, func):
total_tokens = 0
if "messages" in result:
for message in result["messages"]:
metrics = LangChainProvider.get_ai_metrics_from_response(message)
metrics = get_ai_metrics_from_response(message)
if metrics.usage:
total_input_tokens += metrics.usage.input
total_output_tokens += metrics.usage.output
Expand Down
4 changes: 2 additions & 2 deletions examples/langgraph_multi_agent_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ldclient.config import Config
from ldai.client import LDAIClient
from ldai.tracker import TokenUsage
from ldai_langchain import LangChainProvider
from ldai_langchain import get_ai_metrics_from_response
from langchain.chat_models import init_chat_model
from langgraph.prebuilt import create_react_agent
from langgraph.graph import StateGraph, END
Expand Down Expand Up @@ -47,7 +47,7 @@ def track_langgraph_metrics(tracker, func, prev_message_count=0):
if "messages" in result:
new_messages = result["messages"][prev_message_count:]
for message in new_messages:
metrics = LangChainProvider.get_ai_metrics_from_response(message)
metrics = get_ai_metrics_from_response(message)
if metrics.usage:
total_input_tokens += metrics.usage.input
total_output_tokens += metrics.usage.output
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ direct-judge-example = 'examples.direct_judge_example:main'

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

boto3 = { version = ">=0.2.0", optional = true }
openai = { version = ">=0.2.0", optional = true }
google-genai = { version = "^1.30.0", optional = true }
langchain = {version = "^0.3.0", optional = true}
langchain-aws = {version = "^0.2.30", optional = true}
langchain-core = {version = "^0.3.0", optional = true}
langchain-google-genai = {version = "^2.1.9", optional = true}
langchain-openai = {version = "^0.3.30", optional = true}
langgraph = {version = "^0.2.0", optional = true}
langchain = {version = "^1.0.0", optional = true}
langchain-aws = {version = "^1.0.0", optional = true}
langchain-core = {version = "^1.0.0", optional = true}
langchain-google-genai = {version = "^4.0.0", optional = true}
langchain-openai = {version = "^1.0.0", optional = true}
langgraph = {version = "^1.0.0", optional = true}

[tool.poetry.extras]
bedrock = ["boto3"]
Expand Down
Loading