vectorvein 0.2.6__py3-none-any.whl → 0.2.7__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/anthropic_client.py +28 -2
- vectorvein/types/defaults.py +8 -0
- {vectorvein-0.2.6.dist-info → vectorvein-0.2.7.dist-info}/METADATA +1 -1
- {vectorvein-0.2.6.dist-info → vectorvein-0.2.7.dist-info}/RECORD +6 -6
- {vectorvein-0.2.6.dist-info → vectorvein-0.2.7.dist-info}/WHEEL +0 -0
- {vectorvein-0.2.6.dist-info → vectorvein-0.2.7.dist-info}/entry_points.txt +0 -0
@@ -17,6 +17,8 @@ from anthropic import (
|
|
17
17
|
from anthropic._types import NOT_GIVEN
|
18
18
|
from anthropic.types import (
|
19
19
|
TextBlock,
|
20
|
+
ThinkingBlock,
|
21
|
+
RedactedThinkingBlock,
|
20
22
|
MessageParam,
|
21
23
|
ToolUseBlock,
|
22
24
|
RawMessageDeltaEvent,
|
@@ -128,6 +130,8 @@ def refactor_into_openai_messages(messages: Iterable[MessageParam]):
|
|
128
130
|
for item in content:
|
129
131
|
if isinstance(item, (TextBlock, ToolUseBlock)):
|
130
132
|
_content.append(item.model_dump())
|
133
|
+
elif isinstance(item, (ThinkingBlock, RedactedThinkingBlock)):
|
134
|
+
continue
|
131
135
|
elif item.get("type") == "image":
|
132
136
|
image_data = item.get("source", {}).get("data", "")
|
133
137
|
media_type = item.get("source", {}).get("media_type", "")
|
@@ -338,6 +342,9 @@ class AnthropicChatClient(BaseChatClient):
|
|
338
342
|
|
339
343
|
formatted_messages = refactor_into_openai_messages(messages)
|
340
344
|
|
345
|
+
if "thinking" in kwargs:
|
346
|
+
kwargs.pop("thinking") # TODO: 暂时没看到如何处理 openai 接口的 thinking 参数,如 openrouter 中使用
|
347
|
+
|
341
348
|
if self.stream:
|
342
349
|
|
343
350
|
def _generator():
|
@@ -451,7 +458,7 @@ class AnthropicChatClient(BaseChatClient):
|
|
451
458
|
)
|
452
459
|
|
453
460
|
def generator():
|
454
|
-
result = {"content": "", "usage": {}, "tool_calls": []}
|
461
|
+
result = {"content": "", "reasoning_content": "", "usage": {}, "tool_calls": []}
|
455
462
|
for chunk in stream_response:
|
456
463
|
message = {"content": "", "tool_calls": []}
|
457
464
|
if isinstance(chunk, RawMessageStartEvent):
|
@@ -472,11 +479,16 @@ class AnthropicChatClient(BaseChatClient):
|
|
472
479
|
]
|
473
480
|
elif chunk.content_block.type == "text":
|
474
481
|
message["content"] = chunk.content_block.text
|
482
|
+
elif chunk.content_block.type == "thinking":
|
483
|
+
message["reasoning_content"] = chunk.content_block.thinking
|
475
484
|
yield ChatCompletionDeltaMessage(**message)
|
476
485
|
elif isinstance(chunk, RawContentBlockDeltaEvent):
|
477
486
|
if chunk.delta.type == "text_delta":
|
478
487
|
message["content"] = chunk.delta.text
|
479
488
|
result["content"] += chunk.delta.text
|
489
|
+
elif chunk.delta.type == "thinking_delta":
|
490
|
+
message["reasoning_content"] = chunk.delta.thinking
|
491
|
+
result["reasoning_content"] += chunk.delta.thinking
|
480
492
|
elif chunk.delta.type == "input_json_delta":
|
481
493
|
result["tool_calls"][0]["function"]["arguments"] += chunk.delta.partial_json
|
482
494
|
message["tool_calls"] = [
|
@@ -521,6 +533,7 @@ class AnthropicChatClient(BaseChatClient):
|
|
521
533
|
|
522
534
|
result = {
|
523
535
|
"content": "",
|
536
|
+
"reasoning_content": "",
|
524
537
|
"usage": {
|
525
538
|
"prompt_tokens": response.usage.input_tokens,
|
526
539
|
"completion_tokens": response.usage.output_tokens,
|
@@ -531,6 +544,8 @@ class AnthropicChatClient(BaseChatClient):
|
|
531
544
|
for content_block in response.content:
|
532
545
|
if isinstance(content_block, TextBlock):
|
533
546
|
result["content"] += content_block.text
|
547
|
+
elif isinstance(content_block, ThinkingBlock):
|
548
|
+
result["reasoning_content"] = content_block.thinking
|
534
549
|
elif isinstance(content_block, ToolUseBlock):
|
535
550
|
tool_calls.append(content_block.model_dump())
|
536
551
|
|
@@ -728,6 +743,9 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
728
743
|
|
729
744
|
formatted_messages = refactor_into_openai_messages(messages)
|
730
745
|
|
746
|
+
if "thinking" in kwargs:
|
747
|
+
kwargs.pop("thinking") # TODO: 暂时没看到如何处理 openai 接口的 thinking 参数,如 openrouter 中使用
|
748
|
+
|
731
749
|
if self.stream:
|
732
750
|
|
733
751
|
async def _generator():
|
@@ -843,7 +861,7 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
843
861
|
)
|
844
862
|
|
845
863
|
async def generator():
|
846
|
-
result = {"content": "", "usage": {}, "tool_calls": []}
|
864
|
+
result = {"content": "", "reasoning_content": "", "usage": {}, "tool_calls": []}
|
847
865
|
async for chunk in stream_response:
|
848
866
|
message = {"content": "", "tool_calls": []}
|
849
867
|
if isinstance(chunk, RawMessageStartEvent):
|
@@ -864,11 +882,16 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
864
882
|
]
|
865
883
|
elif chunk.content_block.type == "text":
|
866
884
|
message["content"] = chunk.content_block.text
|
885
|
+
elif chunk.content_block.type == "thinking":
|
886
|
+
message["reasoning_content"] = chunk.content_block.thinking
|
867
887
|
yield ChatCompletionDeltaMessage(**message)
|
868
888
|
elif isinstance(chunk, RawContentBlockDeltaEvent):
|
869
889
|
if chunk.delta.type == "text_delta":
|
870
890
|
message["content"] = chunk.delta.text
|
871
891
|
result["content"] += chunk.delta.text
|
892
|
+
elif chunk.delta.type == "thinking_delta":
|
893
|
+
message["reasoning_content"] = chunk.delta.thinking
|
894
|
+
result["reasoning_content"] += chunk.delta.thinking
|
872
895
|
elif chunk.delta.type == "input_json_delta":
|
873
896
|
result["tool_calls"][0]["function"]["arguments"] += chunk.delta.partial_json
|
874
897
|
message["tool_calls"] = [
|
@@ -913,6 +936,7 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
913
936
|
|
914
937
|
result = {
|
915
938
|
"content": "",
|
939
|
+
"reasoning_content": "",
|
916
940
|
"usage": {
|
917
941
|
"prompt_tokens": response.usage.input_tokens,
|
918
942
|
"completion_tokens": response.usage.output_tokens,
|
@@ -923,6 +947,8 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
|
|
923
947
|
for content_block in response.content:
|
924
948
|
if isinstance(content_block, TextBlock):
|
925
949
|
result["content"] += content_block.text
|
950
|
+
elif isinstance(content_block, ThinkingBlock):
|
951
|
+
result["reasoning_content"] = content_block.thinking
|
926
952
|
elif isinstance(content_block, ToolUseBlock):
|
927
953
|
tool_calls.append(content_block.model_dump())
|
928
954
|
|
vectorvein/types/defaults.py
CHANGED
@@ -541,6 +541,14 @@ OPENAI_MODELS: Final[Dict[str, Dict[str, Any]]] = {
|
|
541
541
|
"response_format_available": False,
|
542
542
|
"native_multimodal": False,
|
543
543
|
},
|
544
|
+
"o3-mini": {
|
545
|
+
"id": "o3-mini",
|
546
|
+
"context_length": 200000,
|
547
|
+
"max_output_tokens": 100000,
|
548
|
+
"function_call_available": True,
|
549
|
+
"response_format_available": True,
|
550
|
+
"native_multimodal": False,
|
551
|
+
},
|
544
552
|
}
|
545
553
|
|
546
554
|
# Anthropic models
|
@@ -1,13 +1,13 @@
|
|
1
|
-
vectorvein-0.2.
|
2
|
-
vectorvein-0.2.
|
3
|
-
vectorvein-0.2.
|
1
|
+
vectorvein-0.2.7.dist-info/METADATA,sha256=J67JgDpuGe0YZmLAxOKdkMYKaXD_6LjhSjAzmkzAfSM,4413
|
2
|
+
vectorvein-0.2.7.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
vectorvein-0.2.7.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
9
|
vectorvein/chat_clients/__init__.py,sha256=omQuG4PRRPNflSAgtdU--rwsWG6vMpwMEyIGZyFVHVQ,18596
|
10
|
-
vectorvein/chat_clients/anthropic_client.py,sha256=
|
10
|
+
vectorvein/chat_clients/anthropic_client.py,sha256=8ns9oVFbGoRMWnizmskuDDW2C-xrbVVV_66s3uuhpNM,40079
|
11
11
|
vectorvein/chat_clients/baichuan_client.py,sha256=CVMvpgjdrZGv0BWnTOBD-f2ufZ3wq3496wqukumsAr4,526
|
12
12
|
vectorvein/chat_clients/base_client.py,sha256=QLvcGhjravPbvha6-spU-w6ugHU1LrsbdFUcs6NwMgE,18842
|
13
13
|
vectorvein/chat_clients/deepseek_client.py,sha256=3qWu01NlJAP2N-Ff62d5-CZXZitlizE1fzb20LNetig,526
|
@@ -30,7 +30,7 @@ vectorvein/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
30
|
vectorvein/server/token_server.py,sha256=36F9PKSNOX8ZtYBXY_l-76GQTpUSmQ2Y8EMy1H7wtdQ,1353
|
31
31
|
vectorvein/settings/__init__.py,sha256=ecGyrE_6YfX9z6Igb1rDCu1Q-qMTcVozWF3WEl_hiKA,4871
|
32
32
|
vectorvein/settings/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
|
-
vectorvein/types/defaults.py,sha256=
|
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
36
|
vectorvein/types/llm_parameters.py,sha256=9KJ8z_7xVa0JsV0YPxRKz5n8Eb8PfvB9Y89e6ahjmjw,5989
|
@@ -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.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|