Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/ai-providers/server-ai-langchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,18 @@ from ldai_langchain import LangChainProvider
ld_client = LDClient(Config("your-sdk-key"))
ai_client = init(ld_client)

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

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

```python
# Get the AI config with tracker
config = ai_client.config("ai-config-key", context, {})
config = ai_client.config("ai-config-key", context)

# Create provider
provider = await LangChainProvider.create(config)
Expand Down
2 changes: 1 addition & 1 deletion packages/ai-providers/server-ai-langchain/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ packages = [{ include = "ldai_langchain", from = "src" }]

[tool.poetry.dependencies]
python = ">=3.9,<4"
launchdarkly-server-sdk-ai = ">=0.12.0"
launchdarkly-server-sdk-ai = ">=0.16.0"
langchain-core = ">=0.2.0"
langchain = ">=0.2.0"

Expand Down
19 changes: 12 additions & 7 deletions packages/ai-providers/server-ai-openai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ from ldai_openai import OpenAIProvider
async def main():
# Initialize the AI client
ai_client = AIClient(ld_client)

# Get AI config
ai_config = ai_client.config(
"my-ai-config-key",
context,
default
)

# Get AI config. Pass a default for improved resiliency when the flag is unavailable or
# LaunchDarkly is unreachable; omit for a disabled default. Example:
# from ldai.models import AICompletionConfigDefault, LDMessage, ModelConfig, ProviderConfig
# default = AICompletionConfigDefault(
# enabled=True,
# model=ModelConfig("gpt-4"),
# provider=ProviderConfig("openai"),
# messages=[LDMessage(role="system", content="You are a helpful assistant.")]
# )
# ai_config = ai_client.config("my-ai-config-key", context, default)
ai_config = ai_client.config("my-ai-config-key", context)

# Create an OpenAI provider from the config
provider = await OpenAIProvider.create(ai_config)
Expand Down
2 changes: 1 addition & 1 deletion packages/ai-providers/server-ai-openai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ packages = [{ include = "ldai_openai", from = "src" }]

[tool.poetry.dependencies]
python = ">=3.9,<4"
launchdarkly-server-sdk-ai = ">=0.12.0"
launchdarkly-server-sdk-ai = ">=0.16.0"
openai = ">=1.0.0"

[tool.poetry.group.dev.dependencies]
Expand Down