lucidicai 3.4.0__py3-none-any.whl → 3.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lucidicai/__init__.py +1 -1
- lucidicai/api/resources/prompt.py +24 -11
- {lucidicai-3.4.0.dist-info → lucidicai-3.4.1.dist-info}/METADATA +1 -1
- {lucidicai-3.4.0.dist-info → lucidicai-3.4.1.dist-info}/RECORD +6 -6
- {lucidicai-3.4.0.dist-info → lucidicai-3.4.1.dist-info}/WHEEL +0 -0
- {lucidicai-3.4.0.dist-info → lucidicai-3.4.1.dist-info}/top_level.txt +0 -0
lucidicai/__init__.py
CHANGED
|
@@ -23,6 +23,24 @@ class Prompt:
|
|
|
23
23
|
def __str__(self) -> str:
|
|
24
24
|
return self.content
|
|
25
25
|
|
|
26
|
+
def replace_variables(self, variables: Dict[str, Any]) -> "Prompt":
|
|
27
|
+
"""Replace template variables in the prompt content.
|
|
28
|
+
|
|
29
|
+
Replaces {{key}} placeholders in raw_content with the provided
|
|
30
|
+
variable values and updates content.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
variables: Dictionary mapping variable names to their values.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
self, for method chaining.
|
|
37
|
+
"""
|
|
38
|
+
content = self.raw_content
|
|
39
|
+
for key, value in variables.items():
|
|
40
|
+
content = content.replace(f"{{{{{key}}}}}", str(value))
|
|
41
|
+
self.content = content
|
|
42
|
+
return self
|
|
43
|
+
|
|
26
44
|
|
|
27
45
|
class PromptResource:
|
|
28
46
|
"""Handle prompt-related API operations."""
|
|
@@ -102,13 +120,10 @@ class PromptResource:
|
|
|
102
120
|
"timestamp": time.time(),
|
|
103
121
|
}
|
|
104
122
|
|
|
105
|
-
|
|
106
|
-
content = raw_content
|
|
123
|
+
prompt = Prompt(raw_content=raw_content, content=raw_content, metadata=metadata)
|
|
107
124
|
if variables:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return Prompt(raw_content=raw_content, content=content, metadata=metadata)
|
|
125
|
+
prompt.replace_variables(variables)
|
|
126
|
+
return prompt
|
|
112
127
|
except Exception as e:
|
|
113
128
|
if self._production:
|
|
114
129
|
logger.error(f"[PromptResource] Failed to get prompt: {e}")
|
|
@@ -149,12 +164,10 @@ class PromptResource:
|
|
|
149
164
|
"timestamp": time.time(),
|
|
150
165
|
}
|
|
151
166
|
|
|
152
|
-
|
|
167
|
+
prompt = Prompt(raw_content=raw_content, content=raw_content, metadata=metadata)
|
|
153
168
|
if variables:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return Prompt(raw_content=raw_content, content=content, metadata=metadata)
|
|
169
|
+
prompt.replace_variables(variables)
|
|
170
|
+
return prompt
|
|
158
171
|
except Exception as e:
|
|
159
172
|
if self._production:
|
|
160
173
|
logger.error(f"[PromptResource] Failed to get prompt: {e}")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
lucidicai/__init__.py,sha256=
|
|
1
|
+
lucidicai/__init__.py,sha256=d0jiR0fpY1JbmHuczLu7sni-Qk9zZXe5M8zHxURe4RA,1376
|
|
2
2
|
lucidicai/action.py,sha256=sPRd1hTIVXDqnvG9ZXWEipUFh0bsXcE0Fm7RVqmVccM,237
|
|
3
3
|
lucidicai/client.py,sha256=BGKP91_Oj5kHQU0osYf1T_BWakL8KIhs0AgUc5X99sU,15104
|
|
4
4
|
lucidicai/constants.py,sha256=zN8O7TjoRHRlaGa9CZUWppS73rhzKGwaEkF9XMTV0Cg,1160
|
|
@@ -26,7 +26,7 @@ lucidicai/api/resources/evals.py,sha256=_3nLE6dMLht844mWw7kl_hctjv5JIuC6MP06YWUg
|
|
|
26
26
|
lucidicai/api/resources/event.py,sha256=GTIU5sIbLNTWAHk4rB120xWTRkhnraz9JNfamEygyNo,14267
|
|
27
27
|
lucidicai/api/resources/experiment.py,sha256=fOIKJ5d89bHJBVZ3wjbhY_6XF3kLHz9TE3BVPA5pNpA,3563
|
|
28
28
|
lucidicai/api/resources/feature_flag.py,sha256=ii412DIkZCEAhrXdGydcpQKveqGlFq4NlgdmWQnU83c,2259
|
|
29
|
-
lucidicai/api/resources/prompt.py,sha256=
|
|
29
|
+
lucidicai/api/resources/prompt.py,sha256=M2ZovMX74-ULksMXzXPXVgBziRcTcmz40GnDcJx30Q0,6053
|
|
30
30
|
lucidicai/api/resources/session.py,sha256=jW_bftHdunhLHl_3-k0nqB5FrtLhlFeCF0tMFE82nNw,20761
|
|
31
31
|
lucidicai/core/__init__.py,sha256=b0YQkd8190Y_GgwUcmf0tOiSLARd7L4kq4jwfhhGAyI,39
|
|
32
32
|
lucidicai/core/config.py,sha256=q4h-yR35Ay_3znL7vavri6ScfeM69RjHShNNzjoQthc,10194
|
|
@@ -93,7 +93,7 @@ lucidicai/utils/images.py,sha256=z8mlIKgFfrIbuk-l4L2rB62uw_uPO79sHPXPY7eLu2A,128
|
|
|
93
93
|
lucidicai/utils/logger.py,sha256=R3B3gSee64F6UVHUrShihBq_O7W7bgfrBiVDXTO3Isg,4777
|
|
94
94
|
lucidicai/utils/queue.py,sha256=8DQwnGw7pINEJ0dNSkB0PhdPW-iBQQ-YZg23poe4umE,17323
|
|
95
95
|
lucidicai/utils/serialization.py,sha256=KdOREZd7XBxFBAZ86DePMfYPzSVyKr4RcgUa82aFxrs,820
|
|
96
|
-
lucidicai-3.4.
|
|
97
|
-
lucidicai-3.4.
|
|
98
|
-
lucidicai-3.4.
|
|
99
|
-
lucidicai-3.4.
|
|
96
|
+
lucidicai-3.4.1.dist-info/METADATA,sha256=oPV8Sh8GPs876yl42Vk7ZyAe2HyD8NW9K_jxO1p8kf4,902
|
|
97
|
+
lucidicai-3.4.1.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
|
98
|
+
lucidicai-3.4.1.dist-info/top_level.txt,sha256=vSSdM3lclF4I5tyVC0xxUk8eIRnnYXMe1hW-eO91HUo,10
|
|
99
|
+
lucidicai-3.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|