vectorvein 0.1.8__py3-none-any.whl → 0.1.10__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.
@@ -25,7 +25,7 @@ def extract_tool_calls(response):
25
25
  "index": index,
26
26
  "id": tool_call["id"],
27
27
  "function": tool_call["function"],
28
- "type": tool_call["type"],
28
+ "type": "function",
29
29
  }
30
30
  for index, tool_call in enumerate(tool_calls)
31
31
  ]
@@ -59,6 +59,7 @@ class MiniMaxChatClient(BaseChatClient):
59
59
  endpoint_id,
60
60
  **kwargs,
61
61
  )
62
+ self.http_client = httpx.Client()
62
63
 
63
64
  def create_completion(
64
65
  self,
@@ -93,7 +94,7 @@ class MiniMaxChatClient(BaseChatClient):
93
94
  model=self.model_setting.id,
94
95
  )
95
96
 
96
- if tools is not None:
97
+ if tools:
97
98
  tools_params = {
98
99
  "tools": [
99
100
  {
@@ -136,27 +137,24 @@ class MiniMaxChatClient(BaseChatClient):
136
137
  **tools_params,
137
138
  }
138
139
 
139
- response = httpx.post(
140
- url=self.url,
141
- headers=self.headers,
142
- json=request_body,
143
- timeout=60,
144
- )
145
-
146
140
  if self.stream:
147
141
 
148
142
  def generator():
149
- for chunk in response.iter_lines():
150
- if chunk:
151
- chunk_data = json.loads(chunk[6:])
152
- tool_calls_params = extract_tool_calls(chunk_data)
153
- has_tool_calls = True if tool_calls_params else False
154
- if has_tool_calls:
155
- if "usage" not in chunk_data:
143
+ with self.http_client.stream(
144
+ "POST",
145
+ url=self.url,
146
+ headers=self.headers,
147
+ json=request_body,
148
+ timeout=60,
149
+ ) as response:
150
+ for chunk in response.iter_lines():
151
+ if chunk:
152
+ chunk_data = json.loads(chunk[6:])
153
+ if chunk_data["object"] != "chat.completion.chunk":
156
154
  continue
157
- else:
158
- if chunk_data["object"] != "chat.completion.chunk":
159
- continue
155
+ tool_calls_params = extract_tool_calls(chunk_data)
156
+ has_tool_calls = True if tool_calls_params else False
157
+ if has_tool_calls:
160
158
  yield ChatCompletionDeltaMessage(
161
159
  **{
162
160
  "content": chunk_data["choices"][0]["delta"].get("content"),
@@ -164,18 +162,22 @@ class MiniMaxChatClient(BaseChatClient):
164
162
  **tool_calls_params,
165
163
  }
166
164
  )
167
- else:
168
- if "usage" in chunk_data:
169
- continue
170
- yield ChatCompletionDeltaMessage(
171
- **{
172
- "content": chunk_data["choices"][0]["delta"]["content"],
173
- "role": "assistant",
174
- }
175
- )
165
+ else:
166
+ yield ChatCompletionDeltaMessage(
167
+ **{
168
+ "content": chunk_data["choices"][0]["delta"]["content"],
169
+ "role": "assistant",
170
+ }
171
+ )
176
172
 
177
173
  return generator()
178
174
  else:
175
+ response = httpx.post(
176
+ url=self.url,
177
+ headers=self.headers,
178
+ json=request_body,
179
+ timeout=60,
180
+ )
179
181
  result = response.json()
180
182
  tool_calls_params = extract_tool_calls(result)
181
183
  return ChatCompletionMessage(
@@ -250,7 +252,7 @@ class AsyncMiniMaxChatClient(BaseAsyncChatClient):
250
252
  model=self.model_setting.id,
251
253
  )
252
254
 
253
- if tools is not None:
255
+ if tools:
254
256
  tools_params = {
255
257
  "tools": [
256
258
  {
@@ -305,24 +307,19 @@ class AsyncMiniMaxChatClient(BaseAsyncChatClient):
305
307
  async for chunk in response.aiter_lines():
306
308
  if chunk:
307
309
  chunk_data = json.loads(chunk[6:])
310
+ if chunk_data["object"] != "chat.completion.chunk":
311
+ continue
308
312
  tool_calls_params = extract_tool_calls(chunk_data)
309
313
  has_tool_calls = True if tool_calls_params else False
310
314
  if has_tool_calls:
311
- if "usage" not in chunk_data:
312
- continue
313
- else:
314
- if chunk_data["object"] != "chat.completion.chunk":
315
- continue
316
- yield ChatCompletionDeltaMessage(
317
- **{
318
- "content": chunk_data["choices"][0]["delta"].get("content"),
319
- "role": "assistant",
320
- **tool_calls_params,
321
- }
322
- )
315
+ yield ChatCompletionDeltaMessage(
316
+ **{
317
+ "content": chunk_data["choices"][0]["delta"].get("content"),
318
+ "role": "assistant",
319
+ **tool_calls_params,
320
+ }
321
+ )
323
322
  else:
324
- if "usage" in chunk_data:
325
- continue
326
323
  yield ChatCompletionDeltaMessage(
327
324
  **{
328
325
  "content": chunk_data["choices"][0]["delta"]["content"],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: Default template for PDM package
5
5
  Author-Email: Anderson <andersonby@163.com>
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
- vectorvein-0.1.8.dist-info/METADATA,sha256=3gBxjxgbrdsbA4Xwc3MkuCct-9VFuuM0X9hfSj6sGt4,501
2
- vectorvein-0.1.8.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
1
+ vectorvein-0.1.10.dist-info/METADATA,sha256=9xKzC4bU-2nWl6CavXiKnv3VvQB6ZZn6obbaRLOWZqA,502
2
+ vectorvein-0.1.10.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
3
3
  vectorvein/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  vectorvein/chat_clients/__init__.py,sha256=5j7W--jr-l2cqDJp38uXYvkydDK0rnzm7MYGSACHKmU,3976
5
5
  vectorvein/chat_clients/anthropic_client.py,sha256=JjigSUsIn06ixIEjnOJhVbcMqy2_MAL3iVUlDFAFMW4,20008
@@ -8,7 +8,7 @@ vectorvein/chat_clients/deepseek_client.py,sha256=3qWu01NlJAP2N-Ff62d5-CZXZitliz
8
8
  vectorvein/chat_clients/gemini_client.py,sha256=IHcBHTSHkj3f962S5L7Ga-XA-96sq8quIDRZpoqvGss,13653
9
9
  vectorvein/chat_clients/groq_client.py,sha256=Uow4pgdmFi93ZQSoOol2-0PhhqkW-S0XuSldvppz5U4,498
10
10
  vectorvein/chat_clients/local_client.py,sha256=55nOsxzqUf79q3Y14MKROA71zxhsT7p7FsDZ89rts2M,422
11
- vectorvein/chat_clients/minimax_client.py,sha256=iC60QnLQRb5Y0B6_vorL9wkZx1Gs9w9znm8zil4uJ-g,13588
11
+ vectorvein/chat_clients/minimax_client.py,sha256=ZnRiy1lxwkEugA8VnRLz6HHj2kwAWQ7UmMMwR5UkgyA,13398
12
12
  vectorvein/chat_clients/mistral_client.py,sha256=1aKSylzBDaLYcFnaBIL4-sXSzWmXfBeON9Q0rq-ziWw,534
13
13
  vectorvein/chat_clients/moonshot_client.py,sha256=gbu-6nGxx8uM_U2WlI4Wus881rFRotzHtMSoYOcruGU,526
14
14
  vectorvein/chat_clients/openai_client.py,sha256=Nz6tV45pWcsOupxjnsRsGTicbQNJWIZyxuJoJ5DGMpg,527
@@ -23,4 +23,4 @@ vectorvein/types/enums.py,sha256=vzOenCnRlFXBwPh-lfFhjGfM-6yfDj7wZColHODqocI,155
23
23
  vectorvein/types/llm_parameters.py,sha256=nBjStC2zndTY__yhD2WFXB09taxEhDLE3OHA6MICfgE,3494
24
24
  vectorvein/utilities/media_processing.py,sha256=BujciRmw1GMmc3ELRvafL8STcy6r5b2rVnh27-uA7so,2256
25
25
  vectorvein/utilities/retry.py,sha256=9ePuJdeUUGx-qMWfaFxmlOvG_lQPwCQ4UB1z3Edlo34,993
26
- vectorvein-0.1.8.dist-info/RECORD,,
26
+ vectorvein-0.1.10.dist-info/RECORD,,