maitai-python 1.0.12__tar.gz → 1.0.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 (39) hide show
  1. {maitai_python-1.0.12 → maitai_python-1.0.14}/PKG-INFO +1 -1
  2. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_config.py +12 -0
  3. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_maitai_client.py +2 -1
  4. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_openai.py +4 -2
  5. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_openai_async.py +4 -0
  6. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/application/__init__.py +2 -0
  7. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/chat/__init__.py +8 -0
  8. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/session/__init__.py +4 -0
  9. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_python.egg-info/PKG-INFO +1 -1
  10. {maitai_python-1.0.12 → maitai_python-1.0.14}/setup.py +1 -1
  11. {maitai_python-1.0.12 → maitai_python-1.0.14}/README.md +0 -0
  12. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/__init__.py +0 -0
  13. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_azure.py +0 -0
  14. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_config_listener_thread.py +0 -0
  15. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_evaluator.py +0 -0
  16. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_inference.py +0 -0
  17. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_openai_types.py +0 -0
  18. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai/_utils.py +0 -0
  19. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_common/__init__.py +0 -0
  20. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_common/config/__init__.py +0 -0
  21. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_common/config/config_service.py +0 -0
  22. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_common/processes/__init__.py +0 -0
  23. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_common/processes/io_thread.py +0 -0
  24. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_common/processes/websocket_listener_thread.py +0 -0
  25. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_common/utils/__init__.py +0 -0
  26. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_common/utils/proto_utils.py +0 -0
  27. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_common/utils/types.py +0 -0
  28. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/__init__.py +0 -0
  29. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/company/__init__.py +0 -0
  30. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/config/__init__.py +0 -0
  31. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/inference/__init__.py +0 -0
  32. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/notification/__init__.py +0 -0
  33. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/sandbox/__init__.py +0 -0
  34. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_gen/sentinel/__init__.py +0 -0
  35. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_python.egg-info/SOURCES.txt +0 -0
  36. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_python.egg-info/dependency_links.txt +0 -0
  37. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_python.egg-info/requires.txt +0 -0
  38. {maitai_python-1.0.12 → maitai_python-1.0.14}/maitai_python.egg-info/top_level.txt +0 -0
  39. {maitai_python-1.0.12 → maitai_python-1.0.14}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maitai-python
3
- Version: 1.0.12
3
+ Version: 1.0.14
4
4
  Summary: Maitai SDK for Python
5
5
  Home-page: https://docs.trymaitai.ai
6
6
  Author: Maitai
@@ -5,6 +5,7 @@ import requests
5
5
  from maitai._config_listener_thread import ConfigListenerThread
6
6
  from maitai_common.config import config_service
7
7
  from maitai_gen.application import Application
8
+ from maitai_gen.chat import ChatCompletionAuth
8
9
  from maitai_gen.config import Config as ActionConfig
9
10
 
10
11
 
@@ -20,6 +21,10 @@ class Config:
20
21
  self.config_listener_thread = None
21
22
  self._application_action_configs: dict[str, dict[str, ActionConfig]] = {}
22
23
  self.initialized = False
24
+ self.auth_info = ChatCompletionAuth(
25
+ openai_api_key=os.environ.get("OPENAI_API_KEY"),
26
+ groq_api_key=os.environ.get("GROQ_API_KEY"),
27
+ )
23
28
 
24
29
  @property
25
30
  def api_key(self):
@@ -56,6 +61,10 @@ class Config:
56
61
  }
57
62
 
58
63
  response = requests.get(url, headers=headers, verify=False)
64
+ if response.status_code != 200:
65
+ print(f"Failed to initialize API client. Status code: {response.status_code}. Error: {response.text}")
66
+ return
67
+
59
68
  self._company_id = response.json().get("id")
60
69
 
61
70
  def refresh_applications(self):
@@ -67,6 +76,9 @@ class Config:
67
76
  }
68
77
 
69
78
  response = requests.get(url, headers=headers, verify=False)
79
+ if response.status_code != 200:
80
+ print(f"Failed to initialize API client. Status code: {response.status_code}. Error: {response.text}")
81
+ return
70
82
  applications = [Application().from_dict(app_json) for app_json in response.json()]
71
83
  for application in applications:
72
84
  self._applications[application.application_ref_name] = application
@@ -3,7 +3,7 @@ import os
3
3
  import threading
4
4
 
5
5
  from maitai_gen.chat import ChatCompletionParams, ChatCompletionRequest
6
-
6
+ from maitai._config import config
7
7
 
8
8
  class MaitaiClient:
9
9
  MAITAI_HOST = os.environ.get("MAITAI_HOST", 'https://api.trymaitai.ai')
@@ -45,4 +45,5 @@ class MaitaiClient:
45
45
  infer_request.apply_corrections = apply_corrections
46
46
  infer_request.params = completion_params
47
47
  infer_request.evaluation_enabled = evaluation_enabled
48
+ infer_request.auth_info = config.auth_info
48
49
  return infer_request
@@ -38,6 +38,8 @@ class MaitaiOpenAIClient:
38
38
  ):
39
39
  if maitai_api_key:
40
40
  config.initialize(maitai_api_key)
41
+ if api_key:
42
+ config.auth_info.override_api_key = api_key
41
43
  self.client = openai.OpenAI(
42
44
  api_key=api_key,
43
45
  organization=organization,
@@ -110,8 +112,6 @@ class Completions:
110
112
  raise ValueError("server_side_inference must be true to apply_corrections")
111
113
  if apply_corrections is True and evaluation_enabled is False:
112
114
  raise ValueError("evaluations must be enabled to apply_corrections")
113
- if self.client is None:
114
- self.client = openai.OpenAI()
115
115
  maitai_config = config.get_application_action_config(application_ref_name, action_type)
116
116
  if server_side_inference is None:
117
117
  server_side_inference = maitai_config.inference_location == InferenceLocations.SERVER
@@ -171,6 +171,8 @@ class Completions:
171
171
  return resp.chat_completion_response
172
172
  return chat_completion
173
173
  else:
174
+ if self.client is None:
175
+ self.client = openai.OpenAI()
174
176
  response = self.client.chat.completions.create(
175
177
  messages=messages,
176
178
  model=model,
@@ -39,6 +39,8 @@ class MaitaiAsyncOpenAIClient:
39
39
  ):
40
40
  if maitai_api_key:
41
41
  config.initialize(maitai_api_key)
42
+ if api_key:
43
+ config.auth_info.override_api_key = api_key
42
44
  self.client = openai.AsyncClient(
43
45
  api_key=api_key,
44
46
  organization=organization,
@@ -175,6 +177,8 @@ class AsyncCompletions:
175
177
  return resp.chat_completion_response
176
178
  return chat_completion
177
179
  else:
180
+ if self.client is None:
181
+ self.client = openai.OpenAI()
178
182
  response = await self.client.chat.completions.create(
179
183
  messages=messages,
180
184
  model=model,
@@ -43,6 +43,7 @@ class Application(betterproto.Message):
43
43
  state: str = betterproto.string_field(7)
44
44
  meta: "_config__.Config" = betterproto.message_field(8)
45
45
  action_types: List["ApplicationAction"] = betterproto.message_field(9)
46
+ last_activity: int = betterproto.int64_field(10)
46
47
 
47
48
 
48
49
  @dataclass(eq=False, repr=False)
@@ -52,3 +53,4 @@ class ApplicationAction(betterproto.Message):
52
53
  date_created: int = betterproto.int64_field(3)
53
54
  application_id: int = betterproto.int64_field(4)
54
55
  meta: "_config__.Config" = betterproto.message_field(5)
56
+ last_activity: int = betterproto.int64_field(6)
@@ -44,6 +44,14 @@ class ChatCompletionRequest(betterproto.Message):
44
44
  date_created: int = betterproto.int64_field(9)
45
45
  request_id: str = betterproto.string_field(10)
46
46
  evaluation_enabled: bool = betterproto.bool_field(11)
47
+ auth_info: "ChatCompletionAuth" = betterproto.message_field(12)
48
+
49
+
50
+ @dataclass(eq=False, repr=False)
51
+ class ChatCompletionAuth(betterproto.Message):
52
+ openai_api_key: str = betterproto.string_field(1)
53
+ groq_api_key: str = betterproto.string_field(2)
54
+ override_api_key: str = betterproto.string_field(3)
47
55
 
48
56
 
49
57
  @dataclass(eq=False, repr=False)
@@ -5,6 +5,7 @@
5
5
 
6
6
  from dataclasses import dataclass
7
7
  from typing import (
8
+ Dict,
8
9
  List,
9
10
  Optional,
10
11
  )
@@ -32,6 +33,9 @@ class Session(betterproto.Message):
32
33
  fully_corrected: bool = betterproto.bool_field(6)
33
34
  summary: str = betterproto.string_field(7)
34
35
  feedback: "SessionFeedback" = betterproto.enum_field(8)
36
+ reviewer: Dict[str, str] = betterproto.map_field(
37
+ 9, betterproto.TYPE_STRING, betterproto.TYPE_STRING
38
+ )
35
39
 
36
40
 
37
41
  @dataclass(eq=False, repr=False)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maitai-python
3
- Version: 1.0.12
3
+ Version: 1.0.14
4
4
  Summary: Maitai SDK for Python
5
5
  Home-page: https://docs.trymaitai.ai
6
6
  Author: Maitai
@@ -3,7 +3,7 @@
3
3
  from setuptools import setup, find_packages
4
4
  setup(
5
5
  name='maitai-python',
6
- version='1.0.12',
6
+ version='1.0.14',
7
7
  packages=find_packages(exclude=("maitai_back", "maitai_back.*")),
8
8
  install_requires=[
9
9
  'requests',
File without changes
File without changes