maitai-python 1.2.29b0__tar.gz → 1.2.31__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.
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/PKG-INFO +5 -3
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/README.md +1 -1
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_config.py +11 -3
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_config_listener.py +7 -2
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_maitai.py +19 -11
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_maitai_async.py +17 -9
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_maitai_client.py +30 -18
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_utils.py +21 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/agent/_completions.py +3 -2
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/agent/_completions_async.py +3 -2
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/chat/_completions.py +157 -63
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/chat/_completions_async.py +160 -66
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/agent/base.py +43 -0
- maitai_python-1.2.31/maitai/models/agent/extended.py +702 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/chat.py +67 -5
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/config.py +15 -2
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/inference.py +2 -0
- maitai_python-1.2.31/maitai/models/workflow_chunk.py +24 -0
- maitai_python-1.2.31/maitai/workflow/__init__.py +4 -0
- maitai_python-1.2.31/maitai/workflow/_completions.py +165 -0
- maitai_python-1.2.31/maitai/workflow/_completions_async.py +203 -0
- maitai_python-1.2.31/maitai/workflow/_local.py +376 -0
- maitai_python-1.2.31/maitai/workflow/_stream_http.py +164 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai_common/config/config_service.py +2 -3
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai_common/version.py +1 -1
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai_python.egg-info/PKG-INFO +5 -3
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai_python.egg-info/SOURCES.txt +6 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai_python.egg-info/requires.txt +2 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/setup.py +3 -1
- maitai_python-1.2.29b0/maitai/models/agent/extended.py +0 -1464
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/__init__.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_context.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_evaluator.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_inference.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_pydantic.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/_types.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/agent/__init__.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/chat/__init__.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/exceptions.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/__init__.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/agent/__init__.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/agent/enum.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/agent_action.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/agent_routing.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/application.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/event.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/key.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/metric.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/models/sentinel.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/tools/__init__.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/transcriptions/__init__.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/transcriptions/_transcriptions.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai/transcriptions/_transcriptions_async.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai_common/__init__.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.2.29b0 → maitai_python-1.2.31}/setup.cfg +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maitai-python
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.31
|
|
4
4
|
Summary: Maitai SDK for Python
|
|
5
5
|
Home-page: https://docs.trymaitai.ai
|
|
6
6
|
Author: Maitai
|
|
7
|
-
Author-email: support@trymaitai.
|
|
7
|
+
Author-email: support@trymaitai.com
|
|
8
8
|
License: MIT
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -15,6 +15,8 @@ Requires-Dist: websocket-client
|
|
|
15
15
|
Requires-Dist: pyhumps
|
|
16
16
|
Requires-Dist: pydantic>=2.0.0
|
|
17
17
|
Requires-Dist: groq
|
|
18
|
+
Requires-Dist: boto3
|
|
19
|
+
Requires-Dist: redis
|
|
18
20
|
Dynamic: author
|
|
19
21
|
Dynamic: author-email
|
|
20
22
|
Dynamic: classifier
|
|
@@ -64,4 +66,4 @@ Maitai requires `openai` version `1.30.1` or later. If you are using an older ve
|
|
|
64
66
|
## Run Your Application
|
|
65
67
|
|
|
66
68
|
Run your application, make sure it makes at least one Chat Completion Request, then head over
|
|
67
|
-
to https://portal.trymaitai.
|
|
69
|
+
to https://portal.trymaitai.com and watch Maitai learn your application in real time.
|
|
@@ -37,4 +37,4 @@ Maitai requires `openai` version `1.30.1` or later. If you are using an older ve
|
|
|
37
37
|
## Run Your Application
|
|
38
38
|
|
|
39
39
|
Run your application, make sure it makes at least one Chat Completion Request, then head over
|
|
40
|
-
to https://portal.trymaitai.
|
|
40
|
+
to https://portal.trymaitai.com and watch Maitai learn your application in real time.
|
|
@@ -17,7 +17,7 @@ class Config(MaitaiClient):
|
|
|
17
17
|
config_dir = os.path.expanduser(os.environ.get("MAITAI_CONFIG_DIR", "~/.maitai"))
|
|
18
18
|
refresh_timer = None
|
|
19
19
|
|
|
20
|
-
def __init__(self, api_key=None):
|
|
20
|
+
def __init__(self, api_key=None, server_side_only=False):
|
|
21
21
|
super().__init__()
|
|
22
22
|
self._api_key = None
|
|
23
23
|
self._company_id = None
|
|
@@ -37,7 +37,11 @@ class Config(MaitaiClient):
|
|
|
37
37
|
)
|
|
38
38
|
self.refresh_interval = 30 * 60 # 30 minutes in seconds
|
|
39
39
|
if api_key:
|
|
40
|
-
|
|
40
|
+
if server_side_only:
|
|
41
|
+
self._api_key = api_key
|
|
42
|
+
self.initialized = True
|
|
43
|
+
else:
|
|
44
|
+
self.initialize(api_key)
|
|
41
45
|
|
|
42
46
|
def __del__(self):
|
|
43
47
|
self.cleanup()
|
|
@@ -184,7 +188,11 @@ class Config(MaitaiClient):
|
|
|
184
188
|
|
|
185
189
|
def _initialize_websocket(self):
|
|
186
190
|
self.config_listener = ConfigListener(
|
|
187
|
-
self,
|
|
191
|
+
self,
|
|
192
|
+
self.maitai_ws,
|
|
193
|
+
"APPLICATION_CONFIG_CHANGE",
|
|
194
|
+
self._company_id,
|
|
195
|
+
self.api_key,
|
|
188
196
|
)
|
|
189
197
|
self.config_listener.start()
|
|
190
198
|
|
|
@@ -13,11 +13,13 @@ logger = logging.getLogger("maitai")
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class ConfigListener:
|
|
16
|
-
def __init__(self, config, path, type, key=None):
|
|
16
|
+
def __init__(self, config, path, type, key=None, api_key=None):
|
|
17
17
|
self.config = config
|
|
18
18
|
self.ws_url = f"{path}?type={type}"
|
|
19
19
|
if key:
|
|
20
20
|
self.ws_url += f"&key={key}"
|
|
21
|
+
if api_key:
|
|
22
|
+
self.ws_url += f"&api_key={api_key}"
|
|
21
23
|
|
|
22
24
|
self.ws = None
|
|
23
25
|
self.ws_thread = None
|
|
@@ -48,7 +50,10 @@ class ConfigListener:
|
|
|
48
50
|
|
|
49
51
|
def on_error(self, ws, error):
|
|
50
52
|
if not isinstance(error, (AttributeError, ConnectionError)):
|
|
51
|
-
|
|
53
|
+
if error is not None and isinstance(error, Exception):
|
|
54
|
+
logger.error("Maitai config listener: websocket error", exc_info=error)
|
|
55
|
+
else:
|
|
56
|
+
logger.error(f"Maitai config listener: websocket error: {error}")
|
|
52
57
|
|
|
53
58
|
def on_close(self, ws, close_status_code, close_msg):
|
|
54
59
|
logger.info(
|
|
@@ -13,6 +13,7 @@ from maitai.chat._completions import Completions
|
|
|
13
13
|
from maitai.models.chat import AzureParams, ClientParams
|
|
14
14
|
from maitai.models.key import Key
|
|
15
15
|
from maitai.transcriptions._transcriptions import Transcriptions
|
|
16
|
+
from maitai.workflow._completions import Completions as WorkflowCompletions
|
|
16
17
|
|
|
17
18
|
logger = logging.getLogger("maitai")
|
|
18
19
|
|
|
@@ -45,6 +46,7 @@ class Maitai:
|
|
|
45
46
|
default_query: Optional[Mapping[str, object]] = None,
|
|
46
47
|
http_client: Optional[httpx.Client] = None,
|
|
47
48
|
_strict_response_validation: bool = False,
|
|
49
|
+
server_side_only: bool = False,
|
|
48
50
|
):
|
|
49
51
|
if not maitai_api_key:
|
|
50
52
|
maitai_api_key = os.environ.get("MAITAI_API_KEY")
|
|
@@ -56,7 +58,7 @@ class Maitai:
|
|
|
56
58
|
raise ValueError(
|
|
57
59
|
"api_key is deprecated. Use provider specific keys instead. Supported variables: openai_api_key, groq_api_key, anthropic_api_key, cerebras_api_key, azure_api_key, sambanova_api_key, gemini_api_key, deepseek_api_key"
|
|
58
60
|
)
|
|
59
|
-
self.config = Config(maitai_api_key)
|
|
61
|
+
self.config = Config(maitai_api_key, server_side_only=server_side_only)
|
|
60
62
|
if openai_api_key:
|
|
61
63
|
if not self.config.auth_keys.openai_api_key:
|
|
62
64
|
self.config.auth_keys.openai_api_key = Key(
|
|
@@ -150,16 +152,13 @@ class Maitai:
|
|
|
150
152
|
http_client=http_client,
|
|
151
153
|
_strict_response_validation=_strict_response_validation,
|
|
152
154
|
)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
self.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
else None
|
|
161
|
-
),
|
|
162
|
-
)
|
|
155
|
+
groq_key_value = groq_api_key or (
|
|
156
|
+
self.config.auth_keys.groq_api_key.key_value
|
|
157
|
+
if self.config.auth_keys.groq_api_key
|
|
158
|
+
else None
|
|
159
|
+
)
|
|
160
|
+
if groq_key_value and groq_key_value.strip():
|
|
161
|
+
self._groq_client = groq.Groq(api_key=groq_key_value)
|
|
163
162
|
|
|
164
163
|
client_params = None
|
|
165
164
|
if base_url or default_headers or default_query:
|
|
@@ -178,6 +177,7 @@ class Maitai:
|
|
|
178
177
|
)
|
|
179
178
|
self.audio = Audio(self.config)
|
|
180
179
|
self.agent = Agent(self.config)
|
|
180
|
+
self.workflow = Workflow(self.config)
|
|
181
181
|
self.context = ContextManager(self.config)
|
|
182
182
|
|
|
183
183
|
|
|
@@ -208,3 +208,11 @@ class Agent:
|
|
|
208
208
|
config: Config,
|
|
209
209
|
):
|
|
210
210
|
self.completions = AgentCompletions(config)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class Workflow:
|
|
214
|
+
def __init__(
|
|
215
|
+
self,
|
|
216
|
+
config: Config,
|
|
217
|
+
):
|
|
218
|
+
self.completions = WorkflowCompletions(config)
|
|
@@ -12,6 +12,7 @@ from maitai.chat._completions_async import AsyncCompletions
|
|
|
12
12
|
from maitai.models.chat import AzureParams, ClientParams
|
|
13
13
|
from maitai.models.key import Key
|
|
14
14
|
from maitai.transcriptions._transcriptions_async import AsyncTranscriptions
|
|
15
|
+
from maitai.workflow._completions_async import AsyncCompletions as AsyncWorkflowCompletions
|
|
15
16
|
|
|
16
17
|
logger = logging.getLogger("maitai")
|
|
17
18
|
|
|
@@ -149,15 +150,13 @@ class MaitaiAsync:
|
|
|
149
150
|
http_client=http_client,
|
|
150
151
|
_strict_response_validation=_strict_response_validation,
|
|
151
152
|
)
|
|
152
|
-
|
|
153
|
-
self.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
),
|
|
160
|
-
)
|
|
153
|
+
groq_key_value = groq_api_key or (
|
|
154
|
+
self.config.auth_keys.groq_api_key.key_value
|
|
155
|
+
if self.config.auth_keys.groq_api_key
|
|
156
|
+
else None
|
|
157
|
+
)
|
|
158
|
+
if groq_key_value and groq_key_value.strip():
|
|
159
|
+
self._groq_client = groq.AsyncGroq(api_key=groq_key_value)
|
|
161
160
|
|
|
162
161
|
client_params = None
|
|
163
162
|
if base_url or default_headers or default_query:
|
|
@@ -176,6 +175,7 @@ class MaitaiAsync:
|
|
|
176
175
|
)
|
|
177
176
|
self.audio = AsyncAudio(self.config)
|
|
178
177
|
self.agent = AsyncAgent(self.config)
|
|
178
|
+
self.workflow = AsyncWorkflow(self.config)
|
|
179
179
|
|
|
180
180
|
|
|
181
181
|
class AsyncChat:
|
|
@@ -205,3 +205,11 @@ class AsyncAgent:
|
|
|
205
205
|
config: Config,
|
|
206
206
|
):
|
|
207
207
|
self.completions = AsyncAgentCompletions(config)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
class AsyncWorkflow:
|
|
211
|
+
def __init__(
|
|
212
|
+
self,
|
|
213
|
+
config: Config,
|
|
214
|
+
):
|
|
215
|
+
self.completions = AsyncWorkflowCompletions(config)
|
|
@@ -6,9 +6,12 @@ import httpx
|
|
|
6
6
|
from maitai_common.version import version
|
|
7
7
|
|
|
8
8
|
try:
|
|
9
|
-
from
|
|
9
|
+
from opentelemetry import trace
|
|
10
|
+
|
|
11
|
+
from maitai_back.instrumentation.tracer import trace_span, tracer
|
|
10
12
|
except ImportError:
|
|
11
13
|
tracer = None
|
|
14
|
+
trace = None
|
|
12
15
|
|
|
13
16
|
# Common client settings to ensure consistency
|
|
14
17
|
CLIENT_SETTINGS = {
|
|
@@ -82,8 +85,11 @@ class MaitaiClient:
|
|
|
82
85
|
return self.maitai_host
|
|
83
86
|
|
|
84
87
|
def _determine_maitai_orchestration_host(self):
|
|
85
|
-
if
|
|
86
|
-
|
|
88
|
+
if maitai_agent_host := os.environ.get("MAITAI_AGENT_HOST"):
|
|
89
|
+
maitai_agent_host = maitai_agent_host.rstrip("/")
|
|
90
|
+
if maitai_agent_host.endswith("/agent"):
|
|
91
|
+
maitai_agent_host = maitai_agent_host[: -len("/agent")]
|
|
92
|
+
return maitai_agent_host.rstrip("/")
|
|
87
93
|
return self.maitai_host
|
|
88
94
|
|
|
89
95
|
def _determine_maitai_inference_host(self):
|
|
@@ -93,7 +99,7 @@ class MaitaiClient:
|
|
|
93
99
|
|
|
94
100
|
def get_client(self):
|
|
95
101
|
if tracer:
|
|
96
|
-
with tracer.
|
|
102
|
+
with tracer.start_as_current_span("get_client"):
|
|
97
103
|
return self._get_client()
|
|
98
104
|
return self._get_client()
|
|
99
105
|
|
|
@@ -107,24 +113,30 @@ class MaitaiClient:
|
|
|
107
113
|
|
|
108
114
|
def get_async_client(self):
|
|
109
115
|
if tracer:
|
|
110
|
-
with tracer.
|
|
116
|
+
with tracer.start_as_current_span("get_async_client"):
|
|
111
117
|
return self._get_async_client()
|
|
112
118
|
return self._get_async_client()
|
|
113
119
|
|
|
114
120
|
def _get_async_client(self):
|
|
115
|
-
span = None
|
|
116
121
|
if tracer:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
with tracer.start_as_current_span("create_async_client"):
|
|
123
|
+
if self._async_client is None:
|
|
124
|
+
self._async_client = httpx.AsyncClient(
|
|
125
|
+
**CLIENT_SETTINGS,
|
|
126
|
+
transport=httpx.AsyncHTTPTransport(
|
|
127
|
+
retries=DEFAULT_MAX_RETRIES, http2=True
|
|
128
|
+
),
|
|
129
|
+
)
|
|
130
|
+
return self._async_client
|
|
131
|
+
else:
|
|
132
|
+
if self._async_client is None:
|
|
133
|
+
self._async_client = httpx.AsyncClient(
|
|
134
|
+
**CLIENT_SETTINGS,
|
|
135
|
+
transport=httpx.AsyncHTTPTransport(
|
|
136
|
+
retries=DEFAULT_MAX_RETRIES, http2=True
|
|
137
|
+
),
|
|
138
|
+
)
|
|
139
|
+
return self._async_client
|
|
128
140
|
|
|
129
141
|
def cleanup(self):
|
|
130
142
|
try:
|
|
@@ -196,7 +208,7 @@ class MaitaiClient:
|
|
|
196
208
|
|
|
197
209
|
def init_sdk(self, api_key: str, host: str):
|
|
198
210
|
if tracer:
|
|
199
|
-
with tracer.
|
|
211
|
+
with tracer.start_as_current_span("init_sdk"):
|
|
200
212
|
return self._init_sdk(api_key, host)
|
|
201
213
|
return self._init_sdk(api_key, host)
|
|
202
214
|
|
|
@@ -176,12 +176,19 @@ def get_chat_completion_params(
|
|
|
176
176
|
] = openai.NOT_GIVEN,
|
|
177
177
|
top_logprobs: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
178
178
|
top_p: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
179
|
+
top_k: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
180
|
+
min_p: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
181
|
+
repetition_penalty: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
179
182
|
user: Union[str, openai.NotGiven] = openai.NOT_GIVEN,
|
|
180
183
|
parallel_tool_calls: Union[bool, openai.NotGiven] = openai.NOT_GIVEN,
|
|
181
184
|
reasoning_effort: Union[str, openai.NotGiven, None] = openai.NOT_GIVEN,
|
|
185
|
+
reasoning: Union[dict, chat_types.ReasoningConfig, openai.NotGiven, None] = (
|
|
186
|
+
openai.NOT_GIVEN
|
|
187
|
+
),
|
|
182
188
|
extra_headers: Union[
|
|
183
189
|
None, Headers, Dict[str, str], openai.NotGiven
|
|
184
190
|
] = openai.NOT_GIVEN,
|
|
191
|
+
extra_body: Union[dict, None] = None,
|
|
185
192
|
) -> Dict[str, Any]:
|
|
186
193
|
params = {
|
|
187
194
|
"messages": [msg for msg in messages],
|
|
@@ -197,6 +204,9 @@ def get_chat_completion_params(
|
|
|
197
204
|
"max_tokens": max_tokens,
|
|
198
205
|
"temperature": temperature,
|
|
199
206
|
"top_p": top_p,
|
|
207
|
+
"top_k": top_k,
|
|
208
|
+
"min_p": min_p,
|
|
209
|
+
"repetition_penalty": repetition_penalty,
|
|
200
210
|
"stop": stop,
|
|
201
211
|
"logprobs": logprobs,
|
|
202
212
|
"top_logprobs": top_logprobs,
|
|
@@ -217,6 +227,15 @@ def get_chat_completion_params(
|
|
|
217
227
|
if value != openai.NOT_GIVEN:
|
|
218
228
|
params[param_name] = value
|
|
219
229
|
|
|
230
|
+
if extra_body:
|
|
231
|
+
params["extra_body"] = extra_body
|
|
232
|
+
|
|
233
|
+
if reasoning != openai.NOT_GIVEN and reasoning is not None:
|
|
234
|
+
if hasattr(reasoning, "model_dump"):
|
|
235
|
+
params["reasoning"] = reasoning.model_dump(exclude_none=True)
|
|
236
|
+
else:
|
|
237
|
+
params["reasoning"] = reasoning
|
|
238
|
+
|
|
220
239
|
if stream_options != openai.NOT_GIVEN and stream_options:
|
|
221
240
|
params["stream_options"] = {
|
|
222
241
|
"include_usage": stream_options.get("include_usage")
|
|
@@ -310,6 +329,8 @@ def chat_completion_chunk_to_response(
|
|
|
310
329
|
def convert_params_to_groq(params: Dict[str, Any]) -> Dict[str, Any]:
|
|
311
330
|
if "reasoning_effort" in params:
|
|
312
331
|
del params["reasoning_effort"]
|
|
332
|
+
if "reasoning" in params:
|
|
333
|
+
del params["reasoning"]
|
|
313
334
|
if "stream_options" in params:
|
|
314
335
|
del params["stream_options"]
|
|
315
336
|
if (
|
|
@@ -12,9 +12,9 @@ class Completions(MaitaiClient):
|
|
|
12
12
|
def __init__(self, config: Config):
|
|
13
13
|
super().__init__()
|
|
14
14
|
self.config = config
|
|
15
|
-
# Initialize OpenAI client with Maitai
|
|
15
|
+
# Initialize OpenAI client with Maitai agent endpoint
|
|
16
16
|
self._openai_client = openai.OpenAI(
|
|
17
|
-
base_url=f"{self.config.maitai_orchestration_host.rstrip('/')}/
|
|
17
|
+
base_url=f"{self.config.maitai_orchestration_host.rstrip('/')}/agent",
|
|
18
18
|
api_key=self.config.api_key,
|
|
19
19
|
default_headers={"x-api-key": self.config.api_key},
|
|
20
20
|
)
|
|
@@ -71,6 +71,7 @@ class Completions(MaitaiClient):
|
|
|
71
71
|
"max_iterations": request.max_iterations,
|
|
72
72
|
"high_performance": request.high_performance,
|
|
73
73
|
"disable_chaining": request.disable_chaining,
|
|
74
|
+
"disable_strategy": request.disable_strategy,
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
# Remove None values from extra_body
|
|
@@ -12,9 +12,9 @@ class AsyncCompletions(MaitaiClient):
|
|
|
12
12
|
def __init__(self, config: Config):
|
|
13
13
|
super().__init__()
|
|
14
14
|
self.config = config
|
|
15
|
-
# Initialize OpenAI client with Maitai
|
|
15
|
+
# Initialize OpenAI client with Maitai agent endpoint
|
|
16
16
|
self._openai_client = openai.AsyncOpenAI(
|
|
17
|
-
base_url=f"{self.config.maitai_orchestration_host.rstrip('/')}/
|
|
17
|
+
base_url=f"{self.config.maitai_orchestration_host.rstrip('/')}/agent",
|
|
18
18
|
api_key=self.config.api_key,
|
|
19
19
|
default_headers={"x-api-key": self.config.api_key},
|
|
20
20
|
)
|
|
@@ -71,6 +71,7 @@ class AsyncCompletions(MaitaiClient):
|
|
|
71
71
|
"max_iterations": request.max_iterations,
|
|
72
72
|
"high_performance": request.high_performance,
|
|
73
73
|
"disable_chaining": request.disable_chaining,
|
|
74
|
+
"disable_strategy": request.disable_strategy,
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
# Remove None values from extra_body
|