lucidicai 3.3.1__tar.gz → 3.4.1__tar.gz
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-3.3.1 → lucidicai-3.4.1}/PKG-INFO +1 -1
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/__init__.py +6 -1
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/resources/prompt.py +53 -18
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai.egg-info/PKG-INFO +1 -1
- {lucidicai-3.3.1 → lucidicai-3.4.1}/setup.py +1 -1
- {lucidicai-3.3.1 → lucidicai-3.4.1}/README.md +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/__init__.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/client.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/resources/__init__.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/resources/dataset.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/resources/evals.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/resources/event.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/resources/experiment.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/resources/feature_flag.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/api/resources/session.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/client.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/core/__init__.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/core/config.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/core/errors.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/core/types.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/integrations/__init__.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/integrations/livekit.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/__init__.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/context.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/decorators.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/error_boundary.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/event.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/event_builder.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/features/__init__.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/features/dataset.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/features/feature_flag.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/init.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/session.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/sdk/shutdown_manager.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/session_obj.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/__init__.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/context_bridge.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/context_capture_processor.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/extract.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/litellm_bridge.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/lucidic_exporter.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/openai_agents_instrumentor.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/openai_patch.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/openai_uninstrument.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/telemetry_init.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/telemetry_manager.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/utils/__init__.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/utils/model_pricing.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/telemetry/utils/provider.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/utils/__init__.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/utils/logger.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai/utils/serialization.py +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai.egg-info/SOURCES.txt +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai.egg-info/dependency_links.txt +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai.egg-info/requires.txt +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/lucidicai.egg-info/top_level.txt +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/setup.cfg +0 -0
- {lucidicai-3.3.1 → lucidicai-3.4.1}/tests/test_event_creation.py +0 -0
|
@@ -34,11 +34,14 @@ from .core.errors import (
|
|
|
34
34
|
FeatureFlagError,
|
|
35
35
|
)
|
|
36
36
|
|
|
37
|
+
# Prompt object
|
|
38
|
+
from .api.resources.prompt import Prompt
|
|
39
|
+
|
|
37
40
|
# Integrations
|
|
38
41
|
from .integrations.livekit import setup_livekit
|
|
39
42
|
|
|
40
43
|
# Version
|
|
41
|
-
__version__ = "3.
|
|
44
|
+
__version__ = "3.4.1"
|
|
42
45
|
|
|
43
46
|
# All exports
|
|
44
47
|
__all__ = [
|
|
@@ -53,6 +56,8 @@ __all__ = [
|
|
|
53
56
|
"InvalidOperationError",
|
|
54
57
|
"PromptError",
|
|
55
58
|
"FeatureFlagError",
|
|
59
|
+
# Prompt object
|
|
60
|
+
"Prompt",
|
|
56
61
|
# Integrations
|
|
57
62
|
"setup_livekit",
|
|
58
63
|
# Version
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Prompt resource API operations."""
|
|
2
2
|
import logging
|
|
3
3
|
import time
|
|
4
|
+
from dataclasses import dataclass
|
|
4
5
|
from typing import Any, Dict, Optional, Tuple, TYPE_CHECKING
|
|
5
6
|
|
|
6
7
|
from ..client import HttpClient
|
|
@@ -11,6 +12,36 @@ if TYPE_CHECKING:
|
|
|
11
12
|
logger = logging.getLogger("Lucidic")
|
|
12
13
|
|
|
13
14
|
|
|
15
|
+
@dataclass
|
|
16
|
+
class Prompt:
|
|
17
|
+
"""Represents a prompt retrieved from the Lucidic prompt database."""
|
|
18
|
+
|
|
19
|
+
raw_content: str
|
|
20
|
+
content: str
|
|
21
|
+
metadata: Dict[str, Any]
|
|
22
|
+
|
|
23
|
+
def __str__(self) -> str:
|
|
24
|
+
return self.content
|
|
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
|
+
|
|
44
|
+
|
|
14
45
|
class PromptResource:
|
|
15
46
|
"""Handle prompt-related API operations."""
|
|
16
47
|
|
|
@@ -52,7 +83,7 @@ class PromptResource:
|
|
|
52
83
|
variables: Optional[Dict[str, Any]] = None,
|
|
53
84
|
label: str = "production",
|
|
54
85
|
cache_ttl: int = 0,
|
|
55
|
-
) ->
|
|
86
|
+
) -> Prompt:
|
|
56
87
|
"""Get a prompt from the prompt database.
|
|
57
88
|
|
|
58
89
|
Args:
|
|
@@ -63,38 +94,40 @@ class PromptResource:
|
|
|
63
94
|
positive value = seconds before refetching.
|
|
64
95
|
|
|
65
96
|
Returns:
|
|
66
|
-
|
|
97
|
+
A Prompt object with raw_content, content (with variables replaced),
|
|
98
|
+
and metadata. Use str(prompt) for backward-compatible string access.
|
|
67
99
|
"""
|
|
68
100
|
try:
|
|
69
101
|
cache_key = (prompt_name, label)
|
|
70
102
|
|
|
71
103
|
# Check cache
|
|
72
104
|
if self._is_cache_valid(cache_key, cache_ttl):
|
|
73
|
-
|
|
105
|
+
raw_content = self._cache[cache_key]["content"]
|
|
106
|
+
metadata = self._cache[cache_key]["metadata"]
|
|
74
107
|
else:
|
|
75
108
|
response = self.http.get(
|
|
76
109
|
"getprompt",
|
|
77
110
|
{"prompt_name": prompt_name, "label": label, "agent_id": self._config.agent_id},
|
|
78
111
|
)
|
|
79
|
-
|
|
112
|
+
raw_content = response.get("prompt_content", "")
|
|
113
|
+
metadata = response.get("metadata", {})
|
|
80
114
|
|
|
81
115
|
# Store in cache if caching is enabled
|
|
82
116
|
if cache_ttl != 0:
|
|
83
117
|
self._cache[cache_key] = {
|
|
84
|
-
"content":
|
|
118
|
+
"content": raw_content,
|
|
119
|
+
"metadata": metadata,
|
|
85
120
|
"timestamp": time.time(),
|
|
86
121
|
}
|
|
87
122
|
|
|
88
|
-
|
|
123
|
+
prompt = Prompt(raw_content=raw_content, content=raw_content, metadata=metadata)
|
|
89
124
|
if variables:
|
|
90
|
-
|
|
91
|
-
prompt = prompt.replace(f"{{{{{key}}}}}", str(value))
|
|
92
|
-
|
|
125
|
+
prompt.replace_variables(variables)
|
|
93
126
|
return prompt
|
|
94
127
|
except Exception as e:
|
|
95
128
|
if self._production:
|
|
96
129
|
logger.error(f"[PromptResource] Failed to get prompt: {e}")
|
|
97
|
-
return ""
|
|
130
|
+
return Prompt(raw_content="", content="", metadata={})
|
|
98
131
|
raise
|
|
99
132
|
|
|
100
133
|
async def aget(
|
|
@@ -103,7 +136,7 @@ class PromptResource:
|
|
|
103
136
|
variables: Optional[Dict[str, Any]] = None,
|
|
104
137
|
label: str = "production",
|
|
105
138
|
cache_ttl: int = 0,
|
|
106
|
-
) ->
|
|
139
|
+
) -> Prompt:
|
|
107
140
|
"""Get a prompt from the prompt database (asynchronous).
|
|
108
141
|
|
|
109
142
|
See get() for full documentation.
|
|
@@ -113,28 +146,30 @@ class PromptResource:
|
|
|
113
146
|
|
|
114
147
|
# Check cache
|
|
115
148
|
if self._is_cache_valid(cache_key, cache_ttl):
|
|
116
|
-
|
|
149
|
+
raw_content = self._cache[cache_key]["content"]
|
|
150
|
+
metadata = self._cache[cache_key]["metadata"]
|
|
117
151
|
else:
|
|
118
152
|
response = await self.http.aget(
|
|
119
153
|
"getprompt",
|
|
120
154
|
{"prompt_name": prompt_name, "label": label, "agent_id": self._config.agent_id},
|
|
121
155
|
)
|
|
122
|
-
|
|
156
|
+
raw_content = response.get("prompt_content", "")
|
|
157
|
+
metadata = response.get("metadata", {})
|
|
123
158
|
|
|
124
159
|
# Store in cache if caching is enabled
|
|
125
160
|
if cache_ttl != 0:
|
|
126
161
|
self._cache[cache_key] = {
|
|
127
|
-
"content":
|
|
162
|
+
"content": raw_content,
|
|
163
|
+
"metadata": metadata,
|
|
128
164
|
"timestamp": time.time(),
|
|
129
165
|
}
|
|
130
166
|
|
|
167
|
+
prompt = Prompt(raw_content=raw_content, content=raw_content, metadata=metadata)
|
|
131
168
|
if variables:
|
|
132
|
-
|
|
133
|
-
prompt = prompt.replace(f"{{{{{key}}}}}", str(value))
|
|
134
|
-
|
|
169
|
+
prompt.replace_variables(variables)
|
|
135
170
|
return prompt
|
|
136
171
|
except Exception as e:
|
|
137
172
|
if self._production:
|
|
138
173
|
logger.error(f"[PromptResource] Failed to get prompt: {e}")
|
|
139
|
-
return ""
|
|
174
|
+
return Prompt(raw_content="", content="", metadata={})
|
|
140
175
|
raise
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|