vectorvein 0.1.53__tar.gz → 0.1.55__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.53 → vectorvein-0.1.55}/PKG-INFO +2 -2
- {vectorvein-0.1.53 → vectorvein-0.1.55}/pyproject.toml +2 -2
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/anthropic_client.py +60 -4
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/utils.py +3 -2
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/types/defaults.py +1 -1
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/utilities/media_processing.py +1 -1
- {vectorvein-0.1.53 → vectorvein-0.1.55}/README.md +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/__init__.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/__init__.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/baichuan_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/base_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/deepseek_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/gemini_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/groq_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/local_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/minimax_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/mistral_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/moonshot_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/openai_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/openai_compatible_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/py.typed +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/qwen_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/stepfun_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/xai_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/yi_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/zhipuai_client.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/py.typed +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/server/token_server.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/settings/__init__.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/settings/py.typed +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/types/enums.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/types/exception.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/types/llm_parameters.py +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/types/py.typed +0 -0
- {vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/utilities/retry.py +0 -0
@@ -13,11 +13,11 @@ dependencies = [
|
|
13
13
|
"qwen-tokenizer>=0.2.0",
|
14
14
|
"google-auth>=2.35.0",
|
15
15
|
]
|
16
|
-
description = "
|
16
|
+
description = "VectorVein python SDK"
|
17
17
|
name = "vectorvein"
|
18
18
|
readme = "README.md"
|
19
19
|
requires-python = ">=3.10"
|
20
|
-
version = "0.1.
|
20
|
+
version = "0.1.55"
|
21
21
|
|
22
22
|
[project.license]
|
23
23
|
text = "MIT"
|
@@ -12,6 +12,7 @@ from anthropic import Anthropic, AnthropicVertex, AsyncAnthropic, AsyncAnthropic
|
|
12
12
|
from anthropic._types import NOT_GIVEN
|
13
13
|
from anthropic.types import (
|
14
14
|
TextBlock,
|
15
|
+
MessageParam,
|
15
16
|
ToolUseBlock,
|
16
17
|
RawMessageDeltaEvent,
|
17
18
|
RawMessageStartEvent,
|
@@ -112,6 +113,38 @@ def format_messages_alternate(messages: list) -> list:
|
|
112
113
|
return formatted_messages
|
113
114
|
|
114
115
|
|
116
|
+
def refactor_into_openai_messages(messages: Iterable[MessageParam]):
|
117
|
+
formatted_messages = []
|
118
|
+
for message in messages:
|
119
|
+
content = message["content"]
|
120
|
+
if isinstance(content, str):
|
121
|
+
formatted_messages.append(message)
|
122
|
+
elif isinstance(content, list):
|
123
|
+
_content = []
|
124
|
+
for item in content:
|
125
|
+
if isinstance(item, (TextBlock, ToolUseBlock)):
|
126
|
+
_content.append(item.model_dump())
|
127
|
+
elif item.get("type") == "image":
|
128
|
+
image_data = item.get("source", {}).get("data", "")
|
129
|
+
media_type = item.get("source", {}).get("media_type", "")
|
130
|
+
data_url = f"data:{media_type};base64,{image_data}"
|
131
|
+
_content.append(
|
132
|
+
{
|
133
|
+
"type": "image_url",
|
134
|
+
"image_url": {
|
135
|
+
"url": data_url,
|
136
|
+
"detail_type": "auto",
|
137
|
+
},
|
138
|
+
}
|
139
|
+
)
|
140
|
+
else:
|
141
|
+
_content.append(item)
|
142
|
+
formatted_messages.append({"role": message["role"], "content": _content})
|
143
|
+
else:
|
144
|
+
formatted_messages.append(message)
|
145
|
+
return formatted_messages
|
146
|
+
|
147
|
+
|
115
148
|
class AnthropicChatClient(BaseChatClient):
|
116
149
|
DEFAULT_MODEL: str | None = defs.ANTHROPIC_DEFAULT_MODEL
|
117
150
|
BACKEND_NAME: BackendType = BackendType.Anthropic
|
@@ -290,6 +323,9 @@ class AnthropicChatClient(BaseChatClient):
|
|
290
323
|
if self.endpoint.api_schema_type == "openai":
|
291
324
|
_tools = OPENAI_NOT_GIVEN if tools is NOT_GIVEN else tools
|
292
325
|
_tool_choice = OPENAI_NOT_GIVEN if tool_choice is NOT_GIVEN else tool_choice
|
326
|
+
|
327
|
+
formatted_messages = refactor_into_openai_messages(messages)
|
328
|
+
|
293
329
|
if self.stream:
|
294
330
|
|
295
331
|
def _generator():
|
@@ -303,7 +339,16 @@ class AnthropicChatClient(BaseChatClient):
|
|
303
339
|
http_client=self.http_client,
|
304
340
|
backend_name=self.BACKEND_NAME,
|
305
341
|
).create_completion(
|
306
|
-
messages,
|
342
|
+
messages=formatted_messages,
|
343
|
+
model=model,
|
344
|
+
stream=True,
|
345
|
+
temperature=temperature,
|
346
|
+
max_tokens=max_tokens,
|
347
|
+
tools=_tools,
|
348
|
+
tool_choice=_tool_choice,
|
349
|
+
response_format=response_format,
|
350
|
+
stream_options=stream_options,
|
351
|
+
**kwargs,
|
307
352
|
)
|
308
353
|
for chunk in response:
|
309
354
|
yield chunk
|
@@ -320,7 +365,7 @@ class AnthropicChatClient(BaseChatClient):
|
|
320
365
|
http_client=self.http_client,
|
321
366
|
backend_name=self.BACKEND_NAME,
|
322
367
|
).create_completion(
|
323
|
-
messages=
|
368
|
+
messages=formatted_messages,
|
324
369
|
model=model,
|
325
370
|
stream=False,
|
326
371
|
temperature=temperature,
|
@@ -643,6 +688,9 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
643
688
|
if self.endpoint.api_schema_type == "openai":
|
644
689
|
_tools = OPENAI_NOT_GIVEN if tools is NOT_GIVEN else tools
|
645
690
|
_tool_choice = OPENAI_NOT_GIVEN if tool_choice is NOT_GIVEN else tool_choice
|
691
|
+
|
692
|
+
formatted_messages = refactor_into_openai_messages(messages)
|
693
|
+
|
646
694
|
if self.stream:
|
647
695
|
|
648
696
|
async def _generator():
|
@@ -657,7 +705,7 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
657
705
|
backend_name=self.BACKEND_NAME,
|
658
706
|
)
|
659
707
|
response = await client.create_completion(
|
660
|
-
messages=
|
708
|
+
messages=formatted_messages,
|
661
709
|
model=model,
|
662
710
|
stream=True,
|
663
711
|
temperature=temperature,
|
@@ -684,7 +732,15 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
684
732
|
backend_name=self.BACKEND_NAME,
|
685
733
|
)
|
686
734
|
return await client.create_completion(
|
687
|
-
messages,
|
735
|
+
messages=formatted_messages,
|
736
|
+
model=model,
|
737
|
+
stream=False,
|
738
|
+
temperature=temperature,
|
739
|
+
max_tokens=max_tokens,
|
740
|
+
tools=_tools,
|
741
|
+
tool_choice=_tool_choice,
|
742
|
+
response_format=response_format,
|
743
|
+
**kwargs,
|
688
744
|
)
|
689
745
|
|
690
746
|
assert isinstance(self.raw_client, AsyncAnthropic | AsyncAnthropicVertex)
|
@@ -9,6 +9,7 @@ from typing import Iterable
|
|
9
9
|
import httpx
|
10
10
|
import tiktoken
|
11
11
|
from anthropic import Anthropic
|
12
|
+
from openai.types.chat import ChatCompletionMessageParam
|
12
13
|
|
13
14
|
from ..settings import settings
|
14
15
|
from ..utilities.retry import Retry
|
@@ -567,7 +568,7 @@ def format_workflow_messages(message: dict, content: str, backend: BackendType):
|
|
567
568
|
return formatted_messages
|
568
569
|
|
569
570
|
|
570
|
-
def
|
571
|
+
def transform_from_openai_message(message: ChatCompletionMessageParam, backend: BackendType):
|
571
572
|
role = message.get("role", "user")
|
572
573
|
content = message.get("content", "")
|
573
574
|
|
@@ -635,7 +636,7 @@ def format_messages(
|
|
635
636
|
formatted_messages.extend(format_workflow_messages(message, content, backend))
|
636
637
|
else:
|
637
638
|
# 处理 OpenAI 格式的消息
|
638
|
-
formatted_message =
|
639
|
+
formatted_message = transform_from_openai_message(message, backend)
|
639
640
|
formatted_messages.append(formatted_message)
|
640
641
|
|
641
642
|
return formatted_messages
|
@@ -558,7 +558,7 @@ ANTHROPIC_MODELS: Final[Dict[str, Dict[str, Any]]] = {
|
|
558
558
|
"max_output_tokens": 8192,
|
559
559
|
"function_call_available": True,
|
560
560
|
"response_format_available": False,
|
561
|
-
"native_multimodal":
|
561
|
+
"native_multimodal": False,
|
562
562
|
},
|
563
563
|
"claude-3-5-sonnet-20240620": {
|
564
564
|
"id": "claude-3-5-sonnet-20240620",
|
@@ -36,7 +36,7 @@ class ImageProcessor:
|
|
36
36
|
image_url = self.image_source
|
37
37
|
response = httpx.get(image_url)
|
38
38
|
return Image.open(BytesIO(response.content))
|
39
|
-
elif isinstance(self.image_source, Path):
|
39
|
+
elif isinstance(self.image_source, (Path, str)):
|
40
40
|
return Image.open(self.image_source)
|
41
41
|
elif isinstance(self.image_source, Image.Image):
|
42
42
|
return self.image_source
|
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
|
{vectorvein-0.1.53 → vectorvein-0.1.55}/src/vectorvein/chat_clients/openai_compatible_client.py
RENAMED
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
|