vectorvein 0.2.7__py3-none-any.whl → 0.2.9__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.
- vectorvein/chat_clients/__init__.py +582 -582
- vectorvein/chat_clients/anthropic_client.py +309 -32
- vectorvein/chat_clients/base_client.py +302 -24
- vectorvein/chat_clients/openai_compatible_client.py +312 -38
- vectorvein/types/llm_parameters.py +9 -1
- {vectorvein-0.2.7.dist-info → vectorvein-0.2.9.dist-info}/METADATA +2 -2
- {vectorvein-0.2.7.dist-info → vectorvein-0.2.9.dist-info}/RECORD +9 -9
- {vectorvein-0.2.7.dist-info → vectorvein-0.2.9.dist-info}/WHEEL +0 -0
- {vectorvein-0.2.7.dist-info → vectorvein-0.2.9.dist-info}/entry_points.txt +0 -0
@@ -1,12 +1,21 @@
|
|
1
1
|
# @Author: Bi Ying
|
2
2
|
# @Date: 2024-07-26 14:48:55
|
3
|
+
import re
|
3
4
|
import json
|
4
5
|
from functools import cached_property
|
5
|
-
from typing import overload, Generator, AsyncGenerator, Any, Literal, Iterable
|
6
|
-
import re
|
6
|
+
from typing import overload, Generator, AsyncGenerator, Any, Literal, Iterable, Optional, Dict, List, Union
|
7
7
|
|
8
8
|
import httpx
|
9
9
|
from openai import OpenAI, AsyncOpenAI, AzureOpenAI, AsyncAzureOpenAI
|
10
|
+
from openai._types import Headers, Query, Body
|
11
|
+
from openai.types.shared_params.metadata import Metadata
|
12
|
+
from openai.types.chat.completion_create_params import ResponseFormat
|
13
|
+
from openai.types.chat.chat_completion_modality import ChatCompletionModality
|
14
|
+
from openai.types.chat.chat_completion_audio_param import ChatCompletionAudioParam
|
15
|
+
from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
16
|
+
from openai.types.chat.chat_completion_stream_options_param import ChatCompletionStreamOptionsParam
|
17
|
+
from openai.types.chat.chat_completion_prediction_content_param import ChatCompletionPredictionContentParam
|
18
|
+
from anthropic.types.thinking_config_param import ThinkingConfigParam
|
10
19
|
|
11
20
|
from .base_client import BaseChatClient, BaseAsyncChatClient
|
12
21
|
from .utils import (
|
@@ -20,6 +29,7 @@ from ..types.enums import ContextLengthControlType, BackendType
|
|
20
29
|
from ..types.llm_parameters import (
|
21
30
|
NotGiven,
|
22
31
|
NOT_GIVEN,
|
32
|
+
OPENAI_NOT_GIVEN,
|
23
33
|
ToolParam,
|
24
34
|
ToolChoice,
|
25
35
|
OpenAINotGiven,
|
@@ -27,7 +37,6 @@ from ..types.llm_parameters import (
|
|
27
37
|
Usage,
|
28
38
|
ChatCompletionMessage,
|
29
39
|
ChatCompletionDeltaMessage,
|
30
|
-
ChatCompletionStreamOptionsParam,
|
31
40
|
)
|
32
41
|
|
33
42
|
|
@@ -93,11 +102,33 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
93
102
|
max_tokens: int | None = None,
|
94
103
|
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
|
95
104
|
tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
|
96
|
-
response_format:
|
105
|
+
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
|
97
106
|
stream_options: ChatCompletionStreamOptionsParam | None | OpenAINotGiven = NOT_GIVEN,
|
98
107
|
top_p: float | NotGiven | None = NOT_GIVEN,
|
99
108
|
skip_cutoff: bool = False,
|
100
|
-
|
109
|
+
audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = NOT_GIVEN,
|
110
|
+
frequency_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
111
|
+
logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = NOT_GIVEN,
|
112
|
+
logprobs: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
113
|
+
max_completion_tokens: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
114
|
+
metadata: Optional[Metadata] | OpenAINotGiven = NOT_GIVEN,
|
115
|
+
modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = NOT_GIVEN,
|
116
|
+
n: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
117
|
+
parallel_tool_calls: bool | OpenAINotGiven = NOT_GIVEN,
|
118
|
+
prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = NOT_GIVEN,
|
119
|
+
presence_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
120
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = NOT_GIVEN,
|
121
|
+
thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
|
122
|
+
seed: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
123
|
+
service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = NOT_GIVEN,
|
124
|
+
stop: Union[Optional[str], List[str]] | OpenAINotGiven = NOT_GIVEN,
|
125
|
+
store: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
126
|
+
top_logprobs: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
127
|
+
user: str | OpenAINotGiven = NOT_GIVEN,
|
128
|
+
extra_headers: Headers | None = None,
|
129
|
+
extra_query: Query | None = None,
|
130
|
+
extra_body: Body | None = None,
|
131
|
+
timeout: float | httpx.Timeout | None | OpenAINotGiven = NOT_GIVEN,
|
101
132
|
) -> ChatCompletionMessage:
|
102
133
|
pass
|
103
134
|
|
@@ -112,11 +143,33 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
112
143
|
max_tokens: int | None = None,
|
113
144
|
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
|
114
145
|
tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
|
115
|
-
response_format:
|
146
|
+
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
|
116
147
|
stream_options: ChatCompletionStreamOptionsParam | None | OpenAINotGiven = NOT_GIVEN,
|
117
148
|
top_p: float | NotGiven | None = NOT_GIVEN,
|
118
149
|
skip_cutoff: bool = False,
|
119
|
-
|
150
|
+
audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = NOT_GIVEN,
|
151
|
+
frequency_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
152
|
+
logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = NOT_GIVEN,
|
153
|
+
logprobs: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
154
|
+
max_completion_tokens: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
155
|
+
metadata: Optional[Metadata] | OpenAINotGiven = NOT_GIVEN,
|
156
|
+
modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = NOT_GIVEN,
|
157
|
+
n: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
158
|
+
parallel_tool_calls: bool | OpenAINotGiven = NOT_GIVEN,
|
159
|
+
prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = NOT_GIVEN,
|
160
|
+
presence_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
161
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = NOT_GIVEN,
|
162
|
+
thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
|
163
|
+
seed: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
164
|
+
service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = NOT_GIVEN,
|
165
|
+
stop: Union[Optional[str], List[str]] | OpenAINotGiven = NOT_GIVEN,
|
166
|
+
store: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
167
|
+
top_logprobs: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
168
|
+
user: str | OpenAINotGiven = NOT_GIVEN,
|
169
|
+
extra_headers: Headers | None = None,
|
170
|
+
extra_query: Query | None = None,
|
171
|
+
extra_body: Body | None = None,
|
172
|
+
timeout: float | httpx.Timeout | None | OpenAINotGiven = NOT_GIVEN,
|
120
173
|
) -> Generator[ChatCompletionDeltaMessage, None, None]:
|
121
174
|
pass
|
122
175
|
|
@@ -131,11 +184,33 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
131
184
|
max_tokens: int | None = None,
|
132
185
|
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
|
133
186
|
tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
|
134
|
-
response_format:
|
187
|
+
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
|
135
188
|
stream_options: ChatCompletionStreamOptionsParam | None | OpenAINotGiven = NOT_GIVEN,
|
136
189
|
top_p: float | NotGiven | None = NOT_GIVEN,
|
137
190
|
skip_cutoff: bool = False,
|
138
|
-
|
191
|
+
audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = NOT_GIVEN,
|
192
|
+
frequency_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
193
|
+
logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = NOT_GIVEN,
|
194
|
+
logprobs: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
195
|
+
max_completion_tokens: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
196
|
+
metadata: Optional[Metadata] | OpenAINotGiven = NOT_GIVEN,
|
197
|
+
modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = NOT_GIVEN,
|
198
|
+
n: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
199
|
+
parallel_tool_calls: bool | OpenAINotGiven = NOT_GIVEN,
|
200
|
+
prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = NOT_GIVEN,
|
201
|
+
presence_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
202
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = NOT_GIVEN,
|
203
|
+
thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
|
204
|
+
seed: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
205
|
+
service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = NOT_GIVEN,
|
206
|
+
stop: Union[Optional[str], List[str]] | OpenAINotGiven = NOT_GIVEN,
|
207
|
+
store: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
208
|
+
top_logprobs: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
209
|
+
user: str | OpenAINotGiven = NOT_GIVEN,
|
210
|
+
extra_headers: Headers | None = None,
|
211
|
+
extra_query: Query | None = None,
|
212
|
+
extra_body: Body | None = None,
|
213
|
+
timeout: float | httpx.Timeout | None | OpenAINotGiven = NOT_GIVEN,
|
139
214
|
) -> ChatCompletionMessage | Generator[ChatCompletionDeltaMessage, Any, None]:
|
140
215
|
pass
|
141
216
|
|
@@ -149,11 +224,33 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
149
224
|
max_tokens: int | None = None,
|
150
225
|
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
|
151
226
|
tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
|
152
|
-
response_format:
|
227
|
+
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
|
153
228
|
stream_options: ChatCompletionStreamOptionsParam | None | OpenAINotGiven = NOT_GIVEN,
|
154
229
|
top_p: float | NotGiven | None = NOT_GIVEN,
|
155
230
|
skip_cutoff: bool = False,
|
156
|
-
|
231
|
+
audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = NOT_GIVEN,
|
232
|
+
frequency_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
233
|
+
logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = NOT_GIVEN,
|
234
|
+
logprobs: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
235
|
+
max_completion_tokens: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
236
|
+
metadata: Optional[Metadata] | OpenAINotGiven = NOT_GIVEN,
|
237
|
+
modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = NOT_GIVEN,
|
238
|
+
n: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
239
|
+
parallel_tool_calls: bool | OpenAINotGiven = NOT_GIVEN,
|
240
|
+
prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = NOT_GIVEN,
|
241
|
+
presence_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
242
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = NOT_GIVEN,
|
243
|
+
thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
|
244
|
+
seed: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
245
|
+
service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = NOT_GIVEN,
|
246
|
+
stop: Union[Optional[str], List[str]] | OpenAINotGiven = NOT_GIVEN,
|
247
|
+
store: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
248
|
+
top_logprobs: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
249
|
+
user: str | OpenAINotGiven = NOT_GIVEN,
|
250
|
+
extra_headers: Headers | None = None,
|
251
|
+
extra_query: Query | None = None,
|
252
|
+
extra_body: Body | None = None,
|
253
|
+
timeout: float | httpx.Timeout | None | OpenAINotGiven = NOT_GIVEN,
|
157
254
|
):
|
158
255
|
if model is not None:
|
159
256
|
self.model = model
|
@@ -221,11 +318,6 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
221
318
|
else:
|
222
319
|
self.response_format = {}
|
223
320
|
|
224
|
-
if stream_options:
|
225
|
-
_stream_options_params = {"stream_options": stream_options}
|
226
|
-
else:
|
227
|
-
_stream_options_params = {}
|
228
|
-
|
229
321
|
self._acquire_rate_limit(self.endpoint, self.model, messages)
|
230
322
|
|
231
323
|
if self.stream:
|
@@ -236,10 +328,33 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
236
328
|
temperature=self.temperature,
|
237
329
|
max_tokens=max_tokens,
|
238
330
|
top_p=top_p,
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
331
|
+
audio=audio,
|
332
|
+
frequency_penalty=frequency_penalty,
|
333
|
+
logit_bias=logit_bias,
|
334
|
+
logprobs=logprobs,
|
335
|
+
max_completion_tokens=max_completion_tokens,
|
336
|
+
metadata=metadata,
|
337
|
+
modalities=modalities,
|
338
|
+
n=n,
|
339
|
+
parallel_tool_calls=parallel_tool_calls,
|
340
|
+
prediction=prediction,
|
341
|
+
presence_penalty=presence_penalty,
|
342
|
+
reasoning_effort=reasoning_effort,
|
343
|
+
seed=seed,
|
344
|
+
service_tier=service_tier,
|
345
|
+
stop=stop,
|
346
|
+
store=store,
|
347
|
+
top_logprobs=top_logprobs,
|
348
|
+
user=user,
|
349
|
+
extra_headers=extra_headers,
|
350
|
+
extra_query=extra_query,
|
351
|
+
extra_body=extra_body,
|
352
|
+
timeout=timeout,
|
353
|
+
stream_options=stream_options,
|
354
|
+
response_format=response_format
|
355
|
+
if response_format and self.model_setting.response_format_available
|
356
|
+
else OPENAI_NOT_GIVEN,
|
357
|
+
**tools_params, # type: ignore
|
243
358
|
)
|
244
359
|
|
245
360
|
def generator():
|
@@ -341,9 +456,33 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
341
456
|
temperature=self.temperature,
|
342
457
|
max_tokens=max_tokens,
|
343
458
|
top_p=top_p,
|
344
|
-
|
345
|
-
|
346
|
-
|
459
|
+
audio=audio,
|
460
|
+
frequency_penalty=frequency_penalty,
|
461
|
+
logit_bias=logit_bias,
|
462
|
+
logprobs=logprobs,
|
463
|
+
max_completion_tokens=max_completion_tokens,
|
464
|
+
metadata=metadata,
|
465
|
+
modalities=modalities,
|
466
|
+
n=n,
|
467
|
+
parallel_tool_calls=parallel_tool_calls,
|
468
|
+
prediction=prediction,
|
469
|
+
presence_penalty=presence_penalty,
|
470
|
+
reasoning_effort=reasoning_effort,
|
471
|
+
seed=seed,
|
472
|
+
service_tier=service_tier,
|
473
|
+
stop=stop,
|
474
|
+
store=store,
|
475
|
+
top_logprobs=top_logprobs,
|
476
|
+
user=user,
|
477
|
+
extra_headers=extra_headers,
|
478
|
+
extra_query=extra_query,
|
479
|
+
extra_body=extra_body,
|
480
|
+
timeout=timeout,
|
481
|
+
stream_options=stream_options,
|
482
|
+
response_format=response_format
|
483
|
+
if response_format and self.model_setting.response_format_available
|
484
|
+
else OPENAI_NOT_GIVEN,
|
485
|
+
**tools_params, # type: ignore
|
347
486
|
)
|
348
487
|
|
349
488
|
result = {
|
@@ -436,11 +575,33 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
|
|
436
575
|
max_tokens: int | None = None,
|
437
576
|
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
|
438
577
|
tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
|
439
|
-
response_format:
|
578
|
+
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
|
440
579
|
stream_options: ChatCompletionStreamOptionsParam | None | OpenAINotGiven = NOT_GIVEN,
|
441
580
|
top_p: float | NotGiven | None = NOT_GIVEN,
|
442
581
|
skip_cutoff: bool = False,
|
443
|
-
|
582
|
+
audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = NOT_GIVEN,
|
583
|
+
frequency_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
584
|
+
logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = NOT_GIVEN,
|
585
|
+
logprobs: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
586
|
+
max_completion_tokens: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
587
|
+
metadata: Optional[Metadata] | OpenAINotGiven = NOT_GIVEN,
|
588
|
+
modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = NOT_GIVEN,
|
589
|
+
n: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
590
|
+
parallel_tool_calls: bool | OpenAINotGiven = NOT_GIVEN,
|
591
|
+
prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = NOT_GIVEN,
|
592
|
+
presence_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
593
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = NOT_GIVEN,
|
594
|
+
thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
|
595
|
+
seed: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
596
|
+
service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = NOT_GIVEN,
|
597
|
+
stop: Union[Optional[str], List[str]] | OpenAINotGiven = NOT_GIVEN,
|
598
|
+
store: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
599
|
+
top_logprobs: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
600
|
+
user: str | OpenAINotGiven = NOT_GIVEN,
|
601
|
+
extra_headers: Headers | None = None,
|
602
|
+
extra_query: Query | None = None,
|
603
|
+
extra_body: Body | None = None,
|
604
|
+
timeout: float | httpx.Timeout | None | OpenAINotGiven = NOT_GIVEN,
|
444
605
|
) -> ChatCompletionMessage:
|
445
606
|
pass
|
446
607
|
|
@@ -455,11 +616,33 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
|
|
455
616
|
max_tokens: int | None = None,
|
456
617
|
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
|
457
618
|
tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
|
458
|
-
response_format:
|
619
|
+
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
|
459
620
|
stream_options: ChatCompletionStreamOptionsParam | None | OpenAINotGiven = NOT_GIVEN,
|
460
621
|
top_p: float | NotGiven | None = NOT_GIVEN,
|
461
622
|
skip_cutoff: bool = False,
|
462
|
-
|
623
|
+
audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = NOT_GIVEN,
|
624
|
+
frequency_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
625
|
+
logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = NOT_GIVEN,
|
626
|
+
logprobs: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
627
|
+
max_completion_tokens: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
628
|
+
metadata: Optional[Metadata] | OpenAINotGiven = NOT_GIVEN,
|
629
|
+
modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = NOT_GIVEN,
|
630
|
+
n: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
631
|
+
parallel_tool_calls: bool | OpenAINotGiven = NOT_GIVEN,
|
632
|
+
prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = NOT_GIVEN,
|
633
|
+
presence_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
634
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = NOT_GIVEN,
|
635
|
+
thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
|
636
|
+
seed: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
637
|
+
service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = NOT_GIVEN,
|
638
|
+
stop: Union[Optional[str], List[str]] | OpenAINotGiven = NOT_GIVEN,
|
639
|
+
store: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
640
|
+
top_logprobs: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
641
|
+
user: str | OpenAINotGiven = NOT_GIVEN,
|
642
|
+
extra_headers: Headers | None = None,
|
643
|
+
extra_query: Query | None = None,
|
644
|
+
extra_body: Body | None = None,
|
645
|
+
timeout: float | httpx.Timeout | None | OpenAINotGiven = NOT_GIVEN,
|
463
646
|
) -> AsyncGenerator[ChatCompletionDeltaMessage, Any]:
|
464
647
|
pass
|
465
648
|
|
@@ -474,11 +657,33 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
|
|
474
657
|
max_tokens: int | None = None,
|
475
658
|
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
|
476
659
|
tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
|
477
|
-
response_format:
|
660
|
+
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
|
478
661
|
stream_options: ChatCompletionStreamOptionsParam | None | OpenAINotGiven = NOT_GIVEN,
|
479
662
|
top_p: float | NotGiven | None = NOT_GIVEN,
|
480
663
|
skip_cutoff: bool = False,
|
481
|
-
|
664
|
+
audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = NOT_GIVEN,
|
665
|
+
frequency_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
666
|
+
logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = NOT_GIVEN,
|
667
|
+
logprobs: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
668
|
+
max_completion_tokens: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
669
|
+
metadata: Optional[Metadata] | OpenAINotGiven = NOT_GIVEN,
|
670
|
+
modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = NOT_GIVEN,
|
671
|
+
n: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
672
|
+
parallel_tool_calls: bool | OpenAINotGiven = NOT_GIVEN,
|
673
|
+
prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = NOT_GIVEN,
|
674
|
+
presence_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
675
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = NOT_GIVEN,
|
676
|
+
thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
|
677
|
+
seed: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
678
|
+
service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = NOT_GIVEN,
|
679
|
+
stop: Union[Optional[str], List[str]] | OpenAINotGiven = NOT_GIVEN,
|
680
|
+
store: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
681
|
+
top_logprobs: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
682
|
+
user: str | OpenAINotGiven = NOT_GIVEN,
|
683
|
+
extra_headers: Headers | None = None,
|
684
|
+
extra_query: Query | None = None,
|
685
|
+
extra_body: Body | None = None,
|
686
|
+
timeout: float | httpx.Timeout | None | OpenAINotGiven = NOT_GIVEN,
|
482
687
|
) -> ChatCompletionMessage | AsyncGenerator[ChatCompletionDeltaMessage, Any]:
|
483
688
|
pass
|
484
689
|
|
@@ -492,11 +697,33 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
|
|
492
697
|
max_tokens: int | None = None,
|
493
698
|
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
|
494
699
|
tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
|
495
|
-
response_format:
|
700
|
+
response_format: ResponseFormat | NotGiven = NOT_GIVEN,
|
496
701
|
stream_options: ChatCompletionStreamOptionsParam | None | OpenAINotGiven = NOT_GIVEN,
|
497
702
|
top_p: float | NotGiven | None = NOT_GIVEN,
|
498
703
|
skip_cutoff: bool = False,
|
499
|
-
|
704
|
+
audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = NOT_GIVEN,
|
705
|
+
frequency_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
706
|
+
logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = NOT_GIVEN,
|
707
|
+
logprobs: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
708
|
+
max_completion_tokens: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
709
|
+
metadata: Optional[Metadata] | OpenAINotGiven = NOT_GIVEN,
|
710
|
+
modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = NOT_GIVEN,
|
711
|
+
n: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
712
|
+
parallel_tool_calls: bool | OpenAINotGiven = NOT_GIVEN,
|
713
|
+
prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = NOT_GIVEN,
|
714
|
+
presence_penalty: Optional[float] | OpenAINotGiven = NOT_GIVEN,
|
715
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = NOT_GIVEN,
|
716
|
+
thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
|
717
|
+
seed: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
718
|
+
service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = NOT_GIVEN,
|
719
|
+
stop: Union[Optional[str], List[str]] | OpenAINotGiven = NOT_GIVEN,
|
720
|
+
store: Optional[bool] | OpenAINotGiven = NOT_GIVEN,
|
721
|
+
top_logprobs: Optional[int] | OpenAINotGiven = NOT_GIVEN,
|
722
|
+
user: str | OpenAINotGiven = NOT_GIVEN,
|
723
|
+
extra_headers: Headers | None = None,
|
724
|
+
extra_query: Query | None = None,
|
725
|
+
extra_body: Body | None = None,
|
726
|
+
timeout: float | httpx.Timeout | None | OpenAINotGiven = NOT_GIVEN,
|
500
727
|
):
|
501
728
|
if model is not None:
|
502
729
|
self.model = model
|
@@ -579,10 +806,33 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
|
|
579
806
|
temperature=self.temperature,
|
580
807
|
max_tokens=max_tokens, # Azure 的 OpenAI 怎么 stream 模式不支持 max_completion_tokens
|
581
808
|
top_p=top_p,
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
809
|
+
audio=audio,
|
810
|
+
frequency_penalty=frequency_penalty,
|
811
|
+
logit_bias=logit_bias,
|
812
|
+
logprobs=logprobs,
|
813
|
+
max_completion_tokens=max_completion_tokens,
|
814
|
+
metadata=metadata,
|
815
|
+
modalities=modalities,
|
816
|
+
n=n,
|
817
|
+
parallel_tool_calls=parallel_tool_calls,
|
818
|
+
prediction=prediction,
|
819
|
+
presence_penalty=presence_penalty,
|
820
|
+
reasoning_effort=reasoning_effort,
|
821
|
+
seed=seed,
|
822
|
+
service_tier=service_tier,
|
823
|
+
stop=stop,
|
824
|
+
store=store,
|
825
|
+
top_logprobs=top_logprobs,
|
826
|
+
user=user,
|
827
|
+
extra_headers=extra_headers,
|
828
|
+
extra_query=extra_query,
|
829
|
+
extra_body=extra_body,
|
830
|
+
timeout=timeout,
|
831
|
+
stream_options=stream_options,
|
832
|
+
response_format=response_format
|
833
|
+
if response_format and self.model_setting.response_format_available
|
834
|
+
else OPENAI_NOT_GIVEN,
|
835
|
+
**tools_params, # type: ignore
|
586
836
|
)
|
587
837
|
|
588
838
|
async def generator():
|
@@ -684,9 +934,33 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
|
|
684
934
|
temperature=self.temperature,
|
685
935
|
max_tokens=max_tokens,
|
686
936
|
top_p=top_p,
|
687
|
-
|
688
|
-
|
689
|
-
|
937
|
+
audio=audio,
|
938
|
+
frequency_penalty=frequency_penalty,
|
939
|
+
logit_bias=logit_bias,
|
940
|
+
logprobs=logprobs,
|
941
|
+
max_completion_tokens=max_completion_tokens,
|
942
|
+
metadata=metadata,
|
943
|
+
modalities=modalities,
|
944
|
+
n=n,
|
945
|
+
parallel_tool_calls=parallel_tool_calls,
|
946
|
+
prediction=prediction,
|
947
|
+
presence_penalty=presence_penalty,
|
948
|
+
reasoning_effort=reasoning_effort,
|
949
|
+
seed=seed,
|
950
|
+
service_tier=service_tier,
|
951
|
+
stop=stop,
|
952
|
+
store=store,
|
953
|
+
top_logprobs=top_logprobs,
|
954
|
+
user=user,
|
955
|
+
extra_headers=extra_headers,
|
956
|
+
extra_query=extra_query,
|
957
|
+
extra_body=extra_body,
|
958
|
+
timeout=timeout,
|
959
|
+
stream_options=stream_options,
|
960
|
+
response_format=response_format
|
961
|
+
if response_format and self.model_setting.response_format_available
|
962
|
+
else OPENAI_NOT_GIVEN,
|
963
|
+
**tools_params, # type: ignore
|
690
964
|
)
|
691
965
|
result = {
|
692
966
|
"content": response.choices[0].message.content,
|
@@ -5,12 +5,15 @@ from typing_extensions import TypedDict, NotRequired # Required by pydantic und
|
|
5
5
|
|
6
6
|
from pydantic import BaseModel, Field
|
7
7
|
|
8
|
-
from anthropic.types import ToolParam as AnthropicToolParam
|
9
8
|
from anthropic._types import NotGiven as AnthropicNotGiven
|
9
|
+
from anthropic._types import NOT_GIVEN as ANTHROPIC_NOT_GIVEN
|
10
|
+
from anthropic.types import ToolParam as AnthropicToolParam
|
11
|
+
from anthropic.types import ThinkingConfigParam, ThinkingConfigEnabledParam
|
10
12
|
from anthropic.types.message_create_params import ToolChoice as AnthropicToolChoice
|
11
13
|
|
12
14
|
from openai._types import NotGiven as OpenAINotGiven
|
13
15
|
from openai._types import NOT_GIVEN as OPENAI_NOT_GIVEN
|
16
|
+
from openai.types.chat.completion_create_params import ResponseFormat
|
14
17
|
from openai.types.chat.chat_completion_chunk import ChoiceDeltaToolCall
|
15
18
|
from openai.types.chat.chat_completion_tool_param import ChatCompletionToolParam
|
16
19
|
from openai.types.completion_usage import CompletionTokensDetails, PromptTokensDetails
|
@@ -150,4 +153,9 @@ __all__ = [
|
|
150
153
|
"ToolChoice",
|
151
154
|
"AnthropicToolParam",
|
152
155
|
"AnthropicToolChoice",
|
156
|
+
"OPENAI_NOT_GIVEN",
|
157
|
+
"ANTHROPIC_NOT_GIVEN",
|
158
|
+
"ResponseFormat",
|
159
|
+
"ThinkingConfigParam",
|
160
|
+
"ThinkingConfigEnabledParam",
|
153
161
|
]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: vectorvein
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.9
|
4
4
|
Summary: VectorVein python SDK
|
5
5
|
Author-Email: Anderson <andersonby@163.com>
|
6
6
|
License: MIT
|
@@ -8,7 +8,7 @@ Requires-Python: >=3.10
|
|
8
8
|
Requires-Dist: openai>=1.37.1
|
9
9
|
Requires-Dist: tiktoken>=0.7.0
|
10
10
|
Requires-Dist: httpx>=0.27.0
|
11
|
-
Requires-Dist: anthropic[bedrock,vertex]>=0.
|
11
|
+
Requires-Dist: anthropic[bedrock,vertex]>=0.47.1
|
12
12
|
Requires-Dist: pydantic>=2.8.2
|
13
13
|
Requires-Dist: Pillow>=10.4.0
|
14
14
|
Requires-Dist: deepseek-tokenizer>=0.1.0
|
@@ -1,15 +1,15 @@
|
|
1
|
-
vectorvein-0.2.
|
2
|
-
vectorvein-0.2.
|
3
|
-
vectorvein-0.2.
|
1
|
+
vectorvein-0.2.9.dist-info/METADATA,sha256=0-oCeh7DA-fSPf3gKR0i79tcp_qLi5iOf1w4-mW9WaU,4413
|
2
|
+
vectorvein-0.2.9.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
vectorvein-0.2.9.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
4
|
vectorvein/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
vectorvein/api/__init__.py,sha256=lfY-XA46fgD2iIZTU0VYP8i07AwA03Egj4Qua0vUKrQ,738
|
6
6
|
vectorvein/api/client.py,sha256=xF-leKDQzVyyy9FnIRaz0k4eElYW1XbbzeRLcpnyk90,33047
|
7
7
|
vectorvein/api/exceptions.py,sha256=uS_PAdx0ksC0r3dgfSGWdbLMZm4qdLeWSSqCv1g3_Gc,772
|
8
8
|
vectorvein/api/models.py,sha256=xtPWMsB0yIJI7i-gY4B6MtvXv0ZIXnoeKspmeInH6fU,1449
|
9
|
-
vectorvein/chat_clients/__init__.py,sha256=
|
10
|
-
vectorvein/chat_clients/anthropic_client.py,sha256=
|
9
|
+
vectorvein/chat_clients/__init__.py,sha256=1ElJPca32YqSxD4dWTHkTEWhiJE_N6J-e5ZGilpT7ks,19178
|
10
|
+
vectorvein/chat_clients/anthropic_client.py,sha256=Yx0H2kW-XWOZId9Dnzke5eWWS8FqMf6OfgczZF7yeuM,58192
|
11
11
|
vectorvein/chat_clients/baichuan_client.py,sha256=CVMvpgjdrZGv0BWnTOBD-f2ufZ3wq3496wqukumsAr4,526
|
12
|
-
vectorvein/chat_clients/base_client.py,sha256=
|
12
|
+
vectorvein/chat_clients/base_client.py,sha256=RcAJwwJ83qC73t3W7GoPNvQXb-qPJ7d8U1J5nwzcYls,37044
|
13
13
|
vectorvein/chat_clients/deepseek_client.py,sha256=3qWu01NlJAP2N-Ff62d5-CZXZitlizE1fzb20LNetig,526
|
14
14
|
vectorvein/chat_clients/gemini_client.py,sha256=ufovIZrmAE3RLEe8h5WXombf7bARAZxnkj6ydNK2FQM,475
|
15
15
|
vectorvein/chat_clients/groq_client.py,sha256=Uow4pgdmFi93ZQSoOol2-0PhhqkW-S0XuSldvppz5U4,498
|
@@ -18,7 +18,7 @@ vectorvein/chat_clients/minimax_client.py,sha256=YOILWcsHsN5tihLTMbKJIyJr9TJREMI
|
|
18
18
|
vectorvein/chat_clients/mistral_client.py,sha256=1aKSylzBDaLYcFnaBIL4-sXSzWmXfBeON9Q0rq-ziWw,534
|
19
19
|
vectorvein/chat_clients/moonshot_client.py,sha256=gbu-6nGxx8uM_U2WlI4Wus881rFRotzHtMSoYOcruGU,526
|
20
20
|
vectorvein/chat_clients/openai_client.py,sha256=Nz6tV45pWcsOupxjnsRsGTicbQNJWIZyxuJoJ5DGMpg,527
|
21
|
-
vectorvein/chat_clients/openai_compatible_client.py,sha256=
|
21
|
+
vectorvein/chat_clients/openai_compatible_client.py,sha256=IY3EKkkAespVeVV8sv7M1DN71BCdBRWm_dOtPLn2Rgo,48071
|
22
22
|
vectorvein/chat_clients/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
23
|
vectorvein/chat_clients/qwen_client.py,sha256=-ryh-m9PgsO0fc4ulcCmPTy1155J8YUy15uPoJQOHA0,513
|
24
24
|
vectorvein/chat_clients/stepfun_client.py,sha256=zsD2W5ahmR4DD9cqQTXmJr3txrGuvxbRWhFlRdwNijI,519
|
@@ -33,7 +33,7 @@ vectorvein/settings/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
33
33
|
vectorvein/types/defaults.py,sha256=VrkQoyHqC_eK3g1b6egpPYLLo0ltwMHqxDscCX4y-N0,27417
|
34
34
|
vectorvein/types/enums.py,sha256=7KTJSVtQueImmbr1fSwv3rQVtc0RyMWXJmoE2tDOaso,1667
|
35
35
|
vectorvein/types/exception.py,sha256=gnW4GnJ76jND6UGnodk9xmqkcbeS7Cz2rvncA2HpD5E,69
|
36
|
-
vectorvein/types/llm_parameters.py,sha256=
|
36
|
+
vectorvein/types/llm_parameters.py,sha256=uby71bteIHmZ3YtFBDbapOaQunBVqcI5qAfQmjWlniM,6339
|
37
37
|
vectorvein/types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
38
38
|
vectorvein/utilities/media_processing.py,sha256=7KtbLFzOYIn1e9QTN9G6C76NH8CBlV9kfAgiRKEIeXY,6263
|
39
39
|
vectorvein/utilities/rate_limiter.py,sha256=dwolIUVw2wP83Odqpx0AAaE77de1GzxkYDGH4tM_u_4,10300
|
@@ -59,4 +59,4 @@ vectorvein/workflow/nodes/vector_db.py,sha256=t6I17q6iR3yQreiDHpRrksMdWDPIvgqJs0
|
|
59
59
|
vectorvein/workflow/nodes/video_generation.py,sha256=qmdg-t_idpxq1veukd-jv_ChICMOoInKxprV9Z4Vi2w,4118
|
60
60
|
vectorvein/workflow/nodes/web_crawlers.py,sha256=LsqomfXfqrXfHJDO1cl0Ox48f4St7X_SL12DSbAMSOw,5415
|
61
61
|
vectorvein/workflow/utils/json_to_code.py,sha256=F7dhDy8kGc8ndOeihGLRLGFGlquoxVlb02ENtxnQ0C8,5914
|
62
|
-
vectorvein-0.2.
|
62
|
+
vectorvein-0.2.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|