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
2 changes: 1 addition & 1 deletion ldai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def config(

tracker = LDAIConfigTracker(
self.client,
variation.get('_ldMeta', {}).get('versionKey', ''),
variation.get('_ldMeta', {}).get('variationKey', ''),
key,
context,
)
Expand Down
10 changes: 5 additions & 5 deletions ldai/testing/test_model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def td() -> TestData:
'model': {'name': 'fakeModel', 'parameters': {'temperature': 0.5, 'maxTokens': 4096}, 'custom': {'extra-attribute': 'value'}},
'provider': {'name': 'fakeProvider'},
'messages': [{'role': 'system', 'content': 'Hello, {{name}}!'}],
'_ldMeta': {'enabled': True, 'versionKey': 'abcd'},
'_ldMeta': {'enabled': True, 'variationKey': 'abcd'},
},
"green",
)
Expand All @@ -31,7 +31,7 @@ def td() -> TestData:
{'role': 'system', 'content': 'Hello, {{name}}!'},
{'role': 'user', 'content': 'The day is, {{day}}!'},
],
'_ldMeta': {'enabled': True, 'versionKey': 'abcd'},
'_ldMeta': {'enabled': True, 'variationKey': 'abcd'},
},
"green",
)
Expand All @@ -44,7 +44,7 @@ def td() -> TestData:
{
'model': {'name': 'fakeModel', 'parameters': {'extra-attribute': 'I can be anything I set my mind/type to'}},
'messages': [{'role': 'system', 'content': 'Hello, {{ldctx.name}}! Is your last name {{ldctx.last}}?'}],
'_ldMeta': {'enabled': True, 'versionKey': 'abcd'},
'_ldMeta': {'enabled': True, 'variationKey': 'abcd'},
}
)
.variation_for_all(0)
Expand All @@ -56,7 +56,7 @@ def td() -> TestData:
{
'model': {'name': 'fakeModel', 'parameters': {'extra-attribute': 'I can be anything I set my mind/type to'}},
'messages': [{'role': 'system', 'content': 'Hello, {{ldctx.user.name}}! Do you work for {{ldctx.org.shortname}}?'}],
'_ldMeta': {'enabled': True, 'versionKey': 'abcd'},
'_ldMeta': {'enabled': True, 'variationKey': 'abcd'},
}
)
.variation_for_all(0)
Expand All @@ -68,7 +68,7 @@ def td() -> TestData:
{
'model': {'name': 'fakeModel', 'parameters': {'temperature': 0.1}},
'messages': [{'role': 'system', 'content': 'Hello, {{name}}!'}],
'_ldMeta': {'enabled': False, 'versionKey': 'abcd'},
'_ldMeta': {'enabled': False, 'variationKey': 'abcd'},
}
)
.variation_for_all(0)
Expand Down
10 changes: 5 additions & 5 deletions ldai/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,29 +137,29 @@ class LDAIConfigTracker:
"""

def __init__(
self, ld_client: LDClient, version_key: str, config_key: str, context: Context
self, ld_client: LDClient, variation_key: str, config_key: str, context: Context
):
"""
Initialize an AI configuration tracker.

:param ld_client: LaunchDarkly client instance.
:param version_key: Version key for tracking.
:param variation_key: Variation key for tracking.
:param config_key: Configuration key for tracking.
:param context: Context for evaluation.
"""
self.ld_client = ld_client
self.version_key = version_key
self.variation_key = variation_key
self.config_key = config_key
self.context = context

def __get_track_data(self):
"""
Get tracking data for events.

:return: Dictionary containing version and config keys.
:return: Dictionary containing variation and config keys.
"""
return {
'versionKey': self.version_key,
'variationKey': self.variation_key,
'configKey': self.config_key,
}

Expand Down
Loading