vectorvein 0.1.11__tar.gz → 0.1.13__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.
- {vectorvein-0.1.11 → vectorvein-0.1.13}/PKG-INFO +1 -1
- {vectorvein-0.1.11 → vectorvein-0.1.13}/pyproject.toml +1 -1
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/__init__.py +14 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/anthropic_client.py +9 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/base_client.py +11 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/gemini_client.py +24 -5
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/minimax_client.py +12 -2
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/openai_compatible_client.py +11 -2
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/types/llm_parameters.py +1 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/tests/sample_settings.py +6 -2
- vectorvein-0.1.13/tests/test_chat_prefix.py +23 -0
- vectorvein-0.1.13/tests/test_http_client.py +24 -0
- vectorvein-0.1.13/tests/test_stop.py +25 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/README.md +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/__init__.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/deepseek_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/groq_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/local_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/mistral_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/moonshot_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/openai_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/qwen_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/utils.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/yi_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/zhipuai_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/settings/__init__.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/types/defaults.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/types/enums.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/utilities/media_processing.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/utilities/retry.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/tests/__init__.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/tests/cat.png +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/tests/test_create_chat_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/tests/test_format_messages.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/tests/test_image_input_chat_client.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/tests/test_tokens_count.py +0 -0
- {vectorvein-0.1.11 → vectorvein-0.1.13}/tests/test_tool_use_multi_turns.py +0 -0
@@ -1,5 +1,7 @@
|
|
1
1
|
# @Author: Bi Ying
|
2
2
|
# @Date: 2024-07-26 14:48:55
|
3
|
+
import httpx
|
4
|
+
|
3
5
|
from .base_client import BaseChatClient, BaseAsyncChatClient
|
4
6
|
|
5
7
|
from .yi_client import YiChatClient, AsyncYiChatClient
|
@@ -58,6 +60,9 @@ def create_chat_client(
|
|
58
60
|
stream: bool = False,
|
59
61
|
temperature: float = 0.7,
|
60
62
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
63
|
+
random_endpoint: bool = True,
|
64
|
+
endpoint_id: str = "",
|
65
|
+
http_client: httpx.Client | None = None,
|
61
66
|
**kwargs,
|
62
67
|
) -> BaseChatClient:
|
63
68
|
if backend.lower() not in BackendMap["sync"]:
|
@@ -73,6 +78,9 @@ def create_chat_client(
|
|
73
78
|
stream=stream,
|
74
79
|
temperature=temperature,
|
75
80
|
context_length_control=context_length_control,
|
81
|
+
random_endpoint=random_endpoint,
|
82
|
+
endpoint_id=endpoint_id,
|
83
|
+
http_client=http_client,
|
76
84
|
**kwargs,
|
77
85
|
)
|
78
86
|
|
@@ -83,6 +91,9 @@ def create_async_chat_client(
|
|
83
91
|
stream: bool = False,
|
84
92
|
temperature: float = 0.7,
|
85
93
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
94
|
+
random_endpoint: bool = True,
|
95
|
+
endpoint_id: str = "",
|
96
|
+
http_client: httpx.AsyncClient | None = None,
|
86
97
|
**kwargs,
|
87
98
|
) -> BaseAsyncChatClient:
|
88
99
|
if backend.lower() not in BackendMap["async"]:
|
@@ -98,6 +109,9 @@ def create_async_chat_client(
|
|
98
109
|
stream=stream,
|
99
110
|
temperature=temperature,
|
100
111
|
context_length_control=context_length_control,
|
112
|
+
random_endpoint=random_endpoint,
|
113
|
+
endpoint_id=endpoint_id,
|
114
|
+
http_client=http_client,
|
101
115
|
**kwargs,
|
102
116
|
)
|
103
117
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
import json
|
4
4
|
import random
|
5
5
|
|
6
|
+
import httpx
|
6
7
|
from openai._types import NotGiven as OpenAINotGiven
|
7
8
|
from anthropic import Anthropic, AnthropicVertex, AsyncAnthropic, AsyncAnthropicVertex
|
8
9
|
from anthropic._types import NotGiven, NOT_GIVEN
|
@@ -97,6 +98,7 @@ class AnthropicChatClient(BaseChatClient):
|
|
97
98
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
98
99
|
random_endpoint: bool = True,
|
99
100
|
endpoint_id: str = "",
|
101
|
+
http_client: httpx.Client | None = None,
|
100
102
|
**kwargs,
|
101
103
|
):
|
102
104
|
super().__init__(
|
@@ -106,6 +108,7 @@ class AnthropicChatClient(BaseChatClient):
|
|
106
108
|
context_length_control,
|
107
109
|
random_endpoint,
|
108
110
|
endpoint_id,
|
111
|
+
http_client,
|
109
112
|
**kwargs,
|
110
113
|
)
|
111
114
|
|
@@ -183,11 +186,13 @@ class AnthropicChatClient(BaseChatClient):
|
|
183
186
|
base_url=base_url,
|
184
187
|
project_id=self.endpoint.credentials.get("quota_project_id"),
|
185
188
|
access_token=self.creds.token,
|
189
|
+
http_client=self.http_client,
|
186
190
|
)
|
187
191
|
else:
|
188
192
|
self._client = Anthropic(
|
189
193
|
api_key=self.endpoint.api_key,
|
190
194
|
base_url=self.endpoint.api_base,
|
195
|
+
http_client=self.http_client,
|
191
196
|
)
|
192
197
|
|
193
198
|
tools_params = refactor_tool_use_params(tools) if tools else tools
|
@@ -299,6 +304,7 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
299
304
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
300
305
|
random_endpoint: bool = True,
|
301
306
|
endpoint_id: str = "",
|
307
|
+
http_client: httpx.AsyncClient | None = None,
|
302
308
|
**kwargs,
|
303
309
|
):
|
304
310
|
super().__init__(
|
@@ -308,6 +314,7 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
308
314
|
context_length_control,
|
309
315
|
random_endpoint,
|
310
316
|
endpoint_id,
|
317
|
+
http_client,
|
311
318
|
**kwargs,
|
312
319
|
)
|
313
320
|
|
@@ -385,11 +392,13 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
385
392
|
base_url=base_url,
|
386
393
|
project_id=self.endpoint.credentials.get("quota_project_id"),
|
387
394
|
access_token=self.creds.token,
|
395
|
+
http_client=self.http_client,
|
388
396
|
)
|
389
397
|
else:
|
390
398
|
self._client = AsyncAnthropic(
|
391
399
|
api_key=self.endpoint.api_key,
|
392
400
|
base_url=self.endpoint.api_base,
|
401
|
+
http_client=self.http_client,
|
393
402
|
)
|
394
403
|
|
395
404
|
tools_params = refactor_tool_use_params(tools) if tools else tools
|
@@ -3,6 +3,7 @@
|
|
3
3
|
from abc import ABC, abstractmethod
|
4
4
|
from typing import Generator, AsyncGenerator, Any
|
5
5
|
|
6
|
+
import httpx
|
6
7
|
from openai._types import NotGiven, NOT_GIVEN
|
7
8
|
|
8
9
|
from ..settings import settings
|
@@ -23,6 +24,7 @@ class BaseChatClient(ABC):
|
|
23
24
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
24
25
|
random_endpoint: bool = True,
|
25
26
|
endpoint_id: str = "",
|
27
|
+
http_client: httpx.Client | None = None,
|
26
28
|
**kwargs,
|
27
29
|
):
|
28
30
|
self.model = model or self.DEFAULT_MODEL
|
@@ -31,6 +33,7 @@ class BaseChatClient(ABC):
|
|
31
33
|
self.context_length_control = context_length_control
|
32
34
|
self.random_endpoint = random_endpoint
|
33
35
|
self.endpoint_id = endpoint_id
|
36
|
+
self.http_client = http_client
|
34
37
|
|
35
38
|
self.backend_settings = settings.get_backend(self.BACKEND_NAME)
|
36
39
|
|
@@ -49,6 +52,7 @@ class BaseChatClient(ABC):
|
|
49
52
|
max_tokens: int | None = None,
|
50
53
|
tools: list | NotGiven = NOT_GIVEN,
|
51
54
|
tool_choice: str | NotGiven = NOT_GIVEN,
|
55
|
+
**kwargs,
|
52
56
|
) -> ChatCompletionMessage | Generator[ChatCompletionDeltaMessage, Any, None]:
|
53
57
|
pass
|
54
58
|
|
@@ -60,6 +64,7 @@ class BaseChatClient(ABC):
|
|
60
64
|
max_tokens: int | None = None,
|
61
65
|
tools: list | NotGiven = NOT_GIVEN,
|
62
66
|
tool_choice: str | NotGiven = NOT_GIVEN,
|
67
|
+
**kwargs,
|
63
68
|
) -> Generator[ChatCompletionDeltaMessage, Any, None]:
|
64
69
|
return self.create_completion(
|
65
70
|
messages=messages,
|
@@ -69,6 +74,7 @@ class BaseChatClient(ABC):
|
|
69
74
|
max_tokens=max_tokens,
|
70
75
|
tools=tools,
|
71
76
|
tool_choice=tool_choice,
|
77
|
+
**kwargs,
|
72
78
|
)
|
73
79
|
|
74
80
|
|
@@ -84,6 +90,7 @@ class BaseAsyncChatClient(ABC):
|
|
84
90
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
85
91
|
random_endpoint: bool = True,
|
86
92
|
endpoint_id: str = "",
|
93
|
+
http_client: httpx.AsyncClient | None = None,
|
87
94
|
**kwargs,
|
88
95
|
):
|
89
96
|
self.model = model or self.DEFAULT_MODEL
|
@@ -92,6 +99,7 @@ class BaseAsyncChatClient(ABC):
|
|
92
99
|
self.context_length_control = context_length_control
|
93
100
|
self.random_endpoint = random_endpoint
|
94
101
|
self.endpoint_id = endpoint_id
|
102
|
+
self.http_client = http_client
|
95
103
|
|
96
104
|
self.backend_settings = settings.get_backend(self.BACKEND_NAME)
|
97
105
|
|
@@ -110,6 +118,7 @@ class BaseAsyncChatClient(ABC):
|
|
110
118
|
max_tokens: int | None = None,
|
111
119
|
tools: list | NotGiven = NOT_GIVEN,
|
112
120
|
tool_choice: str | NotGiven = NOT_GIVEN,
|
121
|
+
**kwargs,
|
113
122
|
) -> ChatCompletionMessage | AsyncGenerator[ChatCompletionDeltaMessage, None]:
|
114
123
|
pass
|
115
124
|
|
@@ -121,6 +130,7 @@ class BaseAsyncChatClient(ABC):
|
|
121
130
|
max_tokens: int | None = None,
|
122
131
|
tools: list | NotGiven = NOT_GIVEN,
|
123
132
|
tool_choice: str | NotGiven = NOT_GIVEN,
|
133
|
+
**kwargs,
|
124
134
|
) -> AsyncGenerator[ChatCompletionDeltaMessage, None]:
|
125
135
|
return await self.create_completion(
|
126
136
|
messages=messages,
|
@@ -130,4 +140,5 @@ class BaseAsyncChatClient(ABC):
|
|
130
140
|
max_tokens=max_tokens,
|
131
141
|
tools=tools,
|
132
142
|
tool_choice=tool_choice,
|
143
|
+
**kwargs,
|
133
144
|
)
|
@@ -25,6 +25,7 @@ class GeminiChatClient(BaseChatClient):
|
|
25
25
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
26
26
|
random_endpoint: bool = True,
|
27
27
|
endpoint_id: str = "",
|
28
|
+
http_client: httpx.Client | None = None,
|
28
29
|
**kwargs,
|
29
30
|
):
|
30
31
|
super().__init__(
|
@@ -34,6 +35,7 @@ class GeminiChatClient(BaseChatClient):
|
|
34
35
|
context_length_control,
|
35
36
|
random_endpoint,
|
36
37
|
endpoint_id,
|
38
|
+
http_client,
|
37
39
|
**kwargs,
|
38
40
|
)
|
39
41
|
|
@@ -107,7 +109,11 @@ class GeminiChatClient(BaseChatClient):
|
|
107
109
|
|
108
110
|
def generator():
|
109
111
|
result = {"content": ""}
|
110
|
-
|
112
|
+
if self.http_client:
|
113
|
+
client = self.http_client
|
114
|
+
else:
|
115
|
+
client = httpx.Client()
|
116
|
+
with client.stream("POST", url, headers=headers, params=params, json=request_body) as response:
|
111
117
|
for chunk in response.iter_lines():
|
112
118
|
message = {"content": ""}
|
113
119
|
if not chunk.startswith("data:"):
|
@@ -142,7 +148,11 @@ class GeminiChatClient(BaseChatClient):
|
|
142
148
|
return generator()
|
143
149
|
else:
|
144
150
|
url = f"{self.endpoint.api_base}/models/{self.model_setting.id}:generateContent"
|
145
|
-
|
151
|
+
if self.http_client:
|
152
|
+
client = self.http_client
|
153
|
+
else:
|
154
|
+
client = httpx.Client()
|
155
|
+
response = client.post(url, json=request_body, headers=headers, params=params, timeout=None).json()
|
146
156
|
result = {
|
147
157
|
"content": "",
|
148
158
|
"usage": {
|
@@ -185,6 +195,7 @@ class AsyncGeminiChatClient(BaseAsyncChatClient):
|
|
185
195
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
186
196
|
random_endpoint: bool = True,
|
187
197
|
endpoint_id: str = "",
|
198
|
+
http_client: httpx.AsyncClient | None = None,
|
188
199
|
**kwargs,
|
189
200
|
):
|
190
201
|
super().__init__(
|
@@ -194,6 +205,7 @@ class AsyncGeminiChatClient(BaseAsyncChatClient):
|
|
194
205
|
context_length_control,
|
195
206
|
random_endpoint,
|
196
207
|
endpoint_id,
|
208
|
+
http_client,
|
197
209
|
**kwargs,
|
198
210
|
)
|
199
211
|
|
@@ -267,7 +279,10 @@ class AsyncGeminiChatClient(BaseAsyncChatClient):
|
|
267
279
|
|
268
280
|
async def generator():
|
269
281
|
result = {"content": ""}
|
270
|
-
|
282
|
+
if self.http_client:
|
283
|
+
client = self.http_client
|
284
|
+
else:
|
285
|
+
client = httpx.AsyncClient()
|
271
286
|
async with client.stream("POST", url, headers=headers, params=params, json=request_body) as response:
|
272
287
|
async for chunk in response.aiter_lines():
|
273
288
|
message = {"content": ""}
|
@@ -303,8 +318,12 @@ class AsyncGeminiChatClient(BaseAsyncChatClient):
|
|
303
318
|
return generator()
|
304
319
|
else:
|
305
320
|
url = f"{self.endpoint.api_base}/models/{self.model_setting.id}:generateContent"
|
306
|
-
|
307
|
-
|
321
|
+
if self.http_client:
|
322
|
+
client = self.http_client
|
323
|
+
else:
|
324
|
+
client = httpx.AsyncClient()
|
325
|
+
async with client:
|
326
|
+
response = await client.post(url, json=request_body, headers=headers, params=params, timeout=None)
|
308
327
|
response = response.json()
|
309
328
|
result = {
|
310
329
|
"content": "",
|
@@ -48,6 +48,7 @@ class MiniMaxChatClient(BaseChatClient):
|
|
48
48
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
49
49
|
random_endpoint: bool = True,
|
50
50
|
endpoint_id: str = "",
|
51
|
+
http_client: httpx.Client | None = None,
|
51
52
|
**kwargs,
|
52
53
|
):
|
53
54
|
super().__init__(
|
@@ -57,9 +58,13 @@ class MiniMaxChatClient(BaseChatClient):
|
|
57
58
|
context_length_control,
|
58
59
|
random_endpoint,
|
59
60
|
endpoint_id,
|
61
|
+
http_client,
|
60
62
|
**kwargs,
|
61
63
|
)
|
62
|
-
|
64
|
+
if http_client:
|
65
|
+
self.http_client = http_client
|
66
|
+
else:
|
67
|
+
self.http_client = httpx.Client()
|
63
68
|
|
64
69
|
def create_completion(
|
65
70
|
self,
|
@@ -208,6 +213,7 @@ class AsyncMiniMaxChatClient(BaseAsyncChatClient):
|
|
208
213
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
209
214
|
random_endpoint: bool = True,
|
210
215
|
endpoint_id: str = "",
|
216
|
+
http_client: httpx.AsyncClient | None = None,
|
211
217
|
**kwargs,
|
212
218
|
):
|
213
219
|
super().__init__(
|
@@ -217,9 +223,13 @@ class AsyncMiniMaxChatClient(BaseAsyncChatClient):
|
|
217
223
|
context_length_control,
|
218
224
|
random_endpoint,
|
219
225
|
endpoint_id,
|
226
|
+
http_client,
|
220
227
|
**kwargs,
|
221
228
|
)
|
222
|
-
|
229
|
+
if http_client:
|
230
|
+
self.http_client = http_client
|
231
|
+
else:
|
232
|
+
self.http_client = httpx.AsyncClient()
|
223
233
|
|
224
234
|
async def create_completion(
|
225
235
|
self,
|
{vectorvein-0.1.11 → vectorvein-0.1.13}/src/vectorvein/chat_clients/openai_compatible_client.py
RENAMED
@@ -3,6 +3,7 @@
|
|
3
3
|
import json
|
4
4
|
import random
|
5
5
|
|
6
|
+
import httpx
|
6
7
|
from openai._types import NotGiven, NOT_GIVEN
|
7
8
|
from openai._streaming import Stream, AsyncStream
|
8
9
|
from openai.types.chat import ChatCompletion, ChatCompletionChunk
|
@@ -33,6 +34,7 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
33
34
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
34
35
|
random_endpoint: bool = True,
|
35
36
|
endpoint_id: str = "",
|
37
|
+
http_client: httpx.Client | None = None,
|
36
38
|
**kwargs,
|
37
39
|
):
|
38
40
|
super().__init__(
|
@@ -42,6 +44,7 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
42
44
|
context_length_control,
|
43
45
|
random_endpoint,
|
44
46
|
endpoint_id,
|
47
|
+
http_client,
|
45
48
|
**kwargs,
|
46
49
|
)
|
47
50
|
|
@@ -74,12 +77,14 @@ class OpenAICompatibleChatClient(BaseChatClient):
|
|
74
77
|
self._client = AzureOpenAI(
|
75
78
|
azure_endpoint=self.endpoint.api_base,
|
76
79
|
api_key=self.endpoint.api_key,
|
77
|
-
api_version="2024-
|
80
|
+
api_version="2024-08-01-preview",
|
81
|
+
http_client=self.http_client,
|
78
82
|
)
|
79
83
|
else:
|
80
84
|
self._client = OpenAI(
|
81
85
|
api_key=self.endpoint.api_key,
|
82
86
|
base_url=self.endpoint.api_base,
|
87
|
+
http_client=self.http_client,
|
83
88
|
)
|
84
89
|
|
85
90
|
if self.context_length_control == ContextLengthControlType.Latest:
|
@@ -188,6 +193,7 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
|
|
188
193
|
context_length_control: ContextLengthControlType = defs.CONTEXT_LENGTH_CONTROL,
|
189
194
|
random_endpoint: bool = True,
|
190
195
|
endpoint_id: str = "",
|
196
|
+
http_client: httpx.AsyncClient | None = None,
|
191
197
|
**kwargs,
|
192
198
|
):
|
193
199
|
super().__init__(
|
@@ -197,6 +203,7 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
|
|
197
203
|
context_length_control,
|
198
204
|
random_endpoint,
|
199
205
|
endpoint_id,
|
206
|
+
http_client,
|
200
207
|
**kwargs,
|
201
208
|
)
|
202
209
|
|
@@ -229,12 +236,14 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
|
|
229
236
|
self._client = AsyncAzureOpenAI(
|
230
237
|
azure_endpoint=self.endpoint.api_base,
|
231
238
|
api_key=self.endpoint.api_key,
|
232
|
-
api_version="2024-
|
239
|
+
api_version="2024-08-01-preview",
|
240
|
+
http_client=self.http_client,
|
233
241
|
)
|
234
242
|
else:
|
235
243
|
self._client = AsyncOpenAI(
|
236
244
|
api_key=self.endpoint.api_key,
|
237
245
|
base_url=self.endpoint.api_base,
|
246
|
+
http_client=self.http_client,
|
238
247
|
)
|
239
248
|
|
240
249
|
if self.context_length_control == ContextLengthControlType.Latest:
|
@@ -39,7 +39,7 @@ sample_settings = {
|
|
39
39
|
},
|
40
40
|
{
|
41
41
|
"id": "deepseek-default",
|
42
|
-
"api_base": "https://api.deepseek.com/
|
42
|
+
"api_base": "https://api.deepseek.com/beta",
|
43
43
|
"api_key": "",
|
44
44
|
},
|
45
45
|
{
|
@@ -80,6 +80,10 @@ sample_settings = {
|
|
80
80
|
},
|
81
81
|
"openai": {
|
82
82
|
"models": {
|
83
|
+
"gpt-4o-mini": {
|
84
|
+
"id": "gpt-4o-mini",
|
85
|
+
"endpoints": ["azure-openai"],
|
86
|
+
},
|
83
87
|
"gpt-4o": {
|
84
88
|
"id": "gpt-4o",
|
85
89
|
"endpoints": ["azure-openai"],
|
@@ -362,7 +366,7 @@ sample_settings = {
|
|
362
366
|
},
|
363
367
|
{
|
364
368
|
"id": "deepseek-default",
|
365
|
-
"api_base": "https://api.deepseek.com/
|
369
|
+
"api_base": "https://api.deepseek.com/beta",
|
366
370
|
"api_key": "sk-6dad42e7154743cd80b77dff5d0ecaaa",
|
367
371
|
},
|
368
372
|
{
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# @Author: Bi Ying
|
2
|
+
# @Date: 2024-07-27 11:51:28
|
3
|
+
import time
|
4
|
+
|
5
|
+
from vectorvein.settings import settings
|
6
|
+
from vectorvein.types.enums import BackendType
|
7
|
+
from vectorvein.chat_clients import create_chat_client
|
8
|
+
|
9
|
+
from sample_settings import sample_settings
|
10
|
+
|
11
|
+
settings.load(sample_settings)
|
12
|
+
messages = [
|
13
|
+
{"role": "user", "content": "Please write quick sort code"},
|
14
|
+
{"role": "assistant", "content": "```python\n", "prefix": True},
|
15
|
+
]
|
16
|
+
|
17
|
+
|
18
|
+
start_time = time.perf_counter()
|
19
|
+
client = create_chat_client(backend=BackendType.DeepSeek, model="deepseek-chat", stream=False)
|
20
|
+
response = client.create_completion(messages=messages, stop=["\n```"])
|
21
|
+
print(response)
|
22
|
+
end_time = time.perf_counter()
|
23
|
+
print(f"Stream time elapsed: {end_time - start_time} seconds")
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# @Author: Bi Ying
|
2
|
+
# @Date: 2024-07-27 11:51:28
|
3
|
+
import time
|
4
|
+
|
5
|
+
import httpx
|
6
|
+
from vectorvein.settings import settings
|
7
|
+
from vectorvein.types.enums import BackendType
|
8
|
+
from vectorvein.chat_clients import create_chat_client
|
9
|
+
|
10
|
+
from sample_settings import sample_settings
|
11
|
+
|
12
|
+
settings.load(sample_settings)
|
13
|
+
messages = [
|
14
|
+
{"role": "user", "content": "Please write quick sort code"},
|
15
|
+
]
|
16
|
+
|
17
|
+
|
18
|
+
start_time = time.perf_counter()
|
19
|
+
http_client = httpx.Client()
|
20
|
+
client = create_chat_client(backend=BackendType.DeepSeek, model="deepseek-chat", stream=False, http_client=http_client)
|
21
|
+
response = client.create_completion(messages=messages)
|
22
|
+
print(response)
|
23
|
+
end_time = time.perf_counter()
|
24
|
+
print(f"Stream time elapsed: {end_time - start_time} seconds")
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# @Author: Bi Ying
|
2
|
+
# @Date: 2024-07-27 11:51:28
|
3
|
+
import time
|
4
|
+
|
5
|
+
from vectorvein.settings import settings
|
6
|
+
from vectorvein.types.enums import BackendType
|
7
|
+
from vectorvein.chat_clients import create_chat_client
|
8
|
+
|
9
|
+
from sample_settings import sample_settings
|
10
|
+
|
11
|
+
settings.load(sample_settings)
|
12
|
+
messages = [
|
13
|
+
{
|
14
|
+
"role": "user",
|
15
|
+
"content": "节点名称是 FileLoader,FileLoader 节点连到 OCR 节点,使用 mermaid 语法表示流程图。直接开始补全,不要有任何解释。\n\n```mermaid\n",
|
16
|
+
}
|
17
|
+
]
|
18
|
+
|
19
|
+
|
20
|
+
start_time = time.perf_counter()
|
21
|
+
client = create_chat_client(backend=BackendType.DeepSeek, model="deepseek-chat", stream=False)
|
22
|
+
response = client.create_completion(messages=messages, stop=["\n```"])
|
23
|
+
print(response)
|
24
|
+
end_time = time.perf_counter()
|
25
|
+
print(f"Stream time elapsed: {end_time - start_time} seconds")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|