-
Notifications
You must be signed in to change notification settings - Fork 2
docs: add per-example READMEs with .env support #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
465aaae
docs: add per-example READMEs with .env support
devin-ai-integration[bot] 5fc3b0d
chore: move example files into their respective subdirectories
tracisiebel 6b331e7
chore: fix pyproject.toml script paths and rename hyphenated folders
tracisiebel 675765f
chore: make each example self-contained with its own pyproject.toml
tracisiebel 1f47222
fix: address review feedback on example structure
devin-ai-integration[bot] 240e516
fix: add package-mode=false to root pyproject.toml for CI compatibility
devin-ai-integration[bot] b30d479
fix: add launchdarkly-server-sdk-ai-openai to judge dependencies
devin-ai-integration[bot] 4cf10db
chore: delete root pyproject.toml and update CI to install per-example
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| .python-version | ||
| poetry.lock | ||
| __pycache__/ | ||
| .env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Bedrock Example (Single Provider) | ||
|
|
||
| This example demonstrates how to use LaunchDarkly's AI Config with the AWS Bedrock provider. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Python 3.10 or higher | ||
| - [Poetry](https://python-poetry.org/) installed | ||
| - A LaunchDarkly account with an [AI Config](https://launchdarkly.com/docs/home/ai-configs/create) created | ||
| - AWS credentials configured for Bedrock access | ||
|
|
||
| ## Setup | ||
|
|
||
| 1. Create a `.env` file in the repository root with the following variables: | ||
|
|
||
| ``` | ||
| LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key | ||
| LAUNCHDARKLY_AI_CONFIG_KEY=sample-ai-config | ||
| ``` | ||
|
|
||
| > `LAUNCHDARKLY_AI_CONFIG_KEY` defaults to `sample-ai-config` if not set. | ||
|
|
||
| 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: | ||
|
|
||
| ``` | ||
| AWS_ACCESS_KEY_ID=your-access-key-id | ||
| AWS_SECRET_ACCESS_KEY=your-secret-access-key | ||
| AWS_DEFAULT_REGION=us-east-1 | ||
| ``` | ||
|
|
||
| Other options include role providers or shared credential files. | ||
|
|
||
| 3. Install the required dependencies: | ||
|
|
||
| ```bash | ||
| poetry install -E bedrock | ||
| ``` | ||
|
|
||
| ## Run | ||
|
|
||
| ```bash | ||
| poetry run bedrock-example | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Chat with Observability (Observability Plugin Example) | ||
|
|
||
| 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). | ||
|
|
||
| The observability plugin automatically captures and sends data to LaunchDarkly: | ||
|
|
||
| - **Observability tab**: SDK operations, flag evaluations, error monitoring, logging, and distributed tracing | ||
| - **AI Config Monitoring tab**: Token usage, duration, success/error rates, and custom metadata for filtering and analysis | ||
|
|
||
| View your data in the LaunchDarkly dashboard under **Observability** tabs. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Python 3.10 or higher | ||
| - [Poetry](https://python-poetry.org/) installed | ||
| - A LaunchDarkly account with an [AI Config](https://launchdarkly.com/docs/home/ai-configs/create) created | ||
| - An API key for your AI provider (e.g., OpenAI) | ||
|
|
||
| ## Setup | ||
|
|
||
| 1. Create a `.env` file in the repository root with the following variables: | ||
|
|
||
| ``` | ||
| LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key | ||
| LAUNCHDARKLY_AI_CONFIG_KEY=sample-ai-config | ||
| OPENAI_API_KEY=your-openai-api-key | ||
| ``` | ||
|
|
||
| > `LAUNCHDARKLY_AI_CONFIG_KEY` defaults to `sample-ai-config` if not set. | ||
|
|
||
| Optionally, set service identification: | ||
|
|
||
| ``` | ||
| SERVICE_NAME=my-ai-service | ||
| SERVICE_VERSION=1.0.0 | ||
| ``` | ||
|
|
||
| 2. Install the required dependencies: | ||
|
|
||
| ```bash | ||
| poetry install -E observability | ||
| ``` | ||
|
|
||
| ## Run | ||
|
|
||
| ```bash | ||
| poetry run chat-observability-example | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Gemini Example (Single Provider) | ||
|
|
||
| This example demonstrates how to use LaunchDarkly's AI Config with the Google Gemini provider. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Python 3.10 or higher | ||
| - [Poetry](https://python-poetry.org/) installed | ||
| - A LaunchDarkly account with an [AI Config](https://launchdarkly.com/docs/home/ai-configs/create) created | ||
| - A [Google API key](https://aistudio.google.com/apikey) | ||
|
|
||
| ## Setup | ||
|
|
||
| 1. Create a `.env` file in the repository root with the following variables: | ||
|
|
||
| ``` | ||
| LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key | ||
| LAUNCHDARKLY_AI_CONFIG_KEY=sample-ai-config | ||
| GOOGLE_API_KEY=your-google-api-key | ||
| ``` | ||
|
|
||
| > `LAUNCHDARKLY_AI_CONFIG_KEY` defaults to `sample-ai-config` if not set. | ||
|
|
||
| 2. Install the required dependencies: | ||
|
|
||
| ```bash | ||
| poetry install -E gemini | ||
| ``` | ||
|
|
||
| ## Run | ||
|
|
||
| ```bash | ||
| poetry run gemini-example | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Judge Examples (Judge Evaluation) | ||
|
|
||
| These examples demonstrate how to use LaunchDarkly's judge functionality to evaluate AI responses for accuracy, relevance, and other metrics. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Python 3.10 or higher | ||
| - [Poetry](https://python-poetry.org/) installed | ||
| - A LaunchDarkly account with an [AI Config](https://launchdarkly.com/docs/home/ai-configs/create) created for chat functionality | ||
| - A [Judge Config](https://launchdarkly.com/docs/home/ai-configs/judges) created for evaluation | ||
| - API keys for the provider you want to use (OpenAI, Bedrock, or Gemini) | ||
|
|
||
| ## Setup | ||
|
|
||
| 1. Create a `.env` file in the repository root with the following variables: | ||
|
|
||
| ``` | ||
| LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key | ||
| LAUNCHDARKLY_AI_CONFIG_KEY=sample-ai-config | ||
| LAUNCHDARKLY_AI_JUDGE_KEY=sample-ai-judge-accuracy | ||
| ``` | ||
|
|
||
| > `LAUNCHDARKLY_AI_CONFIG_KEY` defaults to `sample-ai-config` if not set. | ||
| > `LAUNCHDARKLY_AI_JUDGE_KEY` defaults to `sample-ai-judge-accuracy` if not set. | ||
|
|
||
| Add the API key for your chosen provider: | ||
|
|
||
| ``` | ||
| OPENAI_API_KEY=your-openai-api-key | ||
| ``` | ||
|
|
||
| 2. Install the required dependencies: | ||
|
|
||
| ```bash | ||
| poetry install -E langchain | ||
| ``` | ||
|
|
||
| ## Run | ||
|
|
||
| ### Chat with automatic judge evaluation | ||
|
|
||
| Uses the chat functionality which automatically evaluates responses with any judges defined in the AI config. | ||
|
|
||
| ```bash | ||
| poetry run chat-judge-example | ||
| ``` | ||
|
|
||
| ### Direct judge evaluation | ||
|
|
||
| Evaluates specific input/output pairs using a judge configuration directly. | ||
|
|
||
| ```bash | ||
| poetry run direct-judge-example | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.