11# LaunchDarkly Server-Side AI SDK for Python
22
3+ [ ![ Actions Status] ( https://github.com/launchdarkly/python-server-sdk-ai/actions/workflows/ci.yml/badge.svg?branch=main )] ( https://github.com/launchdarkly/python-server-sdk-ai/actions/workflows/ci.yml )
4+ [ ![ readthedocs] ( https://readthedocs.org/projects/launchdarkly-python-sdk-ai/badge/ )] ( https://launchdarkly-python-sdk-ai.readthedocs.io/en/latest/ )
5+
6+ [ ![ PyPI] ( https://img.shields.io/pypi/v/launchdarkly-server-sdk-ai.svg?maxAge=2592000 )] ( https://pypi.org/project/launchdarkly-server-sdk-ai/ )
7+ [ ![ PyPI] ( https://img.shields.io/pypi/pyversions/launchdarkly-server-sdk-ai.svg )] ( https://pypi.org/project/launchdarkly-server-sdk-ai/ )
8+
39This package contains the LaunchDarkly Server-Side AI SDK for Python (` launchdarkly-server-sdk-ai ` ).
410
511> [ !CAUTION]
@@ -90,16 +96,16 @@ if ai_config.enabled:
9096 # Use with your AI provider
9197```
9298
93- ## Chat for Conversational AI
99+ ## ManagedModel for Conversational AI
94100
95- ` Chat ` provides a high-level interface for conversational AI with automatic conversation management and metrics tracking:
101+ ` ManagedModel ` provides a high-level interface for conversational AI with automatic conversation management and metrics tracking:
96102
97103- Automatically configures models based on AI configuration
98104- Maintains conversation history across multiple interactions
99105- Automatically tracks token usage, latency, and success rates
100106- Works with any supported AI provider (see [ AI Providers] ( https://github.com/launchdarkly/python-server-sdk-ai#ai-providers ) for available packages)
101107
102- ### Using Chat
108+ ### Using ManagedModel
103109
104110``` python
105111import asyncio
@@ -109,23 +115,23 @@ from ldai import LDAIClient, AICompletionConfigDefault, ModelConfig, LDMessage
109115# Use the same default_config from the retrieval section above
110116async def main ():
111117 context = Context.create(" user-123" )
112- chat = await ai_client.create_chat (
118+ model = await ai_client.create_model (
113119 ' customer-support-chat' ,
114120 context,
115121 default_config,
116122 variables = {' customerName' : ' John' }
117123 )
118124
119- if chat :
125+ if model :
120126 # Simple conversation flow - metrics are automatically tracked by invoke()
121- response1 = await chat .invoke(' I need help with my order' )
127+ response1 = await model .invoke(' I need help with my order' )
122128 print (response1.message.content)
123129
124- response2 = await chat .invoke(" What's the status?" )
130+ response2 = await model .invoke(" What's the status?" )
125131 print (response2.message.content)
126132
127133 # Access conversation history
128- messages = chat .get_messages()
134+ messages = model .get_messages()
129135 print (f ' Conversation has { len (messages)} messages ' )
130136
131137asyncio.run(main())
0 commit comments