From 19469200eb32588067a7fa889f476e1c32c1669f Mon Sep 17 00:00:00 2001 From: jsonbailey Date: Wed, 13 May 2026 12:39:30 -0500 Subject: [PATCH 1/6] chore: Standardize example config keys and env vars Align hello-python-ai examples with the new env var and default config-key naming established in js-core PR #1379: LAUNCHDARKLY_AI_CONFIG_KEY -> LAUNCHDARKLY_COMPLETION_KEY sample-completion-config -> sample-completion LAUNCHDARKLY_AGENT_CONFIG_KEY -> LAUNCHDARKLY_AGENT_KEY sample-agent-config -> sample-agent LAUNCHDARKLY_AI_JUDGE_KEY -> LAUNCHDARKLY_JUDGE_KEY sample-ai-judge -> sample-judge LAUNCHDARKLY_ANALYZER_CONFIG_KEY -> LAUNCHDARKLY_ANALYZER_KEY LAUNCHDARKLY_DOCUMENTATION_CONFIG_KEY -> LAUNCHDARKLY_DOCUMENTATION_KEY The state_graph example's analyzer/documentation defaults (code-review-analyzer / code-review-documentation) already match the new no-suffix naming and are unchanged. LAUNCHDARKLY_AGENT_GRAPH_KEY / sample-agent-graph are also unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- features/create_agent/README.md | 4 ++-- features/create_agent/create_agent_example.py | 2 +- features/create_judge/README.md | 4 ++-- features/create_judge/create_judge_example.py | 2 +- features/create_model/README.md | 4 ++-- features/create_model/create_model_example.py | 2 +- getting_started/bedrock/converse/README.md | 6 +++--- getting_started/bedrock/converse/bedrock_example.py | 4 ++-- getting_started/gemini/generate_content/README.md | 4 ++-- getting_started/gemini/generate_content/gemini_example.py | 4 ++-- getting_started/langchain/invoke/README.md | 4 ++-- getting_started/langchain/invoke/langchain_example.py | 4 ++-- getting_started/langgraph/react_agent/README.md | 4 ++-- .../langgraph/react_agent/langgraph_agent_example.py | 2 +- .../langgraph/state_graph/langgraph_multi_agent_example.py | 4 ++-- getting_started/openai/chat_completions/README.md | 4 ++-- getting_started/openai/chat_completions/openai_example.py | 4 ++-- 17 files changed, 31 insertions(+), 31 deletions(-) diff --git a/features/create_agent/README.md b/features/create_agent/README.md index 33777a6..0b2bf40 100644 --- a/features/create_agent/README.md +++ b/features/create_agent/README.md @@ -13,13 +13,13 @@ This example demonstrates how to use LaunchDarkly's `create_agent` method, which 1. Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your `.env`. - - [Create an AI Agent Config](https://launchdarkly.com/docs/home/ai-configs/agents) with a model and agent instructions. Default key: `sample-agent-config`. + - [Create an AI Agent Config](https://launchdarkly.com/docs/home/ai-configs/agents) with a model and agent instructions. Default key: `sample-agent`. 1. Create a `.env` file in this directory with the following variables: ``` LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AGENT_CONFIG_KEY=sample-agent-config + LAUNCHDARKLY_AGENT_KEY=sample-agent OPENAI_API_KEY=your-openai-api-key ``` diff --git a/features/create_agent/create_agent_example.py b/features/create_agent/create_agent_example.py index 6f7fa72..6c11e59 100644 --- a/features/create_agent/create_agent_example.py +++ b/features/create_agent/create_agent_example.py @@ -17,7 +17,7 @@ sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') # Set agent_config_key to the AI Agent Config key you want to evaluate. -agent_config_key = os.getenv('LAUNCHDARKLY_AGENT_CONFIG_KEY', 'sample-agent-config') +agent_config_key = os.getenv('LAUNCHDARKLY_AGENT_KEY', 'sample-agent') def get_weather(city: str) -> str: diff --git a/features/create_judge/README.md b/features/create_judge/README.md index f5d0cd9..be46d33 100644 --- a/features/create_judge/README.md +++ b/features/create_judge/README.md @@ -13,13 +13,13 @@ This example demonstrates how to use LaunchDarkly's `create_judge` method to eva 1. Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your `.env`. - - [Create a Judge Config](https://launchdarkly.com/docs/home/ai-configs/judges) for evaluation. Default key: `sample-ai-judge`. + - [Create a Judge Config](https://launchdarkly.com/docs/home/ai-configs/judges) for evaluation. Default key: `sample-judge`. 1. Create a `.env` file in this directory with the following variables: ``` LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AI_JUDGE_KEY=sample-ai-judge + LAUNCHDARKLY_JUDGE_KEY=sample-judge OPENAI_API_KEY=your-openai-api-key ``` diff --git a/features/create_judge/create_judge_example.py b/features/create_judge/create_judge_example.py index 813fcb9..dfce63f 100644 --- a/features/create_judge/create_judge_example.py +++ b/features/create_judge/create_judge_example.py @@ -17,7 +17,7 @@ sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') # Set judge_key to the Judge key you want to use. -judge_key = os.getenv('LAUNCHDARKLY_AI_JUDGE_KEY', 'sample-ai-judge') +judge_key = os.getenv('LAUNCHDARKLY_JUDGE_KEY', 'sample-judge') async def async_main(): diff --git a/features/create_model/README.md b/features/create_model/README.md index 80f049c..186df6a 100644 --- a/features/create_model/README.md +++ b/features/create_model/README.md @@ -13,13 +13,13 @@ This example demonstrates how to use LaunchDarkly's `create_model` method, which 1. Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your `.env`. - - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a model and system message. Default key: `sample-completion-config`. + - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a model and system message. Default key: `sample-completion`. 1. Create a `.env` file in this directory with the following variables: ``` LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AI_CONFIG_KEY=sample-completion-config + LAUNCHDARKLY_COMPLETION_KEY=sample-completion OPENAI_API_KEY=your-openai-api-key ``` diff --git a/features/create_model/create_model_example.py b/features/create_model/create_model_example.py index 9022c2d..d6b1e3e 100644 --- a/features/create_model/create_model_example.py +++ b/features/create_model/create_model_example.py @@ -17,7 +17,7 @@ sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') # Set config_key to the AI Config key you want to evaluate. -ai_config_key = os.getenv('LAUNCHDARKLY_AI_CONFIG_KEY', 'sample-completion-config') +ai_config_key = os.getenv('LAUNCHDARKLY_COMPLETION_KEY', 'sample-completion') async def async_main(): diff --git a/getting_started/bedrock/converse/README.md b/getting_started/bedrock/converse/README.md index 09da9dc..4bf04e9 100644 --- a/getting_started/bedrock/converse/README.md +++ b/getting_started/bedrock/converse/README.md @@ -13,16 +13,16 @@ This example demonstrates how to use LaunchDarkly's AI Config with the AWS Bedro 1. Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your `.env`. - - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a Bedrock model and a system message. Default key: `sample-completion-config`. + - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a Bedrock model and a system message. Default key: `sample-completion`. 1. Create a `.env` file in this directory with the following variables: ``` LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AI_CONFIG_KEY=sample-completion-config + LAUNCHDARKLY_COMPLETION_KEY=sample-completion ``` - > `LAUNCHDARKLY_AI_CONFIG_KEY` defaults to `sample-completion-config` if not set. + > `LAUNCHDARKLY_COMPLETION_KEY` defaults to `sample-completion` if not set. 1. 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: diff --git a/getting_started/bedrock/converse/bedrock_example.py b/getting_started/bedrock/converse/bedrock_example.py index 2d853da..1fded50 100755 --- a/getting_started/bedrock/converse/bedrock_example.py +++ b/getting_started/bedrock/converse/bedrock_example.py @@ -40,14 +40,14 @@ def get_bedrock_metrics(response): sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') # Set config_key to the AI Config key you want to evaluate. -ai_config_key = os.getenv('LAUNCHDARKLY_AI_CONFIG_KEY', 'sample-completion-config') +ai_config_key = os.getenv('LAUNCHDARKLY_COMPLETION_KEY', 'sample-completion') def main(): if not sdk_key: print("*** Please set the LAUNCHDARKLY_SDK_KEY env first") exit() if not ai_config_key: - print("*** Please set the LAUNCHDARKLY_AI_CONFIG_KEY env first") + print("*** Please set the LAUNCHDARKLY_COMPLETION_KEY env first") exit() ldclient.set_config(Config(sdk_key, plugins=[ diff --git a/getting_started/gemini/generate_content/README.md b/getting_started/gemini/generate_content/README.md index 9abe617..4ff87f9 100644 --- a/getting_started/gemini/generate_content/README.md +++ b/getting_started/gemini/generate_content/README.md @@ -13,13 +13,13 @@ This example demonstrates how to use LaunchDarkly's AI Config with the Google Ge 1. Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your `.env`. - - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a Gemini model (e.g. `gemini-2.0-flash`) and a system message. Default key: `sample-completion-config`. + - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a Gemini model (e.g. `gemini-2.0-flash`) and a system message. Default key: `sample-completion`. 1. Create a `.env` file in this directory with the following variables: ``` LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AI_CONFIG_KEY=sample-completion-config + LAUNCHDARKLY_COMPLETION_KEY=sample-completion GOOGLE_API_KEY=your-google-api-key ``` diff --git a/getting_started/gemini/generate_content/gemini_example.py b/getting_started/gemini/generate_content/gemini_example.py index 22ba7ec..086204c 100644 --- a/getting_started/gemini/generate_content/gemini_example.py +++ b/getting_started/gemini/generate_content/gemini_example.py @@ -20,7 +20,7 @@ sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') # Set config_key to the AI Config key you want to evaluate. -ai_config_key = os.getenv('LAUNCHDARKLY_AI_CONFIG_KEY', 'sample-completion-config') +ai_config_key = os.getenv('LAUNCHDARKLY_COMPLETION_KEY', 'sample-completion') # Set Google API key google_api_key = os.getenv('GOOGLE_API_KEY') @@ -93,7 +93,7 @@ def main(): print("*** Please set the LAUNCHDARKLY_SDK_KEY env first") exit() if not ai_config_key: - print("*** Please set the LAUNCHDARKLY_AI_CONFIG_KEY env first") + print("*** Please set the LAUNCHDARKLY_COMPLETION_KEY env first") exit() if not google_api_key: print("*** Please set the GOOGLE_API_KEY env first") diff --git a/getting_started/langchain/invoke/README.md b/getting_started/langchain/invoke/README.md index 5f42e0e..b8740b5 100644 --- a/getting_started/langchain/invoke/README.md +++ b/getting_started/langchain/invoke/README.md @@ -13,13 +13,13 @@ This example demonstrates how to use LaunchDarkly's AI Config with LangChain, su 1. Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your `.env`. - - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a model and a system message. Default key: `sample-completion-config`. + - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a model and a system message. Default key: `sample-completion`. 1. Create a `.env` file in this directory with the following variables: ``` LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AI_CONFIG_KEY=sample-completion-config + LAUNCHDARKLY_COMPLETION_KEY=sample-completion ``` Add the API keys for the providers you want to use: diff --git a/getting_started/langchain/invoke/langchain_example.py b/getting_started/langchain/invoke/langchain_example.py index 8fdba44..a0b388c 100644 --- a/getting_started/langchain/invoke/langchain_example.py +++ b/getting_started/langchain/invoke/langchain_example.py @@ -19,7 +19,7 @@ sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') # Set config_key to the AI Config key you want to evaluate. -ai_config_key = os.getenv('LAUNCHDARKLY_AI_CONFIG_KEY', 'sample-completion-config') +ai_config_key = os.getenv('LAUNCHDARKLY_COMPLETION_KEY', 'sample-completion') def map_provider_to_langchain(provider_name): """Map LaunchDarkly provider names to LangChain provider names.""" @@ -35,7 +35,7 @@ async def async_main(): print("*** Please set the LAUNCHDARKLY_SDK_KEY env first") exit() if not ai_config_key: - print("*** Please set the LAUNCHDARKLY_AI_CONFIG_KEY env first") + print("*** Please set the LAUNCHDARKLY_COMPLETION_KEY env first") exit() ldclient.set_config(Config(sdk_key, plugins=[ diff --git a/getting_started/langgraph/react_agent/README.md b/getting_started/langgraph/react_agent/README.md index d94d8c7..4a90ea9 100644 --- a/getting_started/langgraph/react_agent/README.md +++ b/getting_started/langgraph/react_agent/README.md @@ -13,13 +13,13 @@ This example demonstrates how to use LaunchDarkly's AI Config with LangGraph to 1. Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your `.env`. - - [Create an AI Agent Config](https://launchdarkly.com/docs/home/ai-configs/agents) with a model and agent instructions. Default key: `sample-agent-config`. + - [Create an AI Agent Config](https://launchdarkly.com/docs/home/ai-configs/agents) with a model and agent instructions. Default key: `sample-agent`. 1. Create a `.env` file in this directory with the following variables: ``` LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AGENT_CONFIG_KEY=sample-agent-config + LAUNCHDARKLY_AGENT_KEY=sample-agent ``` Add the API keys for the providers you want to use: diff --git a/getting_started/langgraph/react_agent/langgraph_agent_example.py b/getting_started/langgraph/react_agent/langgraph_agent_example.py index ba1a4c9..a178c63 100644 --- a/getting_started/langgraph/react_agent/langgraph_agent_example.py +++ b/getting_started/langgraph/react_agent/langgraph_agent_example.py @@ -20,7 +20,7 @@ sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') # Set config key for the agent -agent_config_key = os.getenv('LAUNCHDARKLY_AGENT_CONFIG_KEY', 'sample-agent-config') +agent_config_key = os.getenv('LAUNCHDARKLY_AGENT_KEY', 'sample-agent') def map_provider_to_langchain(provider_name): """Map LaunchDarkly provider names to LangChain provider names.""" diff --git a/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py b/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py index c05edef..41ef39d 100644 --- a/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py +++ b/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py @@ -23,8 +23,8 @@ sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') # Set config keys for the two agents -analyzer_config_key = os.getenv('LAUNCHDARKLY_ANALYZER_CONFIG_KEY', 'code-review-analyzer') -documentation_config_key = os.getenv('LAUNCHDARKLY_DOCUMENTATION_CONFIG_KEY', 'code-review-documentation') +analyzer_config_key = os.getenv('LAUNCHDARKLY_ANALYZER_KEY', 'code-review-analyzer') +documentation_config_key = os.getenv('LAUNCHDARKLY_DOCUMENTATION_KEY', 'code-review-documentation') # Custom state class for the code review workflow class CodeReviewState(TypedDict): diff --git a/getting_started/openai/chat_completions/README.md b/getting_started/openai/chat_completions/README.md index cb81328..c2b75cf 100644 --- a/getting_started/openai/chat_completions/README.md +++ b/getting_started/openai/chat_completions/README.md @@ -13,13 +13,13 @@ This example demonstrates how to use LaunchDarkly's AI Config with the OpenAI pr 1. Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your `.env`. - - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with an OpenAI model (e.g. `gpt-4`) and a system message. Default key: `sample-completion-config`. + - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with an OpenAI model (e.g. `gpt-4`) and a system message. Default key: `sample-completion`. 1. Create a `.env` file in this directory with the following variables: ``` LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AI_CONFIG_KEY=sample-completion-config + LAUNCHDARKLY_COMPLETION_KEY=sample-completion OPENAI_API_KEY=your-openai-api-key ``` diff --git a/getting_started/openai/chat_completions/openai_example.py b/getting_started/openai/chat_completions/openai_example.py index ad59114..19fd0cf 100755 --- a/getting_started/openai/chat_completions/openai_example.py +++ b/getting_started/openai/chat_completions/openai_example.py @@ -20,7 +20,7 @@ sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') # Set config_key to the AI Config key you want to evaluate. -ai_config_key = os.getenv('LAUNCHDARKLY_AI_CONFIG_KEY', 'sample-completion-config') +ai_config_key = os.getenv('LAUNCHDARKLY_COMPLETION_KEY', 'sample-completion') def main(): @@ -28,7 +28,7 @@ def main(): print("*** Please set the LAUNCHDARKLY_SDK_KEY env first") exit() if not ai_config_key: - print("*** Please set the LAUNCHDARKLY_AI_CONFIG_KEY env first") + print("*** Please set the LAUNCHDARKLY_COMPLETION_KEY env first") exit() ldclient.set_config(Config(sdk_key, plugins=[ From 17c8bcbc24774258fee8a6c5e9ce5922239ad377 Mon Sep 17 00:00:00 2001 From: jsonbailey Date: Wed, 13 May 2026 12:39:30 -0500 Subject: [PATCH 2/6] chore: Add .env.example files to all examples Each example directory now ships a `.env.example` listing the env vars that example reads, with empty values for the user to fill in. Each per-example README now points at it with a `cp .env.example .env` step instead of inlining the variable list. `.env` is already covered by .gitignore. Co-Authored-By: Claude Opus 4.7 (1M context) --- features/create_agent/.env.example | 8 ++++++++ features/create_agent/README.md | 8 +++----- features/create_agent_graph/.env.example | 8 ++++++++ features/create_agent_graph/README.md | 8 +++----- features/create_judge/.env.example | 8 ++++++++ features/create_judge/README.md | 8 +++----- features/create_model/.env.example | 8 ++++++++ features/create_model/README.md | 8 +++----- getting_started/bedrock/converse/.env.example | 12 ++++++++++++ getting_started/bedrock/converse/README.md | 19 +++++-------------- .../gemini/generate_content/.env.example | 8 ++++++++ .../gemini/generate_content/README.md | 8 +++----- getting_started/langchain/invoke/.env.example | 11 +++++++++++ getting_started/langchain/invoke/README.md | 16 +++------------- .../langgraph/react_agent/.env.example | 11 +++++++++++ .../langgraph/react_agent/README.md | 16 +++------------- .../langgraph/state_graph/.env.example | 14 ++++++++++++++ .../langgraph/state_graph/README.md | 17 +++-------------- .../openai/chat_completions/.env.example | 8 ++++++++ .../openai/chat_completions/README.md | 8 +++----- 20 files changed, 128 insertions(+), 84 deletions(-) create mode 100644 features/create_agent/.env.example create mode 100644 features/create_agent_graph/.env.example create mode 100644 features/create_judge/.env.example create mode 100644 features/create_model/.env.example create mode 100644 getting_started/bedrock/converse/.env.example create mode 100644 getting_started/gemini/generate_content/.env.example create mode 100644 getting_started/langchain/invoke/.env.example create mode 100644 getting_started/langgraph/react_agent/.env.example create mode 100644 getting_started/langgraph/state_graph/.env.example create mode 100644 getting_started/openai/chat_completions/.env.example diff --git a/features/create_agent/.env.example b/features/create_agent/.env.example new file mode 100644 index 0000000..968fc61 --- /dev/null +++ b/features/create_agent/.env.example @@ -0,0 +1,8 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Provider API key(s) for the provider your agent config uses +OPENAI_API_KEY= + +# Optional - defaults to "sample-agent" +LAUNCHDARKLY_AGENT_KEY= diff --git a/features/create_agent/README.md b/features/create_agent/README.md index 0b2bf40..9624ffa 100644 --- a/features/create_agent/README.md +++ b/features/create_agent/README.md @@ -15,12 +15,10 @@ This example demonstrates how to use LaunchDarkly's `create_agent` method, which - [Create an AI Agent Config](https://launchdarkly.com/docs/home/ai-configs/agents) with a model and agent instructions. Default key: `sample-agent`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys: - ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AGENT_KEY=sample-agent - OPENAI_API_KEY=your-openai-api-key + ```bash + cp .env.example .env ``` 1. Install the required dependencies: diff --git a/features/create_agent_graph/.env.example b/features/create_agent_graph/.env.example new file mode 100644 index 0000000..9fa533b --- /dev/null +++ b/features/create_agent_graph/.env.example @@ -0,0 +1,8 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Provider API key(s) for the provider(s) your agent graph uses +OPENAI_API_KEY= + +# Optional - defaults to "sample-agent-graph" +LAUNCHDARKLY_AGENT_GRAPH_KEY= diff --git a/features/create_agent_graph/README.md b/features/create_agent_graph/README.md index 2592de1..d3f3b76 100644 --- a/features/create_agent_graph/README.md +++ b/features/create_agent_graph/README.md @@ -16,12 +16,10 @@ This example demonstrates how to use LaunchDarkly's `create_agent_graph` method, - [Create AI Agent Configs](https://launchdarkly.com/docs/home/ai-configs/agents) for each node in your graph. Configure each with a model and agent instructions. Add tools (e.g. `search_flights`, `search_hotels`, `get_weather`) to the agents that need them. - [Create an Agent Graph](https://launchdarkly.com/docs/home/ai-configs/create) that connects your agent configs as nodes with edges defining the workflow. Default key: `sample-agent-graph`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys: - ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AGENT_GRAPH_KEY=sample-agent-graph - OPENAI_API_KEY=your-openai-api-key + ```bash + cp .env.example .env ``` 1. Install the required dependencies: diff --git a/features/create_judge/.env.example b/features/create_judge/.env.example new file mode 100644 index 0000000..d318e1c --- /dev/null +++ b/features/create_judge/.env.example @@ -0,0 +1,8 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Provider API key(s) for the provider your judge config uses +OPENAI_API_KEY= + +# Optional - defaults to "sample-judge" +LAUNCHDARKLY_JUDGE_KEY= diff --git a/features/create_judge/README.md b/features/create_judge/README.md index be46d33..a58d461 100644 --- a/features/create_judge/README.md +++ b/features/create_judge/README.md @@ -15,12 +15,10 @@ This example demonstrates how to use LaunchDarkly's `create_judge` method to eva - [Create a Judge Config](https://launchdarkly.com/docs/home/ai-configs/judges) for evaluation. Default key: `sample-judge`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys: - ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_JUDGE_KEY=sample-judge - OPENAI_API_KEY=your-openai-api-key + ```bash + cp .env.example .env ``` 1. Install the required dependencies: diff --git a/features/create_model/.env.example b/features/create_model/.env.example new file mode 100644 index 0000000..0bab514 --- /dev/null +++ b/features/create_model/.env.example @@ -0,0 +1,8 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Provider API key(s) for the provider your AI config uses +OPENAI_API_KEY= + +# Optional - defaults to "sample-completion" +LAUNCHDARKLY_COMPLETION_KEY= diff --git a/features/create_model/README.md b/features/create_model/README.md index 186df6a..2502f8d 100644 --- a/features/create_model/README.md +++ b/features/create_model/README.md @@ -15,12 +15,10 @@ This example demonstrates how to use LaunchDarkly's `create_model` method, which - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a model and system message. Default key: `sample-completion`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys: - ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_COMPLETION_KEY=sample-completion - OPENAI_API_KEY=your-openai-api-key + ```bash + cp .env.example .env ``` 1. Install the required dependencies: diff --git a/getting_started/bedrock/converse/.env.example b/getting_started/bedrock/converse/.env.example new file mode 100644 index 0000000..fc40902 --- /dev/null +++ b/getting_started/bedrock/converse/.env.example @@ -0,0 +1,12 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Your AWS credentials for Bedrock access +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= + +# Optional - defaults to "us-east-1" +AWS_DEFAULT_REGION= + +# Optional - defaults to "sample-completion" +LAUNCHDARKLY_COMPLETION_KEY= diff --git a/getting_started/bedrock/converse/README.md b/getting_started/bedrock/converse/README.md index 4bf04e9..497a2c4 100644 --- a/getting_started/bedrock/converse/README.md +++ b/getting_started/bedrock/converse/README.md @@ -15,24 +15,15 @@ This example demonstrates how to use LaunchDarkly's AI Config with the AWS Bedro - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a Bedrock model and a system message. Default key: `sample-completion`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys: + ```bash + cp .env.example .env ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_COMPLETION_KEY=sample-completion - ``` - - > `LAUNCHDARKLY_COMPLETION_KEY` defaults to `sample-completion` if not set. -1. 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 - ``` + `LAUNCHDARKLY_COMPLETION_KEY` defaults to `sample-completion` if not set. - Other options include role providers or shared credential files. + Ensure your AWS credentials can be [auto-detected by the `boto3` library](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html). Setting them in `.env` is one option; role providers or shared credential files are also supported. 1. Install the required dependencies: diff --git a/getting_started/gemini/generate_content/.env.example b/getting_started/gemini/generate_content/.env.example new file mode 100644 index 0000000..af973b8 --- /dev/null +++ b/getting_started/gemini/generate_content/.env.example @@ -0,0 +1,8 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Your Google API key +GOOGLE_API_KEY= + +# Optional - defaults to "sample-completion" +LAUNCHDARKLY_COMPLETION_KEY= diff --git a/getting_started/gemini/generate_content/README.md b/getting_started/gemini/generate_content/README.md index 4ff87f9..8a94bfc 100644 --- a/getting_started/gemini/generate_content/README.md +++ b/getting_started/gemini/generate_content/README.md @@ -15,12 +15,10 @@ This example demonstrates how to use LaunchDarkly's AI Config with the Google Ge - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a Gemini model (e.g. `gemini-2.0-flash`) and a system message. Default key: `sample-completion`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys: - ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_COMPLETION_KEY=sample-completion - GOOGLE_API_KEY=your-google-api-key + ```bash + cp .env.example .env ``` 1. Install the required dependencies: diff --git a/getting_started/langchain/invoke/.env.example b/getting_started/langchain/invoke/.env.example new file mode 100644 index 0000000..8249750 --- /dev/null +++ b/getting_started/langchain/invoke/.env.example @@ -0,0 +1,11 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Provider API keys - fill in the ones for the provider(s) your AI config uses +OPENAI_API_KEY= +GOOGLE_API_KEY= +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= + +# Optional - defaults to "sample-completion" +LAUNCHDARKLY_COMPLETION_KEY= diff --git a/getting_started/langchain/invoke/README.md b/getting_started/langchain/invoke/README.md index b8740b5..da05362 100644 --- a/getting_started/langchain/invoke/README.md +++ b/getting_started/langchain/invoke/README.md @@ -15,20 +15,10 @@ This example demonstrates how to use LaunchDarkly's AI Config with LangChain, su - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with a model and a system message. Default key: `sample-completion`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys (only the provider keys for providers you actually use are required): - ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_COMPLETION_KEY=sample-completion - ``` - - Add the API keys for the providers you want to use: - - ``` - OPENAI_API_KEY=your-openai-api-key - GOOGLE_API_KEY=your-google-api-key - AWS_ACCESS_KEY_ID=your-access-key-id - AWS_SECRET_ACCESS_KEY=your-secret-access-key + ```bash + cp .env.example .env ``` 1. Install the required dependencies: diff --git a/getting_started/langgraph/react_agent/.env.example b/getting_started/langgraph/react_agent/.env.example new file mode 100644 index 0000000..13f1f74 --- /dev/null +++ b/getting_started/langgraph/react_agent/.env.example @@ -0,0 +1,11 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Provider API keys - fill in the ones for the provider(s) your agent config uses +OPENAI_API_KEY= +GOOGLE_API_KEY= +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= + +# Optional - defaults to "sample-agent" +LAUNCHDARKLY_AGENT_KEY= diff --git a/getting_started/langgraph/react_agent/README.md b/getting_started/langgraph/react_agent/README.md index 4a90ea9..71d831c 100644 --- a/getting_started/langgraph/react_agent/README.md +++ b/getting_started/langgraph/react_agent/README.md @@ -15,20 +15,10 @@ This example demonstrates how to use LaunchDarkly's AI Config with LangGraph to - [Create an AI Agent Config](https://launchdarkly.com/docs/home/ai-configs/agents) with a model and agent instructions. Default key: `sample-agent`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys (only the provider keys for providers you actually use are required): - ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_AGENT_KEY=sample-agent - ``` - - Add the API keys for the providers you want to use: - - ``` - OPENAI_API_KEY=your-openai-api-key - GOOGLE_API_KEY=your-google-api-key - AWS_ACCESS_KEY_ID=your-access-key-id - AWS_SECRET_ACCESS_KEY=your-secret-access-key + ```bash + cp .env.example .env ``` 1. Install the required dependencies: diff --git a/getting_started/langgraph/state_graph/.env.example b/getting_started/langgraph/state_graph/.env.example new file mode 100644 index 0000000..df170af --- /dev/null +++ b/getting_started/langgraph/state_graph/.env.example @@ -0,0 +1,14 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Provider API keys - fill in the ones for the provider(s) your agent configs use +OPENAI_API_KEY= +GOOGLE_API_KEY= +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= + +# Optional - defaults to "code-review-analyzer" +LAUNCHDARKLY_ANALYZER_KEY= + +# Optional - defaults to "code-review-documentation" +LAUNCHDARKLY_DOCUMENTATION_KEY= diff --git a/getting_started/langgraph/state_graph/README.md b/getting_started/langgraph/state_graph/README.md index 1388a02..d529205 100644 --- a/getting_started/langgraph/state_graph/README.md +++ b/getting_started/langgraph/state_graph/README.md @@ -16,21 +16,10 @@ This example demonstrates how to use LaunchDarkly's AI Config with LangGraph to - [Create an AI Agent Config](https://launchdarkly.com/docs/home/ai-configs/agents) for code analysis. Default key: `code-review-analyzer`. - [Create an AI Agent Config](https://launchdarkly.com/docs/home/ai-configs/agents) for documentation generation. Default key: `code-review-documentation`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys (only the provider keys for providers you actually use are required): - ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_ANALYZER_CONFIG_KEY=code-review-analyzer - LAUNCHDARKLY_DOCUMENTATION_CONFIG_KEY=code-review-documentation - ``` - - Add the API keys for the providers you want to use: - - ``` - OPENAI_API_KEY=your-openai-api-key - GOOGLE_API_KEY=your-google-api-key - AWS_ACCESS_KEY_ID=your-access-key-id - AWS_SECRET_ACCESS_KEY=your-secret-access-key + ```bash + cp .env.example .env ``` 1. Install the required dependencies: diff --git a/getting_started/openai/chat_completions/.env.example b/getting_started/openai/chat_completions/.env.example new file mode 100644 index 0000000..db08df1 --- /dev/null +++ b/getting_started/openai/chat_completions/.env.example @@ -0,0 +1,8 @@ +# Your LaunchDarkly server-side SDK key +LAUNCHDARKLY_SDK_KEY= + +# Your OpenAI API key +OPENAI_API_KEY= + +# Optional - defaults to "sample-completion" +LAUNCHDARKLY_COMPLETION_KEY= diff --git a/getting_started/openai/chat_completions/README.md b/getting_started/openai/chat_completions/README.md index c2b75cf..368fa97 100644 --- a/getting_started/openai/chat_completions/README.md +++ b/getting_started/openai/chat_completions/README.md @@ -15,12 +15,10 @@ This example demonstrates how to use LaunchDarkly's AI Config with the OpenAI pr - [Create an AI Config](https://launchdarkly.com/docs/home/ai-configs/create) with an OpenAI model (e.g. `gpt-4`) and a system message. Default key: `sample-completion`. -1. Create a `.env` file in this directory with the following variables: +1. Copy `.env.example` to `.env` and fill in your keys: - ``` - LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key - LAUNCHDARKLY_COMPLETION_KEY=sample-completion - OPENAI_API_KEY=your-openai-api-key + ```bash + cp .env.example .env ``` 1. Install the required dependencies: From d2c5af5d0a97c0e9a79fdc6bc85daa2fb8950e13 Mon Sep 17 00:00:00 2001 From: jsonbailey Date: Wed, 13 May 2026 13:30:29 -0500 Subject: [PATCH 3/6] chore: Set default values for optional LaunchDarkly keys in example env files Python's os.getenv(key, default) returns the default only when the var is unset. dotenv loads `KEY=` as a *set* empty string, so a user who copies `.env.example` to `.env` without editing would silently get an empty string and the AI Config lookup would fail. Setting the documented defaults inline (e.g. LAUNCHDARKLY_COMPLETION_KEY= sample-completion) fixes that and removes the duplicate "defaults to X" comments. Required vars (SDK key, provider keys) stay blank. Co-Authored-By: Claude Opus 4.7 (1M context) --- features/create_agent/.env.example | 4 ++-- features/create_agent_graph/.env.example | 4 ++-- features/create_judge/.env.example | 4 ++-- features/create_model/.env.example | 4 ++-- getting_started/bedrock/converse/.env.example | 4 ++-- getting_started/gemini/generate_content/.env.example | 4 ++-- getting_started/langchain/invoke/.env.example | 4 ++-- getting_started/langgraph/react_agent/.env.example | 4 ++-- getting_started/langgraph/state_graph/.env.example | 8 ++++---- getting_started/openai/chat_completions/.env.example | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/features/create_agent/.env.example b/features/create_agent/.env.example index 968fc61..2b699ad 100644 --- a/features/create_agent/.env.example +++ b/features/create_agent/.env.example @@ -4,5 +4,5 @@ LAUNCHDARKLY_SDK_KEY= # Provider API key(s) for the provider your agent config uses OPENAI_API_KEY= -# Optional - defaults to "sample-agent" -LAUNCHDARKLY_AGENT_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_AGENT_KEY=sample-agent diff --git a/features/create_agent_graph/.env.example b/features/create_agent_graph/.env.example index 9fa533b..fede5cc 100644 --- a/features/create_agent_graph/.env.example +++ b/features/create_agent_graph/.env.example @@ -4,5 +4,5 @@ LAUNCHDARKLY_SDK_KEY= # Provider API key(s) for the provider(s) your agent graph uses OPENAI_API_KEY= -# Optional - defaults to "sample-agent-graph" -LAUNCHDARKLY_AGENT_GRAPH_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_AGENT_GRAPH_KEY=sample-agent-graph diff --git a/features/create_judge/.env.example b/features/create_judge/.env.example index d318e1c..43fb371 100644 --- a/features/create_judge/.env.example +++ b/features/create_judge/.env.example @@ -4,5 +4,5 @@ LAUNCHDARKLY_SDK_KEY= # Provider API key(s) for the provider your judge config uses OPENAI_API_KEY= -# Optional - defaults to "sample-judge" -LAUNCHDARKLY_JUDGE_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_JUDGE_KEY=sample-judge diff --git a/features/create_model/.env.example b/features/create_model/.env.example index 0bab514..7bb58dc 100644 --- a/features/create_model/.env.example +++ b/features/create_model/.env.example @@ -4,5 +4,5 @@ LAUNCHDARKLY_SDK_KEY= # Provider API key(s) for the provider your AI config uses OPENAI_API_KEY= -# Optional - defaults to "sample-completion" -LAUNCHDARKLY_COMPLETION_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_COMPLETION_KEY=sample-completion diff --git a/getting_started/bedrock/converse/.env.example b/getting_started/bedrock/converse/.env.example index fc40902..0a52d19 100644 --- a/getting_started/bedrock/converse/.env.example +++ b/getting_started/bedrock/converse/.env.example @@ -8,5 +8,5 @@ AWS_SECRET_ACCESS_KEY= # Optional - defaults to "us-east-1" AWS_DEFAULT_REGION= -# Optional - defaults to "sample-completion" -LAUNCHDARKLY_COMPLETION_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_COMPLETION_KEY=sample-completion diff --git a/getting_started/gemini/generate_content/.env.example b/getting_started/gemini/generate_content/.env.example index af973b8..1cf1d92 100644 --- a/getting_started/gemini/generate_content/.env.example +++ b/getting_started/gemini/generate_content/.env.example @@ -4,5 +4,5 @@ LAUNCHDARKLY_SDK_KEY= # Your Google API key GOOGLE_API_KEY= -# Optional - defaults to "sample-completion" -LAUNCHDARKLY_COMPLETION_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_COMPLETION_KEY=sample-completion diff --git a/getting_started/langchain/invoke/.env.example b/getting_started/langchain/invoke/.env.example index 8249750..09e5c3d 100644 --- a/getting_started/langchain/invoke/.env.example +++ b/getting_started/langchain/invoke/.env.example @@ -7,5 +7,5 @@ GOOGLE_API_KEY= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= -# Optional - defaults to "sample-completion" -LAUNCHDARKLY_COMPLETION_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_COMPLETION_KEY=sample-completion diff --git a/getting_started/langgraph/react_agent/.env.example b/getting_started/langgraph/react_agent/.env.example index 13f1f74..d909fdb 100644 --- a/getting_started/langgraph/react_agent/.env.example +++ b/getting_started/langgraph/react_agent/.env.example @@ -7,5 +7,5 @@ GOOGLE_API_KEY= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= -# Optional - defaults to "sample-agent" -LAUNCHDARKLY_AGENT_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_AGENT_KEY=sample-agent diff --git a/getting_started/langgraph/state_graph/.env.example b/getting_started/langgraph/state_graph/.env.example index df170af..758abdb 100644 --- a/getting_started/langgraph/state_graph/.env.example +++ b/getting_started/langgraph/state_graph/.env.example @@ -7,8 +7,8 @@ GOOGLE_API_KEY= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= -# Optional - defaults to "code-review-analyzer" -LAUNCHDARKLY_ANALYZER_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_ANALYZER_KEY=code-review-analyzer -# Optional - defaults to "code-review-documentation" -LAUNCHDARKLY_DOCUMENTATION_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_DOCUMENTATION_KEY=code-review-documentation diff --git a/getting_started/openai/chat_completions/.env.example b/getting_started/openai/chat_completions/.env.example index db08df1..d20db55 100644 --- a/getting_started/openai/chat_completions/.env.example +++ b/getting_started/openai/chat_completions/.env.example @@ -4,5 +4,5 @@ LAUNCHDARKLY_SDK_KEY= # Your OpenAI API key OPENAI_API_KEY= -# Optional - defaults to "sample-completion" -LAUNCHDARKLY_COMPLETION_KEY= +# Override to use a different AI Config +LAUNCHDARKLY_COMPLETION_KEY=sample-completion From 44e98bc3af3a4de211233777da7044a8844881ee Mon Sep 17 00:00:00 2001 From: jsonbailey Date: Wed, 13 May 2026 16:23:23 -0500 Subject: [PATCH 4/6] chore: Set default values for all documented optional env vars in example env files Extend the previous commit's rule to every documented optional env var in the example .env.example files: if the comment says "defaults to X", the value is set to X inline and the comment is reworded to "Override...". This covers AWS_DEFAULT_REGION in the bedrock example, which had the same os.getenv(key, default) vs dotenv-loads-empty-string bug as the LaunchDarkly config-key vars. Co-Authored-By: Claude Opus 4.7 (1M context) --- getting_started/bedrock/converse/.env.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting_started/bedrock/converse/.env.example b/getting_started/bedrock/converse/.env.example index 0a52d19..aa988e4 100644 --- a/getting_started/bedrock/converse/.env.example +++ b/getting_started/bedrock/converse/.env.example @@ -5,8 +5,8 @@ LAUNCHDARKLY_SDK_KEY= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= -# Optional - defaults to "us-east-1" -AWS_DEFAULT_REGION= +# Override to use a different AWS region +AWS_DEFAULT_REGION=us-east-1 # Override to use a different AI Config LAUNCHDARKLY_COMPLETION_KEY=sample-completion From acdf06d1050fd4a6f513f23a6b373829ce511024 Mon Sep 17 00:00:00 2001 From: jsonbailey Date: Wed, 13 May 2026 16:40:34 -0500 Subject: [PATCH 5/6] chore: Note credential-leak risk on raw error logging in examples JS-side reviewer flagged that provider error responses may include credentials (OpenAI has historically echoed API keys back in error JSON). The examples intentionally print the raw exception so users can see what's wrong without modifying code, but a short comment above each top-level catch-and-log explains that production code should sanitize errors first. Co-Authored-By: Claude Opus 4.7 (1M context) --- features/create_agent/create_agent_example.py | 3 +++ features/create_agent_graph/create_agent_graph_example.py | 3 +++ features/create_judge/create_judge_example.py | 3 +++ features/create_model/create_model_example.py | 3 +++ getting_started/langchain/invoke/langchain_example.py | 3 +++ .../langgraph/react_agent/langgraph_agent_example.py | 3 +++ .../langgraph/state_graph/langgraph_multi_agent_example.py | 6 ++++++ 7 files changed, 24 insertions(+) diff --git a/features/create_agent/create_agent_example.py b/features/create_agent/create_agent_example.py index 6c11e59..418594d 100644 --- a/features/create_agent/create_agent_example.py +++ b/features/create_agent/create_agent_example.py @@ -109,6 +109,9 @@ async def async_main(): else: print("\nNo judge evaluations were performed.") + # For convenience during example debugging, we print the raw error. In + # production, sanitize errors before logging — provider responses may + # include credentials or other sensitive data. except Exception as err: print("Error:", err) finally: diff --git a/features/create_agent_graph/create_agent_graph_example.py b/features/create_agent_graph/create_agent_graph_example.py index c30b9e3..63b453b 100644 --- a/features/create_agent_graph/create_agent_graph_example.py +++ b/features/create_agent_graph/create_agent_graph_example.py @@ -127,6 +127,9 @@ async def async_main(): print(f" score: {eval_result.score}") print(f" reasoning: {eval_result.reasoning}") + # For convenience during example debugging, we print the raw error. In + # production, sanitize errors before logging — provider responses may + # include credentials or other sensitive data. except Exception as err: print("Error:", err) finally: diff --git a/features/create_judge/create_judge_example.py b/features/create_judge/create_judge_example.py index dfce63f..de82844 100644 --- a/features/create_judge/create_judge_example.py +++ b/features/create_judge/create_judge_example.py @@ -94,6 +94,9 @@ async def async_main(): print(f" reasoning: {judge_result.reasoning}") print("\nDone!") + # For convenience during example debugging, we print the raw error. In + # production, sanitize errors before logging — provider responses may + # include credentials or other sensitive data. except Exception as err: print("Error:", err) finally: diff --git a/features/create_model/create_model_example.py b/features/create_model/create_model_example.py index d6b1e3e..adb2503 100644 --- a/features/create_model/create_model_example.py +++ b/features/create_model/create_model_example.py @@ -95,6 +95,9 @@ async def async_main(): else: print("\nNo judge evaluations were performed. Try adding a judge to the AI config to see results.") + # For convenience during example debugging, we print the raw error. In + # production, sanitize errors before logging — provider responses may + # include credentials or other sensitive data. except Exception as err: print("Error:", err) finally: diff --git a/getting_started/langchain/invoke/langchain_example.py b/getting_started/langchain/invoke/langchain_example.py index a0b388c..a9ae36a 100644 --- a/getting_started/langchain/invoke/langchain_example.py +++ b/getting_started/langchain/invoke/langchain_example.py @@ -118,6 +118,9 @@ async def async_main(): if summary.tool_calls: print(f" Tool calls: {', '.join(summary.tool_calls)}") + # For convenience during example debugging, we print the raw error. In + # production, sanitize errors before logging — provider responses may + # include credentials or other sensitive data. except Exception as e: print(f"Error during completion: {e}") print("Please ensure you have the correct API keys and credentials set up for the detected provider.") diff --git a/getting_started/langgraph/react_agent/langgraph_agent_example.py b/getting_started/langgraph/react_agent/langgraph_agent_example.py index a178c63..85dfd93 100644 --- a/getting_started/langgraph/react_agent/langgraph_agent_example.py +++ b/getting_started/langgraph/react_agent/langgraph_agent_example.py @@ -121,6 +121,9 @@ def main(): if summary.tool_calls: print(f" Tool calls: {', '.join(summary.tool_calls)}") + # For convenience during example debugging, we print the raw error. In + # production, sanitize errors before logging — provider responses may + # include credentials or other sensitive data. except Exception as e: print(f"\nError: {e}") print("Please ensure you have the correct API keys and credentials set up for the detected providers.") diff --git a/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py b/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py index 41ef39d..7721244 100644 --- a/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py +++ b/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py @@ -147,6 +147,9 @@ def ai_node( } ) + # For convenience during example debugging, we print the raw error. In + # production, sanitize errors before logging — provider responses may + # include credentials or other sensitive data. except Exception as e: print(f"Error in node for {config_key}: {e}") return Command( @@ -278,6 +281,9 @@ def calculate_average(numbers): print(final_report) print("="*80) + # For convenience during example debugging, we print the raw error. In + # production, sanitize errors before logging — provider responses may + # include credentials or other sensitive data. except Exception as e: print(f"Error during workflow execution: {e}") print("Please ensure you have the correct API keys and credentials set up for the detected providers.") From 2848c7f4bfc3310d188bcdd780bc30c53764d1da Mon Sep 17 00:00:00 2001 From: jsonbailey Date: Wed, 13 May 2026 16:48:10 -0500 Subject: [PATCH 6/6] chore: Shorten and reposition error-logging caveat comment The three-line caveat above each top-level catch-and-log is now a single line directly above the print call, which keeps the security note tied to the actual logging statement rather than to the except clause. Co-Authored-By: Claude Opus 4.7 (1M context) --- features/create_agent/create_agent_example.py | 4 +--- features/create_agent_graph/create_agent_graph_example.py | 4 +--- features/create_judge/create_judge_example.py | 4 +--- features/create_model/create_model_example.py | 4 +--- getting_started/langchain/invoke/langchain_example.py | 4 +--- .../langgraph/react_agent/langgraph_agent_example.py | 4 +--- .../state_graph/langgraph_multi_agent_example.py | 8 ++------ 7 files changed, 8 insertions(+), 24 deletions(-) diff --git a/features/create_agent/create_agent_example.py b/features/create_agent/create_agent_example.py index 418594d..43d6c99 100644 --- a/features/create_agent/create_agent_example.py +++ b/features/create_agent/create_agent_example.py @@ -109,10 +109,8 @@ async def async_main(): else: print("\nNo judge evaluations were performed.") - # For convenience during example debugging, we print the raw error. In - # production, sanitize errors before logging — provider responses may - # include credentials or other sensitive data. except Exception as err: + # In production, sanitize before logging — provider errors may include credentials. print("Error:", err) finally: # Flush pending events and close the client. diff --git a/features/create_agent_graph/create_agent_graph_example.py b/features/create_agent_graph/create_agent_graph_example.py index 63b453b..5ada8a0 100644 --- a/features/create_agent_graph/create_agent_graph_example.py +++ b/features/create_agent_graph/create_agent_graph_example.py @@ -127,10 +127,8 @@ async def async_main(): print(f" score: {eval_result.score}") print(f" reasoning: {eval_result.reasoning}") - # For convenience during example debugging, we print the raw error. In - # production, sanitize errors before logging — provider responses may - # include credentials or other sensitive data. except Exception as err: + # In production, sanitize before logging — provider errors may include credentials. print("Error:", err) finally: # Flush pending events and close the client. diff --git a/features/create_judge/create_judge_example.py b/features/create_judge/create_judge_example.py index de82844..c188506 100644 --- a/features/create_judge/create_judge_example.py +++ b/features/create_judge/create_judge_example.py @@ -94,10 +94,8 @@ async def async_main(): print(f" reasoning: {judge_result.reasoning}") print("\nDone!") - # For convenience during example debugging, we print the raw error. In - # production, sanitize errors before logging — provider responses may - # include credentials or other sensitive data. except Exception as err: + # In production, sanitize before logging — provider errors may include credentials. print("Error:", err) finally: # Flush pending events and close the client. diff --git a/features/create_model/create_model_example.py b/features/create_model/create_model_example.py index adb2503..e044e90 100644 --- a/features/create_model/create_model_example.py +++ b/features/create_model/create_model_example.py @@ -95,10 +95,8 @@ async def async_main(): else: print("\nNo judge evaluations were performed. Try adding a judge to the AI config to see results.") - # For convenience during example debugging, we print the raw error. In - # production, sanitize errors before logging — provider responses may - # include credentials or other sensitive data. except Exception as err: + # In production, sanitize before logging — provider errors may include credentials. print("Error:", err) finally: # Flush pending events and close the client. diff --git a/getting_started/langchain/invoke/langchain_example.py b/getting_started/langchain/invoke/langchain_example.py index a9ae36a..3b763d2 100644 --- a/getting_started/langchain/invoke/langchain_example.py +++ b/getting_started/langchain/invoke/langchain_example.py @@ -118,10 +118,8 @@ async def async_main(): if summary.tool_calls: print(f" Tool calls: {', '.join(summary.tool_calls)}") - # For convenience during example debugging, we print the raw error. In - # production, sanitize errors before logging — provider responses may - # include credentials or other sensitive data. except Exception as e: + # In production, sanitize before logging — provider errors may include credentials. print(f"Error during completion: {e}") print("Please ensure you have the correct API keys and credentials set up for the detected provider.") diff --git a/getting_started/langgraph/react_agent/langgraph_agent_example.py b/getting_started/langgraph/react_agent/langgraph_agent_example.py index 85dfd93..0244865 100644 --- a/getting_started/langgraph/react_agent/langgraph_agent_example.py +++ b/getting_started/langgraph/react_agent/langgraph_agent_example.py @@ -121,10 +121,8 @@ def main(): if summary.tool_calls: print(f" Tool calls: {', '.join(summary.tool_calls)}") - # For convenience during example debugging, we print the raw error. In - # production, sanitize errors before logging — provider responses may - # include credentials or other sensitive data. except Exception as e: + # In production, sanitize before logging — provider errors may include credentials. print(f"\nError: {e}") print("Please ensure you have the correct API keys and credentials set up for the detected providers.") diff --git a/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py b/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py index 7721244..b2b1691 100644 --- a/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py +++ b/getting_started/langgraph/state_graph/langgraph_multi_agent_example.py @@ -147,10 +147,8 @@ def ai_node( } ) - # For convenience during example debugging, we print the raw error. In - # production, sanitize errors before logging — provider responses may - # include credentials or other sensitive data. except Exception as e: + # In production, sanitize before logging — provider errors may include credentials. print(f"Error in node for {config_key}: {e}") return Command( goto=END, @@ -281,10 +279,8 @@ def calculate_average(numbers): print(final_report) print("="*80) - # For convenience during example debugging, we print the raw error. In - # production, sanitize errors before logging — provider responses may - # include credentials or other sensitive data. except Exception as e: + # In production, sanitize before logging — provider errors may include credentials. print(f"Error during workflow execution: {e}") print("Please ensure you have the correct API keys and credentials set up for the detected providers.")