Skip to content

Commit 4b8a667

Browse files
committed
chore: Update comments for setting default
1 parent 39e09c6 commit 4b8a667

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

packages/ai-providers/server-ai-langchain/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,18 @@ from ldai_langchain import LangChainProvider
4141
ld_client = LDClient(Config("your-sdk-key"))
4242
ai_client = init(ld_client)
4343

44-
# Get AI configuration
44+
# Get AI configuration. Pass a default for improved resiliency when the flag is unavailable or
45+
# LaunchDarkly is unreachable; omit for a disabled default. Example:
46+
# from ldai.models import AICompletionConfigDefault, LDMessage, ModelConfig, ProviderConfig
47+
# default = AICompletionConfigDefault(
48+
# enabled=True,
49+
# model=ModelConfig("gpt-4"),
50+
# provider=ProviderConfig("openai"),
51+
# messages=[LDMessage(role="system", content="You are a helpful assistant.")]
52+
# )
53+
# config = ai_client.config("ai-config-key", context, default)
4554
context = Context.builder("user-123").build()
46-
config = ai_client.config("ai-config-key", context, {})
55+
config = ai_client.config("ai-config-key", context)
4756

4857
async def main():
4958
# Create a LangChain provider from the AI configuration
@@ -120,7 +129,7 @@ Use the provider with LaunchDarkly's tracking capabilities:
120129

121130
```python
122131
# Get the AI config with tracker
123-
config = ai_client.config("ai-config-key", context, {})
132+
config = ai_client.config("ai-config-key", context)
124133

125134
# Create provider
126135
provider = await LangChainProvider.create(config)

packages/ai-providers/server-ai-openai/README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ from ldai_openai import OpenAIProvider
2626
async def main():
2727
# Initialize the AI client
2828
ai_client = AIClient(ld_client)
29-
30-
# Get AI config
31-
ai_config = ai_client.config(
32-
"my-ai-config-key",
33-
context,
34-
default
35-
)
29+
30+
# Get AI config. Pass a default for improved resiliency when the flag is unavailable or
31+
# LaunchDarkly is unreachable; omit for a disabled default. Example:
32+
# from ldai.models import AICompletionConfigDefault, LDMessage, ModelConfig, ProviderConfig
33+
# default = AICompletionConfigDefault(
34+
# enabled=True,
35+
# model=ModelConfig("gpt-4"),
36+
# provider=ProviderConfig("openai"),
37+
# messages=[LDMessage(role="system", content="You are a helpful assistant.")]
38+
# )
39+
# ai_config = ai_client.config("my-ai-config-key", context, default)
40+
ai_config = ai_client.config("my-ai-config-key", context)
3641

3742
# Create an OpenAI provider from the config
3843
provider = await OpenAIProvider.create(ai_config)

0 commit comments

Comments
 (0)