22from ldclient import Config , Context , LDClient
33from ldclient .integrations .test_data import TestData
44
5- from ldai import (LDAIAgentConfig , LDAIAgentDefaults , LDAIClient , ModelConfig ,
6- ProviderConfig )
5+ from ldai import (
6+ LDAIAgentConfig ,
7+ LDAIAgentDefaults ,
8+ LDAIClient ,
9+ ModelConfig ,
10+ ProviderConfig ,
11+ )
712
813
914@pytest .fixture
@@ -17,7 +22,10 @@ def td() -> TestData:
1722 {
1823 'model' : {'name' : 'gpt-4' , 'parameters' : {'temperature' : 0.3 , 'maxTokens' : 2048 }},
1924 'provider' : {'name' : 'openai' },
20- 'instructions' : 'You are a helpful customer support agent for {{company_name}}. Always be polite and professional.' ,
25+ 'instructions' : (
26+ 'You are a helpful customer support agent for {{company_name}}.'
27+ ' Always be polite and professional.'
28+ ),
2129 '_ldMeta' : {'enabled' : True , 'variationKey' : 'agent-v1' , 'version' : 1 , 'mode' : 'agent' },
2230 }
2331 )
@@ -30,7 +38,10 @@ def td() -> TestData:
3038 .variations (
3139 {
3240 'model' : {'name' : 'claude-3' , 'parameters' : {'temperature' : 0.5 }},
33- 'instructions' : 'Hello {{ldctx.name}}! I am your personal assistant. Your user key is {{ldctx.key}}.' ,
41+ 'instructions' : (
42+ 'Hello {{ldctx.name}}! I am your personal assistant.'
43+ ' Your user key is {{ldctx.key}}.'
44+ ),
3445 '_ldMeta' : {'enabled' : True , 'variationKey' : 'personal-v1' , 'version' : 2 , 'mode' : 'agent' },
3546 }
3647 )
@@ -43,7 +54,10 @@ def td() -> TestData:
4354 .variations (
4455 {
4556 'model' : {'name' : 'gpt-3.5-turbo' },
46- 'instructions' : 'Welcome {{ldctx.user.name}} from {{ldctx.org.name}}! Your organization tier is {{ldctx.org.tier}}.' ,
57+ 'instructions' : (
58+ 'Welcome {{ldctx.user.name}} from {{ldctx.org.name}}!'
59+ ' Your organization tier is {{ldctx.org.tier}}.'
60+ ),
4761 '_ldMeta' : {'enabled' : True , 'variationKey' : 'multi-v1' , 'version' : 1 , 'mode' : 'agent' },
4862 }
4963 )
@@ -82,7 +96,10 @@ def td() -> TestData:
8296 {
8397 'model' : {'name' : 'gpt-4' , 'parameters' : {'temperature' : 0.7 }},
8498 'provider' : {'name' : 'openai' },
85- 'instructions' : 'You are a sales assistant for {{company_name}}. Help customers find the right products.' ,
99+ 'instructions' : (
100+ 'You are a sales assistant for {{company_name}}.'
101+ ' Help customers find the right products.'
102+ ),
86103 '_ldMeta' : {'enabled' : True , 'variationKey' : 'sales-v1' , 'version' : 1 , 'mode' : 'agent' },
87104 }
88105 )
@@ -96,7 +113,10 @@ def td() -> TestData:
96113 {
97114 'model' : {'name' : 'gpt-4' , 'parameters' : {'temperature' : 0.2 , 'maxTokens' : 3000 }},
98115 'provider' : {'name' : 'openai' },
99- 'instructions' : 'You are a research assistant specializing in {{topic}}. Your expertise level should match {{ldctx.expertise}}.' ,
116+ 'instructions' : (
117+ 'You are a research assistant specializing in {{topic}}.'
118+ ' Your expertise level should match {{ldctx.expertise}}.'
119+ ),
100120 '_ldMeta' : {'enabled' : True , 'variationKey' : 'research-v1' , 'version' : 1 , 'mode' : 'agent' },
101121 }
102122 )
@@ -139,7 +159,10 @@ def test_single_agent_method(ldai_client: LDAIClient):
139159 assert agent .model .get_parameter ('maxTokens' ) == 3000
140160 assert agent .provider is not None
141161 assert agent .provider .name == 'openai'
142- assert agent .instructions == 'You are a research assistant specializing in quantum computing. Your expertise level should match advanced.'
162+ assert agent .instructions == (
163+ 'You are a research assistant specializing in quantum computing.'
164+ ' Your expertise level should match advanced.'
165+ )
143166 assert callable (agent .create_tracker )
144167
145168
@@ -237,7 +260,10 @@ def test_agents_method_different_variables_per_agent(ldai_client: LDAIClient):
237260 assert personal_agent .instructions == 'Hello Alice! I am your personal assistant. Your user key is user-key.'
238261
239262 support_agent = agents ['customer-support-agent' ]
240- assert support_agent .instructions == 'You are a helpful customer support agent for TechStart Inc. Always be polite and professional.'
263+ assert support_agent .instructions == (
264+ 'You are a helpful customer support agent for TechStart Inc.'
265+ ' Always be polite and professional.'
266+ )
241267
242268
243269def test_agents_with_multi_context_interpolation (ldai_client : LDAIClient ):
0 commit comments