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
3 changes: 2 additions & 1 deletion examples/bedrock/bedrock_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ def main():
context,
variables={'myUserVariable': "Testing Variable"}
)
tracker = config_value.tracker

if not config_value.enabled:
print("AI Config is disabled")
return

tracker = config_value.create_tracker()

# Map the messages to the format expected by Bedrock
chat_messages = [{'role': msg.role, 'content': [{'text': msg.content}]} for msg in config_value.messages if msg.role != 'system']
system_messages = [{'text': msg.content} for msg in config_value.messages if msg.role == 'system']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def async_main():
)

if not chat:
print(f"*** AI chat configuration is not enabled for key: {ai_config_key}")
print(f"*** Failed to create chat for key: {ai_config_key}")
return

user_input_1 = "What is feature flagging in 2 sentences?"
Expand Down
2 changes: 2 additions & 0 deletions examples/chat_observability/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ python = "^3.10"
python-dotenv = ">=1.0.0"
launchdarkly-server-sdk-ai = "^0.18.0"
launchdarkly-observability = ">=0.1.0"
launchdarkly-server-sdk-ai-openai = ">=0.4.0"
launchdarkly-server-sdk-ai-langchain = ">=0.5.0"
openai = ">=0.2.0"

[build-system]
Expand Down
3 changes: 2 additions & 1 deletion examples/gemini/gemini_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ def main():
context,
variables={'myUserVariable': "Testing Variable"}
)
tracker = config_value.tracker

if not config_value.enabled:
print("AI Config is disabled")
return

tracker = config_value.create_tracker()

# Configure Google Generative AI
client = genai.Client(
api_key=google_api_key,
Expand Down
2 changes: 1 addition & 1 deletion examples/judge/chat_judge_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def async_main():
})

if not chat:
print(f"*** AI chat configuration is not enabled for key: {ai_config_key}")
print(f"*** Failed to create chat for key: {ai_config_key}")
return

print("\n*** Starting chat with automatic judge evaluation:")
Expand Down
2 changes: 1 addition & 1 deletion examples/judge/direct_judge_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def async_main():
judge = await aiclient.create_judge(judge_key, context)

if not judge:
print(f"*** AI judge configuration is not enabled for key: {judge_key}")
print(f"*** Failed to create judge for key: {judge_key}")
return

print("\n*** Starting direct judge evaluation of input and output:")
Expand Down
3 changes: 2 additions & 1 deletion examples/langchain/langchain_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ async def async_main():
context,
variables={'myUserVariable': "Testing Variable"}
)
tracker = config_value.tracker

if not config_value.enabled:
print("AI Config is disabled")
return

tracker = config_value.create_tracker()

try:
# Create LangChain model instance using init_chat_model
# Map the provider from config_value to LangChain format
Expand Down
2 changes: 1 addition & 1 deletion examples/langgraph_agent/langgraph_agent_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def main():

try:
# Track and execute the agent
response = track_langgraph_metrics(agent_config.tracker, lambda: agent.invoke({
response = track_langgraph_metrics(agent_config.create_tracker(), lambda: agent.invoke({
"messages": [{"role": "user", "content": "What is the weather in Tokyo?"}]
}))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def create_agent_with_config(aiclient, config_key, context):
# Create a React agent with the LLM
agent = create_react_agent(llm, [], prompt=agent_config.instructions)

return agent, agent_config.tracker, False
return agent, agent_config.create_tracker(), False

def ai_node(
state: CodeReviewState,
Expand Down
3 changes: 2 additions & 1 deletion examples/openai/openai_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ def main():
context,
variables={'myUserVariable': "Testing Variable"}
)
tracker = config_value.tracker

if not config_value.enabled:
print("AI Config is disabled")
return

tracker = config_value.create_tracker()

messages = [message.to_dict() for message in (config_value.messages or [])]

Expand Down
Loading