lucidicai 2.1.3__py3-none-any.whl → 3.0.0__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.
Files changed (38) hide show
  1. lucidicai/__init__.py +32 -390
  2. lucidicai/api/client.py +31 -2
  3. lucidicai/api/resources/__init__.py +16 -1
  4. lucidicai/api/resources/dataset.py +422 -82
  5. lucidicai/api/resources/event.py +399 -27
  6. lucidicai/api/resources/experiment.py +108 -0
  7. lucidicai/api/resources/feature_flag.py +78 -0
  8. lucidicai/api/resources/prompt.py +84 -0
  9. lucidicai/api/resources/session.py +545 -38
  10. lucidicai/client.py +395 -480
  11. lucidicai/core/config.py +73 -48
  12. lucidicai/core/errors.py +3 -3
  13. lucidicai/sdk/bound_decorators.py +321 -0
  14. lucidicai/sdk/context.py +20 -2
  15. lucidicai/sdk/decorators.py +283 -74
  16. lucidicai/sdk/event.py +538 -36
  17. lucidicai/sdk/event_builder.py +2 -4
  18. lucidicai/sdk/features/dataset.py +391 -1
  19. lucidicai/sdk/features/feature_flag.py +344 -3
  20. lucidicai/sdk/init.py +49 -347
  21. lucidicai/sdk/session.py +502 -0
  22. lucidicai/sdk/shutdown_manager.py +103 -46
  23. lucidicai/session_obj.py +321 -0
  24. lucidicai/telemetry/context_capture_processor.py +13 -6
  25. lucidicai/telemetry/extract.py +60 -63
  26. lucidicai/telemetry/litellm_bridge.py +3 -44
  27. lucidicai/telemetry/lucidic_exporter.py +143 -131
  28. lucidicai/telemetry/openai_agents_instrumentor.py +2 -2
  29. lucidicai/telemetry/openai_patch.py +7 -6
  30. lucidicai/telemetry/telemetry_manager.py +183 -0
  31. lucidicai/telemetry/utils/model_pricing.py +21 -30
  32. lucidicai/telemetry/utils/provider.py +77 -0
  33. lucidicai/utils/images.py +27 -11
  34. lucidicai/utils/serialization.py +27 -0
  35. {lucidicai-2.1.3.dist-info → lucidicai-3.0.0.dist-info}/METADATA +1 -1
  36. {lucidicai-2.1.3.dist-info → lucidicai-3.0.0.dist-info}/RECORD +38 -29
  37. {lucidicai-2.1.3.dist-info → lucidicai-3.0.0.dist-info}/WHEEL +0 -0
  38. {lucidicai-2.1.3.dist-info → lucidicai-3.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,84 @@
1
+ """Prompt resource API operations."""
2
+ import logging
3
+ from typing import Any, Dict, Optional
4
+
5
+ from ..client import HttpClient
6
+
7
+ logger = logging.getLogger("Lucidic")
8
+
9
+
10
+ class PromptResource:
11
+ """Handle prompt-related API operations."""
12
+
13
+ def __init__(self, http: HttpClient, production: bool = False):
14
+ """Initialize prompt resource.
15
+
16
+ Args:
17
+ http: HTTP client instance
18
+ production: Whether to suppress errors in production mode
19
+ """
20
+ self.http = http
21
+ self._production = production
22
+
23
+ def get(
24
+ self,
25
+ prompt_name: str,
26
+ variables: Optional[Dict[str, Any]] = None,
27
+ label: str = "production",
28
+ ) -> str:
29
+ """Get a prompt from the prompt database.
30
+
31
+ Args:
32
+ prompt_name: Name of the prompt.
33
+ variables: Variables to interpolate into the prompt.
34
+ label: Prompt version label (default: "production").
35
+
36
+ Returns:
37
+ The prompt content with variables interpolated.
38
+ """
39
+ try:
40
+ response = self.http.get(
41
+ "getprompt",
42
+ {"prompt_name": prompt_name, "label": label},
43
+ )
44
+ prompt = response.get("prompt_content", "")
45
+
46
+ # Replace variables
47
+ if variables:
48
+ for key, value in variables.items():
49
+ prompt = prompt.replace(f"{{{key}}}", str(value))
50
+
51
+ return prompt
52
+ except Exception as e:
53
+ if self._production:
54
+ logger.error(f"[PromptResource] Failed to get prompt: {e}")
55
+ return ""
56
+ raise
57
+
58
+ async def aget(
59
+ self,
60
+ prompt_name: str,
61
+ variables: Optional[Dict[str, Any]] = None,
62
+ label: str = "production",
63
+ ) -> str:
64
+ """Get a prompt from the prompt database (asynchronous).
65
+
66
+ See get() for full documentation.
67
+ """
68
+ try:
69
+ response = await self.http.aget(
70
+ "getprompt",
71
+ {"prompt_name": prompt_name, "label": label},
72
+ )
73
+ prompt = response.get("prompt_content", "")
74
+
75
+ if variables:
76
+ for key, value in variables.items():
77
+ prompt = prompt.replace(f"{{{key}}}", str(value))
78
+
79
+ return prompt
80
+ except Exception as e:
81
+ if self._production:
82
+ logger.error(f"[PromptResource] Failed to get prompt: {e}")
83
+ return ""
84
+ raise