You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add per-example READMEs with .env support (#25)
## Summary
Restructures the repository so each example is self-contained in its own
directory with a dedicated README, `pyproject.toml`, and source files.
Adds `.env` file support via `python-dotenv`.
## Review & Testing Checklist for Human
- [ ] `cd` into an example directory (e.g. `examples/openai`) and run
`poetry install && poetry run openai-example` to confirm the
self-contained setup works
- [ ] Verify each example README has correct env vars, install, and run
commands
- [ ] Confirm main README table links resolve to the correct example
READMEs
### Notes
- Root `pyproject.toml` deleted; CI updated to loop through each example
directory with `poetry -C "$dir" install`
- Bedrock example now reads `AWS_DEFAULT_REGION` from env with
`us-east-1` fallback
- `.env` added to `.gitignore`
Link to Devin session:
https://app.devin.ai/sessions/26e40d921a3d4e42a01faa3068908c23
Requested by: @tracisiebel
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+15-90Lines changed: 15 additions & 90 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,106 +8,31 @@ This demo requires Python 3.10 or higher.
8
8
9
9
## Build Instructions
10
10
11
-
This repository includes examples for `OpenAI`, `Bedrock`, and`LangChain` for multi-provider support. Depending on your preferred provider, you may have to take some additional steps.
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.
12
12
13
13
### General setup
14
14
15
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.
16
-
1. Set the environment variable `LAUNCHDARKLY_SDK_KEY` to your LaunchDarkly SDK key and `LAUNCHDARKLY_AI_CONFIG_KEY` to the AI Config key; otherwise, an AI Config of `sample-ai-config` or `sample-ai-agent-config` will be assumed for most examples.
1. Ensure you have [Poetry](https://python-poetry.org/) installed.
24
18
25
-
### Provider-Specific Setup
26
-
27
-
#### OpenAI setup (single provider)
28
-
29
-
1. Install the required dependencies with `poetry install -E openai` or `poetry install --all-extras`.
30
-
1. Set the environment variable `OPENAI_API_KEY` to your OpenAI key.
31
-
1. On the command line, run `poetry run openai-example`.
32
-
33
-
#### Chat with observability (observability plugin example)
34
-
35
-
This example demonstrates how to use the LaunchDarkly observability SDK plugin to monitor AI chat operations. For more details, see the [Python SDK observability reference](https://launchdarkly.com/docs/sdk/observability/python).
19
+
1. Create a `.env` file in the repository root with at least your LaunchDarkly SDK key:
36
20
37
-
1. Install the required dependencies with `poetry install -E observability` or `poetry install --all-extras`.
38
-
1. Set the environment variable for your AI provider (e.g., `OPENAI_API_KEY`), or configure your AI Config to use a different provider.
39
-
1. Optionally, set service identification:
40
-
```bash
41
-
export SERVICE_NAME="my-ai-service"
42
-
export SERVICE_VERSION="1.0.0"
43
21
```
44
-
1. On the command line, run `poetry run chat-observability-example`.
45
-
46
-
The observability plugin automatically captures and sends data to LaunchDarkly:
47
-
-**Observability tab**: SDK operations, flag evaluations, error monitoring, logging, and distributed tracing
48
-
-**AI Config Monitoring tab**: Token usage, duration, success/error rates, and custom metadata for filtering and analysis
49
-
50
-
View your data in the LaunchDarkly dashboard under **Observability** tabs.
51
-
52
-
#### Bedrock setup (single provider)
53
-
54
-
1. Install the required dependencies with `poetry install -E bedrock` or `poetry install --all-extras`.
55
-
1. Ensure the required AWS credentials can be [auto-detected by the `boto3` library](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html). Examples might include environment variables, role providers, or shared credential files.
56
-
1. On the command line, run `poetry run bedrock-example`.
57
-
58
-
#### Gemini setup (single provider)
59
-
60
-
1. Install the required dependencies with `poetry install -E gemini` or `poetry install --all-extras`.
61
-
1. Set the environment variable `GOOGLE_API_KEY` to your Google API key.
62
-
1. On the command line, run `poetry run gemini-example`.
63
-
64
-
#### LangChain setup (multiple providers)
65
-
66
-
This example uses `OpenAI`, `Bedrock`, and `Gemini` LangChain provider packages. You can add additional LangChain providers using the `poetry add` command.
67
-
68
-
1. Install all dependencies with `poetry install -E langchain` or `poetry install --all-extras`.
69
-
1. Set up API keys for the providers you want to use.
70
-
1. On the command line, run `poetry run langchain-example`
71
-
72
-
#### LangGraph setup (multiple providers, single agent)
73
-
74
-
1. Install all dependencies with `poetry install -E langgraph` or `poetry install --all-extras`.
75
-
1. Set up API keys for the providers you want to use.
76
-
1. Optionally set this environment variable to use a different agent config:
1. Install all dependencies with `poetry install -E langgraph` or `poetry install --all-extras`.
85
-
1. Set up API keys for the providers you want to use.
86
-
1.[Create an AI Config (Agent-based)](https://launchdarkly.com/docs/home/ai-configs/agents) using the keys below. Write a goal for each config and enable it with targeting rules.
87
-
1. Optionally set these environment variables to use different agent configs:
Note: The default values are `sample-ai-config` for AI Config and `sample-ai-judge-accuracy` for Judge Config if not specified.
25
+
Each example README describes the full set of environment variables needed. The `.env` file is loaded automatically when running any example.
109
26
110
-
##### Available judge examples:
27
+
###Examples
111
28
112
-
-**Chat with automatic judge evaluation** (`poetry run chat-judge-example`): Uses the chat functionality which automatically evaluates responses with any judges defined in the AI config.
113
-
-**Direct judge evaluation** (`poetry run direct-judge-example`): Evaluates specific input/output pairs using a judge configuration directly.
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)|
This example demonstrates how to use LaunchDarkly's AI Config with the AWS Bedrock provider.
4
+
5
+
## Prerequisites
6
+
7
+
- Python 3.10 or higher
8
+
-[Poetry](https://python-poetry.org/) installed
9
+
- A LaunchDarkly account with an [AI Config](https://launchdarkly.com/docs/home/ai-configs/create) created
10
+
- AWS credentials configured for Bedrock access
11
+
12
+
## Setup
13
+
14
+
1. Create a `.env` file in this directory with the following variables:
15
+
16
+
```
17
+
LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key
18
+
LAUNCHDARKLY_AI_CONFIG_KEY=sample-ai-config
19
+
```
20
+
21
+
> `LAUNCHDARKLY_AI_CONFIG_KEY` defaults to `sample-ai-config` if not set.
22
+
23
+
2. Ensure your AWS credentials can be [auto-detected by the `boto3` library](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html). You can set them in your `.env` file:
24
+
25
+
```
26
+
AWS_ACCESS_KEY_ID=your-access-key-id
27
+
AWS_SECRET_ACCESS_KEY=your-secret-access-key
28
+
AWS_DEFAULT_REGION=us-east-1
29
+
```
30
+
31
+
Other options include role providers or shared credential files.
# Chat with Observability (Observability Plugin Example)
2
+
3
+
This example demonstrates how to use the LaunchDarkly observability SDK plugin to monitor AI chat operations. For more details, see the [Python SDK observability reference](https://launchdarkly.com/docs/sdk/observability/python).
4
+
5
+
The observability plugin automatically captures and sends data to LaunchDarkly:
6
+
7
+
-**Observability tab**: SDK operations, flag evaluations, error monitoring, logging, and distributed tracing
8
+
-**AI Config Monitoring tab**: Token usage, duration, success/error rates, and custom metadata for filtering and analysis
9
+
10
+
View your data in the LaunchDarkly dashboard under **Observability** tabs.
11
+
12
+
## Prerequisites
13
+
14
+
- Python 3.10 or higher
15
+
-[Poetry](https://python-poetry.org/) installed
16
+
- A LaunchDarkly account with an [AI Config](https://launchdarkly.com/docs/home/ai-configs/create) created
17
+
- An API key for your AI provider (e.g., OpenAI)
18
+
19
+
## Setup
20
+
21
+
1. Create a `.env` file in this directory with the following variables:
22
+
23
+
```
24
+
LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key
25
+
LAUNCHDARKLY_AI_CONFIG_KEY=sample-ai-config
26
+
OPENAI_API_KEY=your-openai-api-key
27
+
```
28
+
29
+
> `LAUNCHDARKLY_AI_CONFIG_KEY` defaults to `sample-ai-config` if not set.
0 commit comments