vectorvein 0.1.46__py3-none-any.whl → 0.1.48__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.
@@ -148,6 +148,7 @@ class BaseChatClient(ABC):
148
148
  tools=tools,
149
149
  tool_choice=tool_choice,
150
150
  response_format=response_format,
151
+ stream_options=stream_options,
151
152
  **kwargs,
152
153
  )
153
154
 
@@ -6,8 +6,6 @@ from functools import cached_property
6
6
  from typing import overload, Generator, AsyncGenerator, Any, Literal, Iterable
7
7
 
8
8
  import httpx
9
- from openai._streaming import Stream, AsyncStream
10
- from openai.types.chat import ChatCompletion, ChatCompletionChunk
11
9
  from openai import OpenAI, AsyncOpenAI, AzureOpenAI, AsyncAzureOpenAI
12
10
 
13
11
  from .base_client import BaseChatClient, BaseAsyncChatClient
@@ -202,7 +200,7 @@ class OpenAICompatibleChatClient(BaseChatClient):
202
200
  _stream_options_params = {}
203
201
 
204
202
  if self.stream:
205
- stream_response: Stream[ChatCompletionChunk] = raw_client.chat.completions.create(
203
+ stream_response = raw_client.chat.completions.create(
206
204
  model=self.model_id,
207
205
  messages=messages,
208
206
  stream=True,
@@ -225,11 +223,14 @@ class OpenAICompatibleChatClient(BaseChatClient):
225
223
  prompt_tokens=chunk.usage.prompt_tokens or 0,
226
224
  total_tokens=chunk.usage.total_tokens or 0,
227
225
  )
228
- else:
229
- usage = None
226
+
230
227
  if len(chunk.choices) == 0:
228
+ if usage:
229
+ yield ChatCompletionDeltaMessage(usage=usage)
231
230
  continue
232
231
  if not chunk.choices[0].delta:
232
+ if usage:
233
+ yield ChatCompletionDeltaMessage(usage=usage)
233
234
  continue
234
235
  if self.model_setting.function_call_available:
235
236
  if chunk.choices[0].delta.tool_calls:
@@ -253,7 +254,7 @@ class OpenAICompatibleChatClient(BaseChatClient):
253
254
 
254
255
  return generator()
255
256
  else:
256
- response: ChatCompletion = raw_client.chat.completions.create(
257
+ response = raw_client.chat.completions.create(
257
258
  model=self.model_id,
258
259
  messages=messages,
259
260
  stream=False,
@@ -453,7 +454,7 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
453
454
  max_tokens = self.model_setting.context_length - token_counts - 64
454
455
 
455
456
  if self.stream:
456
- stream_response: AsyncStream[ChatCompletionChunk] = await raw_client.chat.completions.create(
457
+ stream_response = await raw_client.chat.completions.create(
457
458
  model=self.model_id,
458
459
  messages=messages,
459
460
  stream=self.stream,
@@ -476,12 +477,16 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
476
477
  prompt_tokens=chunk.usage.prompt_tokens or 0,
477
478
  total_tokens=chunk.usage.total_tokens or 0,
478
479
  )
479
- else:
480
- usage = None
480
+
481
481
  if len(chunk.choices) == 0:
482
+ if usage:
483
+ yield ChatCompletionDeltaMessage(usage=usage)
482
484
  continue
483
485
  if not chunk.choices[0].delta:
486
+ if usage:
487
+ yield ChatCompletionDeltaMessage(usage=usage)
484
488
  continue
489
+
485
490
  if self.model_setting.function_call_available:
486
491
  if chunk.choices[0].delta.tool_calls:
487
492
  for index, tool_call in enumerate(chunk.choices[0].delta.tool_calls):
@@ -504,7 +509,7 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
504
509
 
505
510
  return generator()
506
511
  else:
507
- response: ChatCompletion = await raw_client.chat.completions.create(
512
+ response = await raw_client.chat.completions.create(
508
513
  model=self.model_id,
509
514
  messages=messages,
510
515
  stream=self.stream,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.1.46
3
+ Version: 0.1.48
4
4
  Summary: Default template for PDM package
5
5
  Author-Email: Anderson <andersonby@163.com>
6
6
  License: MIT
@@ -1,11 +1,11 @@
1
- vectorvein-0.1.46.dist-info/METADATA,sha256=36D8mKjmVS10vBTLPCUu1sMLJoJQWV4SQS_AQeFJRN4,644
2
- vectorvein-0.1.46.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- vectorvein-0.1.46.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
1
+ vectorvein-0.1.48.dist-info/METADATA,sha256=J6bEBBrKiwUMNvIysDT5W-V8fDFhdwIYPjWBYXmFRKM,644
2
+ vectorvein-0.1.48.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ vectorvein-0.1.48.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
4
  vectorvein/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  vectorvein/chat_clients/__init__.py,sha256=dW169oK1n3v8Z0uD8itghzlCP72rxiaS-XYn6fvI2xM,16788
6
6
  vectorvein/chat_clients/anthropic_client.py,sha256=i1fMYSkUovd-Lc9B64bWMgzSTUFw4S3fj3AJ_pDokT4,34029
7
7
  vectorvein/chat_clients/baichuan_client.py,sha256=CVMvpgjdrZGv0BWnTOBD-f2ufZ3wq3496wqukumsAr4,526
8
- vectorvein/chat_clients/base_client.py,sha256=4IYRAfRt9jk1nuUh7e57boaI7_WHR31fJKvvRkt3RDE,9454
8
+ vectorvein/chat_clients/base_client.py,sha256=0Uj0e-JR0a68sRS_WfUMVd91Av7lzJh6-DukjutlaD0,9497
9
9
  vectorvein/chat_clients/deepseek_client.py,sha256=3qWu01NlJAP2N-Ff62d5-CZXZitlizE1fzb20LNetig,526
10
10
  vectorvein/chat_clients/gemini_client.py,sha256=TJZUP8dbufuDnqkRI_gxIDDCYHrIhMPCqKGI6sSwqZo,19860
11
11
  vectorvein/chat_clients/groq_client.py,sha256=Uow4pgdmFi93ZQSoOol2-0PhhqkW-S0XuSldvppz5U4,498
@@ -14,7 +14,7 @@ vectorvein/chat_clients/minimax_client.py,sha256=cLpSJ5vIaDi0Kmrt7XGlbjnlFnByJiI
14
14
  vectorvein/chat_clients/mistral_client.py,sha256=1aKSylzBDaLYcFnaBIL4-sXSzWmXfBeON9Q0rq-ziWw,534
15
15
  vectorvein/chat_clients/moonshot_client.py,sha256=gbu-6nGxx8uM_U2WlI4Wus881rFRotzHtMSoYOcruGU,526
16
16
  vectorvein/chat_clients/openai_client.py,sha256=Nz6tV45pWcsOupxjnsRsGTicbQNJWIZyxuJoJ5DGMpg,527
17
- vectorvein/chat_clients/openai_compatible_client.py,sha256=CUylVzn-1bYB27gDDUVtfjxeSqG7yirFssNFW2dpBaQ,21941
17
+ vectorvein/chat_clients/openai_compatible_client.py,sha256=D2VmhpDVct4w2y58s87An7x22koOdkxSOKR2-so9lJI,22044
18
18
  vectorvein/chat_clients/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  vectorvein/chat_clients/qwen_client.py,sha256=-ryh-m9PgsO0fc4ulcCmPTy1155J8YUy15uPoJQOHA0,513
20
20
  vectorvein/chat_clients/stepfun_client.py,sha256=zsD2W5ahmR4DD9cqQTXmJr3txrGuvxbRWhFlRdwNijI,519
@@ -32,4 +32,4 @@ vectorvein/types/llm_parameters.py,sha256=5o-C_yXxxQWZy_e8OWowB2107GTS-Eawx4Mvb1
32
32
  vectorvein/types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  vectorvein/utilities/media_processing.py,sha256=cnzLrU1OaJvSv87IOnc36FrDXtmGMDStPbxtIJ33YN4,5880
34
34
  vectorvein/utilities/retry.py,sha256=6KFS9R2HdhqM3_9jkjD4F36ZSpEx2YNFGOVlpOsUetM,2208
35
- vectorvein-0.1.46.dist-info/RECORD,,
35
+ vectorvein-0.1.48.dist-info/RECORD,,