Skip to content

Commit 3de980f

Browse files
committed
feat: Reorganize examples for easier navigation
1 parent 5176d03 commit 3de980f

35 files changed

Lines changed: 177 additions & 284 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
- name: Install dependencies
3434
run: |
35-
for dir in examples/*/; do
35+
for dir in getting_started/completion_config/*/ getting_started/agent_config/*/ features/*/; do
3636
echo "Installing $dir"
3737
poetry -C "$dir" install
3838
done

README.md

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
# LaunchDarkly sample Python application
1+
# LaunchDarkly AI SDK for Python - Examples
22

3-
We've built a simple console application that demonstrates how LaunchDarkly's SDK works.
4-
5-
Below, you'll find the build procedure. For more comprehensive instructions, you can visit your [Quickstart page](https://docs.launchdarkly.com/home/ai-configs/quickstart) or the [Python reference guide](https://docs.launchdarkly.com/sdk/ai/python).
6-
7-
This demo requires Python 3.10 or higher.
8-
9-
## Build Instructions
10-
11-
This repository includes examples for `OpenAI`, `Bedrock`, `Gemini`, `LangChain`, `LangGraph`, `Judge`, and `Observability`. Depending on your preferred provider, you may have to take some additional steps.
3+
| Package | PyPI | Docs |
4+
| --- | --- | --- |
5+
| [launchdarkly-server-sdk-ai](https://github.com/launchdarkly/python-server-sdk-ai/tree/main/packages/sdk/server-ai) | [![PyPI](https://img.shields.io/pypi/v/launchdarkly-server-sdk-ai)](https://pypi.org/project/launchdarkly-server-sdk-ai/) | [Reference](https://docs.launchdarkly.com/sdk/ai/python) |
6+
| [launchdarkly-server-sdk-ai-openai](https://github.com/launchdarkly/python-server-sdk-ai/tree/main/packages/ai-providers/server-ai-openai) | [![PyPI](https://img.shields.io/pypi/v/launchdarkly-server-sdk-ai-openai)](https://pypi.org/project/launchdarkly-server-sdk-ai-openai/) | [Reference](https://docs.launchdarkly.com/sdk/ai/python) |
7+
| [launchdarkly-server-sdk-ai-langchain](https://github.com/launchdarkly/python-server-sdk-ai/tree/main/packages/ai-providers/server-ai-langchain) | [![PyPI](https://img.shields.io/pypi/v/launchdarkly-server-sdk-ai-langchain)](https://pypi.org/project/launchdarkly-server-sdk-ai-langchain/) | [Reference](https://docs.launchdarkly.com/sdk/ai/python) |
8+
| [launchdarkly-observability](https://github.com/launchdarkly/observability-sdk/tree/main/sdk/%40launchdarkly/observability-python) | [![PyPI](https://img.shields.io/pypi/v/launchdarkly-observability)](https://pypi.org/project/launchdarkly-observability/) | [Reference](https://docs.launchdarkly.com/sdk/observability/python) |
129

13-
### General setup
10+
Each example is a self-contained application you can run independently to explore LaunchDarkly's AI APIs hands-on. Pick one that matches your provider or use case, follow the README, and you'll be up and running in minutes.
1411

15-
1. [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) using the key specified in each example, or copy the key of existing AI Config in your LaunchDarkly project that you want to evaluate.
12+
For more comprehensive instructions, visit the [Quickstart page](https://docs.launchdarkly.com/home/ai-configs/quickstart) or the [Python reference guide](https://docs.launchdarkly.com/sdk/ai/python).
1613

17-
1. Ensure you have [Poetry](https://python-poetry.org/) installed.
14+
## Getting Started
1815

19-
1. Create a `.env` file in the repository root with at least your LaunchDarkly SDK key:
16+
These examples show how to integrate LaunchDarkly AI with different providers using `completion_config` and `agent_config`.
2017

21-
```
22-
LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key
23-
```
18+
| Example | Description |
19+
| --- | --- |
20+
| [Bedrock](getting_started/completion_config/bedrock/) | `completion_config` with AWS Bedrock, metrics tracking |
21+
| [Gemini](getting_started/completion_config/gemini/) | `completion_config` with Google Gemini, metrics tracking |
22+
| [LangChain](getting_started/completion_config/langchain/) | `completion_config` with LangChain, async metrics tracking |
23+
| [LangGraph Agent](getting_started/agent_config/langgraph_agent/) | `agent_config` with a single LangGraph ReAct agent, tool calling, metrics tracking |
24+
| [LangGraph Multi-Agent](getting_started/agent_config/langgraph_multi_agent/) | `agent_config` with multiple LangGraph agents, custom StateGraph workflow, per-node metrics |
25+
| [OpenAI](getting_started/completion_config/openai/) | `completion_config` with OpenAI, automatic metrics tracking |
2426

25-
Each example README describes the full set of environment variables needed. The `.env` file is loaded automatically when running any example.
27+
## Features
2628

27-
### Examples
29+
These examples demonstrate LaunchDarkly's managed APIs and standalone capabilities.
2830

29-
| Example | Description | README |
30-
| --- | --- | --- |
31-
| **OpenAI** | Single provider using OpenAI | [examples/openai](examples/openai/README.md) |
32-
| **Bedrock** | Single provider using AWS Bedrock | [examples/bedrock](examples/bedrock/README.md) |
33-
| **Gemini** | Single provider using Google Gemini | [examples/gemini](examples/gemini/README.md) |
34-
| **LangChain** | Multiple providers via LangChain | [examples/langchain](examples/langchain/README.md) |
35-
| **LangGraph Agent** | Single agent using LangGraph | [examples/langgraph_agent](examples/langgraph_agent/README.md) |
36-
| **LangGraph Multi-Agent** | Multiple agents using LangGraph | [examples/langgraph_multi_agent](examples/langgraph_multi_agent/README.md) |
37-
| **Judge** | Judge evaluation of AI responses | [examples/judge](examples/judge/README.md) |
38-
| **Chat with Observability** | Observability plugin for AI chat monitoring | [examples/chat_observability](examples/chat_observability/README.md) |
31+
| Example | Description |
32+
| --- | --- |
33+
| [Judge](features/judge/) | `create_judge` for standalone evaluation of AI responses |
34+
| [Managed Agent](features/managed_agent/) | `create_agent` with tool calling, automatic metrics tracking, and judge evaluation |
35+
| [Managed Agent Graph](features/managed_agent_graph/) | `create_agent_graph` with multi-node workflows, tool calling, per-node metrics, and judge evaluation |
36+
| [Managed Model](features/managed_model/) | `create_model` with managed chat, automatic metrics tracking, and judge evaluation |

examples/chat_observability/README.md

Lines changed: 0 additions & 50 deletions
This file was deleted.

examples/chat_observability/chat_observability_example.py

Lines changed: 0 additions & 128 deletions
This file was deleted.

examples/judge/README.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

features/judge/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Judge Example (Direct Evaluation)
2+
3+
This example demonstrates how to use LaunchDarkly's judge functionality to evaluate specific input/output pairs directly, without an associated chat session.
4+
5+
## Prerequisites
6+
7+
- Python 3.10 or higher
8+
- [Poetry](https://python-poetry.org/) installed
9+
- A [LaunchDarkly](https://launchdarkly.com/) account and SDK key
10+
- API keys for the provider you want to use (OpenAI, Bedrock, or Gemini)
11+
12+
## Setup
13+
14+
1. Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your `.env`.
15+
16+
- [Create a Judge Config](https://launchdarkly.com/docs/home/ai-configs/judges) for evaluation. Default key: `sample-ai-judge`.
17+
18+
1. Create a `.env` file in this directory with the following variables:
19+
20+
```
21+
LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key
22+
LAUNCHDARKLY_AI_JUDGE_KEY=sample-ai-judge
23+
OPENAI_API_KEY=your-openai-api-key
24+
```
25+
26+
1. Install the required dependencies:
27+
28+
```bash
29+
poetry install
30+
```
31+
32+
## Run
33+
34+
```bash
35+
poetry run judge
36+
```
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ldclient import Context
77
from ldclient.config import Config
88
from ldai import LDAIClient, AIJudgeConfigDefault
9+
from ldobserve import ObservabilityConfig, ObservabilityPlugin
910

1011
load_dotenv()
1112

@@ -24,7 +25,11 @@ async def async_main():
2425
print("*** Please set the LAUNCHDARKLY_SDK_KEY env first")
2526
exit()
2627

27-
ldclient.set_config(Config(sdk_key))
28+
ldclient.set_config(Config(sdk_key, plugins=[
29+
ObservabilityPlugin(ObservabilityConfig(
30+
service_name='hello-python-ai-judge',
31+
))
32+
]))
2833

2934
if not ldclient.get().is_initialized():
3035
print("*** SDK failed to initialize. Please check your internet connection and SDK credential for any typo.")
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@ description = "Hello LaunchDarkly for Python AI - Judge"
55
authors = ["LaunchDarkly <dev@launchdarkly.com>"]
66
license = "Apache-2.0"
77
readme = "README.md"
8-
packages = [
9-
{include = "chat_judge_example.py"},
10-
{include = "direct_judge_example.py"},
11-
]
8+
packages = [{include = "judge_example.py"}]
129

1310
[tool.poetry.scripts]
14-
chat-judge = "chat_judge_example:main"
15-
direct-judge = "direct_judge_example:main"
11+
judge = "judge_example:main"
1612

1713
[tool.poetry.dependencies]
1814
python = "^3.10"
1915
python-dotenv = ">=1.0.0"
2016
launchdarkly-server-sdk-ai = ">=0.19.0"
17+
launchdarkly-observability = ">=0.1.0"
2118
launchdarkly-server-sdk-ai-openai = ">=0.5.0"
2219
launchdarkly-server-sdk-ai-langchain = ">=0.6.0"
2320
openai = ">=1.0.0"
File renamed without changes.

0 commit comments

Comments
 (0)