Skip to content

Commit b0e70b1

Browse files
committed
fix!: Rename default_value args to default
1 parent e15082a commit b0e70b1

7 files changed

Lines changed: 88 additions & 96 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def main():
3131
ai_config = ai_client.config(
3232
"my-ai-config-key",
3333
context,
34-
default_value
34+
default
3535
)
3636

3737
# Create an OpenAI provider from the config

packages/sdk/server-ai/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ from ldai.providers.types import LDAIMetrics, TokenUsage
145145
from ldai_langchain import LangChainProvider
146146

147147
async def main():
148-
ai_config = ai_client.completion_config(ai_config_key, context, default_value)
148+
ai_config = ai_client.completion_config(ai_config_key, context, default)
149149

150150
# Create LangChain model from configuration
151151
llm = await LangChainProvider.create_langchain_model(ai_config)
@@ -169,7 +169,7 @@ from ldai import LDAIClient, AICompletionConfigDefault, ModelConfig
169169
from ldai.providers.types import LDAIMetrics, TokenUsage
170170

171171
async def main():
172-
ai_config = ai_client.completion_config(ai_config_key, context, default_value)
172+
ai_config = ai_client.completion_config(ai_config_key, context, default)
173173

174174
# Define custom metrics mapping for your provider
175175
def map_custom_provider_metrics(response):

packages/sdk/server-ai/src/ldai/client.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def _completion_config(
4949
self,
5050
key: str,
5151
context: Context,
52-
default_value: AICompletionConfigDefault,
52+
default: AICompletionConfigDefault,
5353
variables: Optional[Dict[str, Any]] = None,
5454
) -> AICompletionConfig:
5555
model, provider, messages, instructions, tracker, enabled, judge_configuration, _ = self.__evaluate(
56-
key, context, default_value.to_dict(), variables
56+
key, context, default.to_dict(), variables
5757
)
5858

5959
config = AICompletionConfig(
@@ -72,30 +72,30 @@ def completion_config(
7272
self,
7373
key: str,
7474
context: Context,
75-
default_value: Optional[AICompletionConfigDefault] = None,
75+
default: Optional[AICompletionConfigDefault] = None,
7676
variables: Optional[Dict[str, Any]] = None,
7777
) -> AICompletionConfig:
7878
"""
7979
Get the value of a completion configuration.
8080
8181
:param key: The key of the completion configuration.
8282
:param context: The context to evaluate the completion configuration in.
83-
:param default_value: The default value of the completion configuration. When not provided,
83+
:param default: The default value of the completion configuration. When not provided,
8484
a disabled config is used as the fallback.
8585
:param variables: Additional variables for the completion configuration.
8686
:return: The completion configuration with a tracker used for gathering metrics.
8787
"""
8888
self._client.track(_TRACK_USAGE_COMPLETION_CONFIG, context, key, 1)
8989

9090
return self._completion_config(
91-
key, context, default_value or AICompletionConfigDefault.disabled(), variables
91+
key, context, default or AICompletionConfigDefault.disabled(), variables
9292
)
9393

9494
def config(
9595
self,
9696
key: str,
9797
context: Context,
98-
default_value: Optional[AICompletionConfigDefault] = None,
98+
default: Optional[AICompletionConfigDefault] = None,
9999
variables: Optional[Dict[str, Any]] = None,
100100
) -> AICompletionConfig:
101101
"""
@@ -105,21 +105,21 @@ def config(
105105
106106
:param key: The key of the model configuration.
107107
:param context: The context to evaluate the model configuration in.
108-
:param default_value: The default value of the model configuration.
108+
:param default: The default value of the model configuration.
109109
:param variables: Additional variables for the model configuration.
110110
:return: The value of the model configuration along with a tracker used for gathering metrics.
111111
"""
112-
return self.completion_config(key, context, default_value, variables)
112+
return self.completion_config(key, context, default, variables)
113113

114114
def _judge_config(
115115
self,
116116
key: str,
117117
context: Context,
118-
default_value: AIJudgeConfigDefault,
118+
default: AIJudgeConfigDefault,
119119
variables: Optional[Dict[str, Any]] = None,
120120
) -> AIJudgeConfig:
121121
model, provider, messages, instructions, tracker, enabled, judge_configuration, variation = self.__evaluate(
122-
key, context, default_value.to_dict(), variables
122+
key, context, default.to_dict(), variables
123123
)
124124

125125
def _extract_evaluation_metric_key(variation: Dict[str, Any]) -> Optional[str]:
@@ -155,30 +155,30 @@ def judge_config(
155155
self,
156156
key: str,
157157
context: Context,
158-
default_value: Optional[AIJudgeConfigDefault] = None,
158+
default: Optional[AIJudgeConfigDefault] = None,
159159
variables: Optional[Dict[str, Any]] = None,
160160
) -> AIJudgeConfig:
161161
"""
162162
Get the value of a judge configuration.
163163
164164
:param key: The key of the judge configuration.
165165
:param context: The context to evaluate the judge configuration in.
166-
:param default_value: The default value of the judge configuration. When not provided,
166+
:param default: The default value of the judge configuration. When not provided,
167167
a disabled config is used as the fallback.
168168
:param variables: Additional variables for the judge configuration.
169169
:return: The judge configuration with a tracker used for gathering metrics.
170170
"""
171171
self._client.track(_TRACK_USAGE_JUDGE_CONFIG, context, key, 1)
172172

173173
return self._judge_config(
174-
key, context, default_value or AIJudgeConfigDefault.disabled(), variables
174+
key, context, default or AIJudgeConfigDefault.disabled(), variables
175175
)
176176

177177
async def create_judge(
178178
self,
179179
key: str,
180180
context: Context,
181-
default_value: Optional[AIJudgeConfigDefault] = None,
181+
default: Optional[AIJudgeConfigDefault] = None,
182182
variables: Optional[Dict[str, Any]] = None,
183183
default_ai_provider: Optional[str] = None,
184184
) -> Optional[Judge]:
@@ -187,7 +187,7 @@ async def create_judge(
187187
188188
:param key: The key identifying the AI judge configuration to use
189189
:param context: Standard Context used when evaluating flags
190-
:param default_value: A default value representing a standard AI config result
190+
:param default: A default value representing a standard AI config result
191191
:param variables: Dictionary of values for instruction interpolation.
192192
The variables `message_history` and `response_to_evaluate` are reserved for the judge and will be ignored.
193193
:param default_ai_provider: Optional default AI provider to use.
@@ -229,7 +229,7 @@ async def create_judge(
229229
extended_variables['response_to_evaluate'] = '{{response_to_evaluate}}'
230230

231231
judge_config = self._judge_config(
232-
key, context, default_value or AIJudgeConfigDefault.disabled(), extended_variables
232+
key, context, default or AIJudgeConfigDefault.disabled(), extended_variables
233233
)
234234

235235
if not judge_config.enabled or not judge_config.tracker:
@@ -292,7 +292,7 @@ async def create_chat(
292292
self,
293293
key: str,
294294
context: Context,
295-
default_value: AICompletionConfigDefault,
295+
default: AICompletionConfigDefault,
296296
variables: Optional[Dict[str, Any]] = None,
297297
default_ai_provider: Optional[str] = None,
298298
) -> Optional[Chat]:
@@ -301,7 +301,7 @@ async def create_chat(
301301
302302
:param key: The key identifying the AI completion configuration to use
303303
:param context: Standard Context used when evaluating flags
304-
:param default_value: A default value representing a standard AI config result
304+
:param default: A default value representing a standard AI config result
305305
:param variables: Dictionary of values for instruction interpolation
306306
:param default_ai_provider: Optional default AI provider to use
307307
:return: Chat instance or None if disabled/unsupported
@@ -330,7 +330,7 @@ async def create_chat(
330330
"""
331331
self._client.track(_TRACK_USAGE_CREATE_CHAT, context, key, 1)
332332
log.debug(f"Creating chat for key: {key}")
333-
config = self._completion_config(key, context, default_value, variables)
333+
config = self._completion_config(key, context, default, variables)
334334

335335
if not config.enabled or not config.tracker:
336336
return None
@@ -354,7 +354,7 @@ def agent_config(
354354
self,
355355
key: str,
356356
context: Context,
357-
default_value: Optional[AIAgentConfigDefault] = None,
357+
default: Optional[AIAgentConfigDefault] = None,
358358
variables: Optional[Dict[str, Any]] = None,
359359
) -> AIAgentConfig:
360360
"""
@@ -382,7 +382,7 @@ def agent_config(
382382
383383
:param key: The agent configuration key.
384384
:param context: The context to evaluate the agent configuration in.
385-
:param default_value: Default agent values. When not provided, a disabled config is used
385+
:param default: Default agent values. When not provided, a disabled config is used
386386
as the fallback.
387387
:param variables: Variables for interpolation.
388388
:return: Configured AIAgentConfig instance.
@@ -395,7 +395,7 @@ def agent_config(
395395
)
396396

397397
return self.__evaluate_agent(
398-
key, context, default_value or AIAgentConfigDefault.disabled(), variables
398+
key, context, default or AIAgentConfigDefault.disabled(), variables
399399
)
400400

401401
def agent(
@@ -412,7 +412,7 @@ def agent(
412412
:param context: The context to evaluate the agent configuration in.
413413
:return: Configured AIAgentConfig instance.
414414
"""
415-
return self.agent_config(config.key, context, config.default_value, config.variables)
415+
return self.agent_config(config.key, context, config.default, config.variables)
416416

417417
def agent_configs(
418418
self,
@@ -431,15 +431,15 @@ def agent_configs(
431431
agents = client.agent_configs([
432432
AIAgentConfigRequest(
433433
key='research_agent',
434-
default_value=AIAgentConfigDefault(
434+
default=AIAgentConfigDefault(
435435
enabled=True,
436436
instructions='You are a research assistant.'
437437
),
438438
variables={'topic': 'climate change'}
439439
),
440440
AIAgentConfigRequest(
441441
key='writing_agent',
442-
default_value=AIAgentConfigDefault(
442+
default=AIAgentConfigDefault(
443443
enabled=True,
444444
instructions='You are a writing assistant.'
445445
),
@@ -468,7 +468,7 @@ def agent_configs(
468468
agent = self.__evaluate_agent(
469469
config.key,
470470
context,
471-
config.default_value or AIAgentConfigDefault.disabled(),
471+
config.default or AIAgentConfigDefault.disabled(),
472472
config.variables
473473
)
474474
result[config.key] = agent
@@ -676,33 +676,33 @@ def __evaluate_agent(
676676
self,
677677
key: str,
678678
context: Context,
679-
default_value: AIAgentConfigDefault,
679+
default: AIAgentConfigDefault,
680680
variables: Optional[Dict[str, Any]] = None,
681681
) -> AIAgentConfig:
682682
"""
683683
Internal method to evaluate an agent configuration.
684684
685685
:param key: The agent configuration key.
686686
:param context: The evaluation context.
687-
:param default_value: Default agent values.
687+
:param default: Default agent values.
688688
:param variables: Variables for interpolation.
689689
:return: Configured AIAgentConfig instance.
690690
"""
691691
model, provider, messages, instructions, tracker, enabled, judge_configuration, _ = self.__evaluate(
692-
key, context, default_value.to_dict(), variables
692+
key, context, default.to_dict(), variables
693693
)
694694

695695
# For agents, prioritize instructions over messages
696-
final_instructions = instructions if instructions is not None else default_value.instructions
696+
final_instructions = instructions if instructions is not None else default.instructions
697697

698698
return AIAgentConfig(
699699
key=key,
700-
enabled=bool(enabled) if enabled is not None else (default_value.enabled or False),
701-
model=model or default_value.model,
702-
provider=provider or default_value.provider,
700+
enabled=bool(enabled) if enabled is not None else (default.enabled or False),
701+
model=model or default.model,
702+
provider=provider or default.provider,
703703
instructions=final_instructions,
704704
tracker=tracker,
705-
judge_configuration=judge_configuration or default_value.judge_configuration,
705+
judge_configuration=judge_configuration or default.judge_configuration,
706706
)
707707

708708
def __interpolate_template(self, template: str, variables: Dict[str, Any]) -> str:

packages/sdk/server-ai/src/ldai/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ class AIAgentConfigRequest:
342342
Combines agent key with its specific default configuration and variables.
343343
"""
344344
key: str
345-
default_value: Optional[AIAgentConfigDefault] = None
345+
default: Optional[AIAgentConfigDefault] = None
346346
variables: Optional[Dict[str, Any]] = None
347347

348348

0 commit comments

Comments
 (0)