This example demonstrates how to use LaunchDarkly's AI Config with LangChain, supporting multiple providers including OpenAI, Bedrock, and Gemini. You can add additional LangChain providers using the poetry add command.
- Python 3.10 or higher
- Poetry installed
- A LaunchDarkly account and SDK key
- API keys for the providers you want to use
-
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 with a model and a system message. Default key:
sample-completion-config.
- Create an AI Config with a model and a system message. Default key:
-
Create a
.envfile in this directory with the following variables:LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key LAUNCHDARKLY_AI_CONFIG_KEY=sample-completion-configAdd 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 -
Install the required dependencies:
poetry install
poetry run langchain