Skip to content

Commit 050cc71

Browse files
author
Dan O'Brien
authored
fix: Update how prompt is handled (#12)
* Change how the prompt is returned as part of AI Config.
2 parents 2ec9b31 + ffc2b31 commit 050cc71

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

ldai/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
from typing import Any, Dict, List, Literal, Optional
33

44
import chevron
5+
from dataclasses_json import dataclass_json
56
from ldclient import Context
67
from ldclient.client import LDClient
78

89
from ldai.tracker import LDAIConfigTracker
910

1011

12+
@dataclass_json
1113
@dataclass
1214
class LDMessage:
1315
role: Literal['system', 'user', 'assistant']
@@ -59,7 +61,7 @@ def model_config(
5961
if isinstance(variation['prompt'], list) and all(
6062
isinstance(entry, dict) for entry in variation['prompt']
6163
):
62-
variation['prompt'] = [
64+
prompt = [
6365
LDMessage(
6466
role=entry['role'],
6567
content=self.__interpolate_template(
@@ -71,7 +73,7 @@ def model_config(
7173

7274
enabled = variation.get('_ldMeta', {}).get('enabled', False)
7375
return AIConfig(
74-
config=AIConfigData(model=variation['model'], prompt=variation['prompt']),
76+
config=AIConfigData(model=variation['model'], prompt=prompt),
7577
tracker=LDAIConfigTracker(
7678
self.client,
7779
variation.get('_ldMeta', {}).get('versionKey', ''),

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ exclude = [
2727
]
2828

2929
[tool.poetry.dependencies]
30-
python = ">=3.8"
30+
python = ">=3.8,<4"
3131
launchdarkly-server-sdk = ">=9.4.0"
3232
chevron = "=0.14.0"
3333
pycodestyle = "^2.12.1"
3434
isort = "^5.13.2"
35+
dataclasses-json = "^0.6.7"
3536

3637

3738
[tool.poetry.group.dev.dependencies]

0 commit comments

Comments
 (0)