maitai-python 1.1.10__tar.gz → 1.1.11__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 (48) hide show
  1. {maitai_python-1.1.10 → maitai_python-1.1.11}/PKG-INFO +1 -1
  2. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_maitai.py +7 -0
  3. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_maitai_async.py +7 -0
  4. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_utils.py +1 -1
  5. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/processes/io_thread.py +9 -12
  6. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/version.py +1 -1
  7. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_python.egg-info/PKG-INFO +1 -1
  8. {maitai_python-1.1.10 → maitai_python-1.1.11}/README.md +0 -0
  9. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/__init__.py +0 -0
  10. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_azure.py +0 -0
  11. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_config.py +0 -0
  12. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_config_listener_thread.py +0 -0
  13. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_context.py +0 -0
  14. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_evaluator.py +0 -0
  15. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_inference.py +0 -0
  16. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_maitai_client.py +0 -0
  17. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/_types.py +0 -0
  18. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai/tools/__init__.py +0 -0
  19. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/__init__.py +0 -0
  20. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/config/__init__.py +0 -0
  21. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/config/config_service.py +0 -0
  22. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/processes/__init__.py +0 -0
  23. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/processes/websocket_listener_thread.py +0 -0
  24. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/utils/__init__.py +0 -0
  25. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/utils/proto_utils.py +0 -0
  26. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_common/utils/types.py +0 -0
  27. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/__init__.py +0 -0
  28. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/application/__init__.py +0 -0
  29. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/backtest/__init__.py +0 -0
  30. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/chat/__init__.py +0 -0
  31. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/company/__init__.py +0 -0
  32. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/config/__init__.py +0 -0
  33. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/embedding/__init__.py +0 -0
  34. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/event/__init__.py +0 -0
  35. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/inference/__init__.py +0 -0
  36. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/key/__init__.py +0 -0
  37. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/metric/__init__.py +0 -0
  38. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/model/__init__.py +0 -0
  39. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/notification/__init__.py +0 -0
  40. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/sandbox/__init__.py +0 -0
  41. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/sentinel/__init__.py +0 -0
  42. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_gen/session/__init__.py +0 -0
  43. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_python.egg-info/SOURCES.txt +0 -0
  44. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_python.egg-info/dependency_links.txt +0 -0
  45. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_python.egg-info/requires.txt +0 -0
  46. {maitai_python-1.1.10 → maitai_python-1.1.11}/maitai_python.egg-info/top_level.txt +0 -0
  47. {maitai_python-1.1.10 → maitai_python-1.1.11}/setup.cfg +0 -0
  48. {maitai_python-1.1.10 → maitai_python-1.1.11}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maitai-python
3
- Version: 1.1.10
3
+ Version: 1.1.11
4
4
  Summary: Maitai SDK for Python
5
5
  Home-page: https://docs.trymaitai.ai
6
6
  Author: Maitai
@@ -160,6 +160,13 @@ class Completions:
160
160
  raise ValueError("server_side_inference must be true to apply_corrections")
161
161
  if apply_corrections is True and evaluation_enabled is False:
162
162
  raise ValueError("evaluations must be enabled to apply_corrections")
163
+ if assistant is True:
164
+ user_msgs = [True for msg in messages if msg["role"] == "user"]
165
+ assistant_messages = [True for msg in messages if msg["role"] == "assistant"]
166
+ if len(user_msgs) != 1:
167
+ raise ValueError("When assistant = True, exactly 1 user message is required")
168
+ if len(assistant_messages) > 0:
169
+ raise ValueError("When assistant = True, no assistant messages are allowed")
163
170
  if not session_id:
164
171
  session_id = str(uuid.uuid4())
165
172
  if not intent and action_type:
@@ -155,6 +155,13 @@ class AsyncCompletions:
155
155
  raise ValueError("server_side_inference must be true to apply_corrections")
156
156
  if apply_corrections is True and evaluation_enabled is False:
157
157
  raise ValueError("evaluations must be enabled to apply_corrections")
158
+ if assistant is True:
159
+ user_msgs = [True for msg in messages if msg["role"] == "user"]
160
+ assistant_messages = [True for msg in messages if msg["role"] == "assistant"]
161
+ if len(user_msgs) != 1:
162
+ raise ValueError("When assistant = True, exactly 1 user message is required")
163
+ if len(assistant_messages) > 0:
164
+ raise ValueError("When assistant = True, no assistant messages are allowed")
158
165
  if not session_id:
159
166
  session_id = str(uuid.uuid4())
160
167
  if action_type and not intent:
@@ -160,7 +160,7 @@ def get_chat_completion_params(*,
160
160
  params.tools = []
161
161
  if isinstance(tools, Tools):
162
162
  params.tools = tools.get_tool_definitions()
163
- else:
163
+ elif tools:
164
164
  for tool in tools:
165
165
  if isinstance(tool, Callable) and not isinstance(tool, ToolFunction):
166
166
  raise TypeError(f"Method passed into tools missing @tool decorator")
@@ -1,4 +1,4 @@
1
- import threading
1
+ import asyncio
2
2
  import time
3
3
  import traceback
4
4
  from threading import Thread
@@ -16,17 +16,20 @@ class IOThread(Thread):
16
16
  self.completed_loops = 0
17
17
  self.avg_loop_time = 0
18
18
  self.cleaned = False
19
- self.timer_thread = None
20
19
  self.last_loop_start = -1
21
20
  self.child_name = self.__class__.__name__ if name is None else name
22
21
 
23
22
  def run(self):
24
23
  if not self.initialized:
25
24
  self.initialize()
26
- time.sleep(self.interval)
27
- self.loop()
25
+ asyncio.run(self.main_loop())
28
26
 
29
- def loop(self):
27
+ async def main_loop(self):
28
+ await asyncio.sleep(self.interval)
29
+ while self.run_thread:
30
+ await self.loop()
31
+
32
+ async def loop(self):
30
33
  if self.run_thread:
31
34
  self.last_loop_start = time.time()
32
35
  self.is_running = True
@@ -41,18 +44,12 @@ class IOThread(Thread):
41
44
  self.avg_loop_time = ((self.avg_loop_time * self.completed_loops) * delta) / (self.completed_loops + 1)
42
45
  self.completed_loops += 1
43
46
  next_run = self.interval - delta
44
- self.timer_thread = threading.Timer(0 if next_run < 0 else next_run, self.loop)
45
- self.timer_thread.name = self.child_name
46
- self.timer_thread.start()
47
+ await asyncio.sleep(max(0, next_run))
47
48
  else:
48
- if self.timer_thread is not None:
49
- self.timer_thread.cancel()
50
49
  self.cleaned = True
51
50
 
52
51
  def terminate(self):
53
52
  self.run_thread = False
54
- if self.timer_thread is not None:
55
- self.timer_thread.cancel()
56
53
  self.cleaned = True
57
54
  self.print(f'{self.child_name} cleaned up')
58
55
 
@@ -1,3 +1,3 @@
1
- version = "1.1.10"
1
+ version = "1.1.11"
2
2
  if __name__ == "__main__":
3
3
  print(version)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maitai-python
3
- Version: 1.1.10
3
+ Version: 1.1.11
4
4
  Summary: Maitai SDK for Python
5
5
  Home-page: https://docs.trymaitai.ai
6
6
  Author: Maitai
File without changes
File without changes
File without changes