lucidicai 1.2.12__tar.gz → 1.2.14__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.
Files changed (33) hide show
  1. {lucidicai-1.2.12 → lucidicai-1.2.14}/PKG-INFO +1 -1
  2. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/__init__.py +7 -20
  3. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/client.py +2 -0
  4. lucidicai-1.2.14/lucidicai/singleton.py +50 -0
  5. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai.egg-info/PKG-INFO +1 -1
  6. {lucidicai-1.2.12 → lucidicai-1.2.14}/setup.py +1 -1
  7. lucidicai-1.2.12/lucidicai/singleton.py +0 -16
  8. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/constants.py +0 -0
  9. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/errors.py +0 -0
  10. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/event.py +0 -0
  11. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/image_upload.py +0 -0
  12. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/model_pricing.py +0 -0
  13. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/providers/__init__.py +0 -0
  14. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/providers/anthropic_handler.py +0 -0
  15. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/providers/base_providers.py +0 -0
  16. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/providers/langchain.py +0 -0
  17. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/providers/openai_agents_handler.py +0 -0
  18. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/providers/openai_handler.py +0 -0
  19. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/providers/opentelemetry_converter.py +0 -0
  20. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/providers/pydantic_ai_handler.py +0 -0
  21. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/session.py +0 -0
  22. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/step.py +0 -0
  23. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai/streaming.py +0 -0
  24. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai.egg-info/SOURCES.txt +0 -0
  25. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai.egg-info/dependency_links.txt +0 -0
  26. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai.egg-info/requires.txt +0 -0
  27. {lucidicai-1.2.12 → lucidicai-1.2.14}/lucidicai.egg-info/top_level.txt +0 -0
  28. {lucidicai-1.2.12 → lucidicai-1.2.14}/setup.cfg +0 -0
  29. {lucidicai-1.2.12 → lucidicai-1.2.14}/tests/test_anthropic_comprehensive.py +0 -0
  30. {lucidicai-1.2.12 → lucidicai-1.2.14}/tests/test_event_display.py +0 -0
  31. {lucidicai-1.2.12 → lucidicai-1.2.14}/tests/test_openai_agents_9_patterns_fixed.py +0 -0
  32. {lucidicai-1.2.12 → lucidicai-1.2.14}/tests/test_openai_comprehensive.py +0 -0
  33. {lucidicai-1.2.12 → lucidicai-1.2.14}/tests/test_pydantic_ai_comprehensive.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lucidicai
3
- Version: 1.2.12
3
+ Version: 1.2.14
4
4
  Summary: Lucidic AI Python SDK
5
5
  Author: Andy Liang
6
6
  Author-email: andy@lucidic.ai
@@ -130,15 +130,12 @@ def init(
130
130
  agent_id = os.getenv("LUCIDIC_AGENT_ID", None)
131
131
  if agent_id is None:
132
132
  raise APIKeyVerificationError("Lucidic agent ID not specified. Make sure to either pass your agent ID into lai.init() or set the LUCIDIC_AGENT_ID environment variable.")
133
- try:
134
- client = Client()
135
- if client.initialized:
136
- raise InvalidOperationError("[Lucidic] Session already in progress. Please call lai.reset() between sessions.")
137
- except LucidicNotInitializedError:
138
- client = Client(
139
- lucidic_api_key=lucidic_api_key,
140
- agent_id=agent_id,
141
- )
133
+
134
+ # get current client which will be NullClient if never lai is never initialized
135
+ client = Client()
136
+ # ff not yet initialized or still the NullClient -> creaet a real client when init is called
137
+ if not getattr(client, 'initialized', False):
138
+ client = Client(lucidic_api_key=lucidic_api_key, agent_id=agent_id)
142
139
 
143
140
  # Set up providers
144
141
  _setup_providers(client, providers)
@@ -201,9 +198,8 @@ def update_session(
201
198
  is_successful: Whether the session was successful.
202
199
  is_successful_reason: Session success reason.
203
200
  """
204
- client = Client() # TODO: Fail silently if client not initialized yet
201
+ client = Client()
205
202
  if not client.session:
206
- logger.warning("update_session called when session not initialized. Please call lai.init() first.")
207
203
  return
208
204
  client.session.update_session(**locals())
209
205
 
@@ -225,7 +221,6 @@ def end_session(
225
221
  """
226
222
  client = Client()
227
223
  if not client.session:
228
- logger.warning("end_session called when session not initialized. Please call lai.init() first.")
229
224
  return
230
225
  client.session.update_session(is_finished=True, **locals())
231
226
  client.clear()
@@ -237,7 +232,6 @@ def reset_sdk() -> None:
237
232
  """
238
233
  client = Client()
239
234
  if not client.initialized:
240
- logger.warning("reset_sdk called when SDK not initialized. Please call lai.init() first.")
241
235
  return
242
236
  client.clear()
243
237
 
@@ -307,7 +301,6 @@ def create_step(
307
301
  """
308
302
  client = Client()
309
303
  if not client.session:
310
- logger.warning("create_step called when session not initialized. Please call lai.init() first.")
311
304
  return
312
305
  return client.session.create_step(**locals())
313
306
 
@@ -337,7 +330,6 @@ def update_step(
337
330
  """
338
331
  client = Client()
339
332
  if not client.session:
340
- logger.warning("update_step called when session not initialized. Please call lai.init() first.")
341
333
  return
342
334
  if not client.session.active_step:
343
335
  raise InvalidOperationError("No active step to update")
@@ -369,7 +361,6 @@ def end_step(
369
361
  """
370
362
  client = Client()
371
363
  if not client.session:
372
- logger.warning("end_step called when session not initialized. Please call lai.init() first.")
373
364
  return
374
365
 
375
366
  if not client.session.active_step and step_id is None:
@@ -404,7 +395,6 @@ def create_event(
404
395
 
405
396
  client = Client()
406
397
  if not client.session:
407
- logger.warning("create_event called when session not initialized. Please call lai.init() first.")
408
398
  return
409
399
  return client.session.create_event(**locals())
410
400
 
@@ -430,7 +420,6 @@ def update_event(
430
420
  """
431
421
  client = Client()
432
422
  if not client.session:
433
- logger.warning("update_event called when session not initialized. Please call lai.init() first.")
434
423
  return
435
424
  client.session.update_event(**locals())
436
425
 
@@ -455,7 +444,6 @@ def end_event(
455
444
  """
456
445
  client = Client()
457
446
  if not client.session:
458
- logger.warning("end_event called when session not initialized. Please call lai.init() first.")
459
447
  return
460
448
  client.session.update_event(is_finished=True, **locals())
461
449
 
@@ -480,7 +468,6 @@ def get_prompt(
480
468
  """
481
469
  client = Client()
482
470
  if not client.session:
483
- logger.warning("get_prompt called when session not initialized, and will return an empty string. Please call lai.init() first.")
484
471
  return ""
485
472
  prompt = client.get_prompt(prompt_name, cache_ttl, label)
486
473
  if variables:
@@ -135,6 +135,8 @@ class Client:
135
135
  break
136
136
  except Exception:
137
137
  pass
138
+ if response is None:
139
+ raise InvalidOperationError("Cannot reach backend. Check your internet connection.")
138
140
  if response.status_code == 401:
139
141
  raise APIKeyVerificationError("Invalid API key: 401 Unauthorized")
140
142
  if response.status_code == 402:
@@ -0,0 +1,50 @@
1
+ from .errors import LucidicNotInitializedError
2
+
3
+ lai_inst = {}
4
+
5
+ def singleton(class_):
6
+ def getinstance(*args, **kwargs):
7
+
8
+ inst = lai_inst.get(class_)
9
+
10
+ # on first access -> no instance yet
11
+ if inst is None:
12
+ # no args/kwargs -> return a NullClient for Client
13
+ if class_.__name__ == 'Client' and not args and not kwargs:
14
+ inst = NullClient()
15
+ else:
16
+ inst = class_(*args, **kwargs)
17
+ lai_inst[class_] = inst
18
+ return inst
19
+
20
+ # existing instance present
21
+ # if NullClient and now real init args are passed -> upgrade it
22
+ if isinstance(inst, NullClient) and (args or kwargs):
23
+ inst = class_(*args, **kwargs)
24
+ lai_inst[class_] = inst
25
+ return inst
26
+
27
+ return getinstance
28
+
29
+ def clear_singletons():
30
+ lai_inst.clear()
31
+
32
+
33
+ class NullClient:
34
+ """
35
+ A no-op client returned when Lucidic has not been initialized.
36
+ All methods are inert and session is None.
37
+ """
38
+ def __init__(self):
39
+ self.initialized = False
40
+ self.session = None
41
+ self.providers = []
42
+
43
+ def set_provider(self, *args, **kwargs):
44
+ pass
45
+
46
+ def undo_overrides(self):
47
+ pass
48
+
49
+ def clear(self):
50
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lucidicai
3
- Version: 1.2.12
3
+ Version: 1.2.14
4
4
  Summary: Lucidic AI Python SDK
5
5
  Author: Andy Liang
6
6
  Author-email: andy@lucidic.ai
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="lucidicai",
5
- version="1.2.12",
5
+ version="1.2.14",
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  "requests>=2.25.1",
@@ -1,16 +0,0 @@
1
- from .errors import LucidicNotInitializedError
2
-
3
- lai_inst = {}
4
-
5
- def singleton(class_):
6
- def getinstance(*args, **kwargs):
7
- if class_ not in lai_inst:
8
- if class_.__name__ == 'Client' and ('lucidic_api_key' not in kwargs or 'agent_id' not in kwargs):
9
- raise LucidicNotInitializedError()
10
- lai_inst[class_] = class_(*args, **kwargs)
11
- return lai_inst[class_]
12
-
13
- return getinstance
14
-
15
- def clear_singletons():
16
- lai_inst.clear()
File without changes
File without changes