Skip to content

chore: Align example config keys and env vars with new naming#29

Open
jsonbailey wants to merge 6 commits into
mainfrom
jb/aic-2383/align-python-examples
Open

chore: Align example config keys and env vars with new naming#29
jsonbailey wants to merge 6 commits into
mainfrom
jb/aic-2383/align-python-examples

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

Summary

Back-port of the naming changes landed in js-core PR #1379 (launchdarkly/js-core#1379). Drops the _CONFIG_KEY env-var suffix and the trailing -config / -ai- on the default AI Config keys so the names are consistent and concise across SDKs.

Old env var Old default -> New env var New default
LAUNCHDARKLY_AI_CONFIG_KEY sample-completion-config LAUNCHDARKLY_COMPLETION_KEY sample-completion
LAUNCHDARKLY_AGENT_CONFIG_KEY sample-agent-config LAUNCHDARKLY_AGENT_KEY sample-agent
LAUNCHDARKLY_AI_JUDGE_KEY sample-ai-judge LAUNCHDARKLY_JUDGE_KEY sample-judge
LAUNCHDARKLY_ANALYZER_CONFIG_KEY code-review-analyzer LAUNCHDARKLY_ANALYZER_KEY unchanged
LAUNCHDARKLY_DOCUMENTATION_CONFIG_KEY code-review-documentation LAUNCHDARKLY_DOCUMENTATION_KEY unchanged

LAUNCHDARKLY_AGENT_GRAPH_KEY / sample-agent-graph were already aligned and are unchanged.

Also adds a .env.example to each of the 10 example directories — the repo uses python-dotenv but didn't ship samples. Each .env.example lists only the env vars the example actually reads.

Test plan

  • poetry run openai-example runs end-to-end against an AI Config and prints the metric summary

jsonbailey and others added 2 commits May 13, 2026 12:39
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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
@jsonbailey jsonbailey marked this pull request as ready for review May 13, 2026 18:20
@jsonbailey jsonbailey requested a review from a team as a code owner May 13, 2026 18:20
jsonbailey and others added 4 commits May 13, 2026 13:30
…nv 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) <noreply@anthropic.com>
…mple 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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants