vectorvein 0.2.89__py3-none-any.whl → 0.2.90__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.
@@ -19,6 +19,8 @@ from ..types.llm_parameters import (
19
19
  NOT_GIVEN,
20
20
  ToolParam,
21
21
  VectorVeinMessage,
22
+ VectorVeinTextMessage,
23
+ VectorVeinWorkflowMessage,
22
24
  )
23
25
 
24
26
 
@@ -436,7 +438,7 @@ def format_image_message(image: str, backend: BackendType = BackendType.OpenAI,
436
438
  return {"type": "image_url", "image_url": {"url": image}}
437
439
 
438
440
 
439
- def format_workflow_messages(message: VectorVeinMessage, content: str, backend: BackendType):
441
+ def format_workflow_messages(message: VectorVeinWorkflowMessage, content: str, backend: BackendType):
440
442
  formatted_messages = []
441
443
 
442
444
  # 工具调用消息
@@ -654,13 +656,22 @@ def format_messages(
654
656
  for message in messages:
655
657
  if is_vectorvein_message(message):
656
658
  message = cast(VectorVeinMessage, message)
659
+ match message["content_type"]:
660
+ case "TXT":
661
+ message = cast(VectorVeinTextMessage, message)
662
+ case "WKF":
663
+ message = cast(VectorVeinWorkflowMessage, message)
664
+ case _:
665
+ raise ValueError(f"Unsupported message type: {message['content_type']}")
657
666
  # 处理 VectorVein 格式的消息
658
667
  content = message["content"]["text"]
659
668
  if message["content_type"] == "TXT":
669
+ message = cast(VectorVeinTextMessage, message)
660
670
  role = "user" if message["author_type"] == "U" else "assistant"
661
671
  formatted_message = format_text_message(content, role, message.get("attachments", []), backend, native_multimodal, process_image)
662
672
  formatted_messages.append(formatted_message)
663
673
  elif message["content_type"] == "WKF" and message["status"] in ("S", "R"):
674
+ message = cast(VectorVeinWorkflowMessage, message)
664
675
  formatted_messages.extend(format_workflow_messages(message, content, backend))
665
676
  else:
666
677
  # 处理 OpenAI 格式的消息
@@ -1,7 +1,7 @@
1
1
  # @Author: Bi Ying
2
2
  # @Date: 2024-07-26 23:48:04
3
3
  from typing import List, Dict, Optional, Union, Iterable, Literal
4
- from typing_extensions import TypedDict
4
+ from typing_extensions import TypedDict, NotRequired
5
5
 
6
6
  import httpx
7
7
  from pydantic import BaseModel, Field
@@ -27,16 +27,31 @@ from . import defaults as defs
27
27
  from .settings import EndpointOptionDict
28
28
 
29
29
 
30
- class VectorVeinMessage(TypedDict):
31
- mid: str
32
- author_type: str # "U" for user, "A" for assistant
33
- content_type: str # "TXT" for text, "WKF" for workflow
30
+ class VectorVeinTextMessage(TypedDict):
31
+ mid: NotRequired[str]
32
+ author_type: Literal["U", "A"] # "U" for user, "A" for assistant
33
+ content_type: Literal["TXT"]
34
+ status: NotRequired[str]
35
+ create_time: NotRequired[int]
36
+ update_time: NotRequired[int]
37
+ metadata: NotRequired[dict]
38
+ content: Dict[str, str]
39
+ attachments: NotRequired[List[str]]
40
+
41
+
42
+ class VectorVeinWorkflowMessage(TypedDict):
43
+ mid: NotRequired[str]
44
+ author_type: Literal["U", "A"] # "U" for user, "A" for assistant
45
+ content_type: Literal["WKF"]
34
46
  status: str
35
- create_time: int
36
- update_time: int
47
+ create_time: NotRequired[int]
48
+ update_time: NotRequired[int]
37
49
  metadata: dict
38
50
  content: Dict[str, str]
39
- attachments: List[str]
51
+ attachments: NotRequired[List[str]]
52
+
53
+
54
+ VectorVeinMessage = Union[VectorVeinTextMessage, VectorVeinWorkflowMessage]
40
55
 
41
56
 
42
57
  class EndpointSetting(BaseModel):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.2.89
3
+ Version: 0.2.90
4
4
  Summary: VectorVein Python SDK
5
5
  Author-Email: Anderson <andersonby@163.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
- vectorvein-0.2.89.dist-info/METADATA,sha256=qtcGLIg9q_9vV8GfwmfoDjPJxmnDALprwgNJhJ6Dz5I,4567
2
- vectorvein-0.2.89.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- vectorvein-0.2.89.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
1
+ vectorvein-0.2.90.dist-info/METADATA,sha256=uxiyZMribelfH7JrV7nseeEMhm_XTR9Chcg8bcX2Y80,4567
2
+ vectorvein-0.2.90.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ vectorvein-0.2.90.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
@@ -23,7 +23,7 @@ vectorvein/chat_clients/openai_compatible_client.py,sha256=0nj5DwnY8llctoxbW-UXs
23
23
  vectorvein/chat_clients/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  vectorvein/chat_clients/qwen_client.py,sha256=-ryh-m9PgsO0fc4ulcCmPTy1155J8YUy15uPoJQOHA0,513
25
25
  vectorvein/chat_clients/stepfun_client.py,sha256=zsD2W5ahmR4DD9cqQTXmJr3txrGuvxbRWhFlRdwNijI,519
26
- vectorvein/chat_clients/utils.py,sha256=4mAZt8Fw11zgWjccZb93fjkh41KYFNALi7yCgSzllx0,29936
26
+ vectorvein/chat_clients/utils.py,sha256=rMLRLF0l-D0LjamlZsJOtzQlaqqh-34EapxdCVCQq7E,30486
27
27
  vectorvein/chat_clients/xai_client.py,sha256=eLFJJrNRJ-ni3DpshODcr3S1EJQLbhVwxyO1E54LaqM,491
28
28
  vectorvein/chat_clients/yi_client.py,sha256=RNf4CRuPJfixrwLZ3-DEc3t25QDe1mvZeb9sku2f8Bc,484
29
29
  vectorvein/chat_clients/zhipuai_client.py,sha256=Ys5DSeLCuedaDXr3PfG1EW2zKXopt-awO2IylWSwY0s,519
@@ -35,7 +35,7 @@ vectorvein/types/__init__.py,sha256=2PIMllSLIhgIuM0Ijtms7yDS1dkiGlJVQ1ab9AM2iwk,
35
35
  vectorvein/types/defaults.py,sha256=v6hE1TGWoYcSBzPtlGlRVy4eg0T9qBJAcn7u_a7EZSE,37593
36
36
  vectorvein/types/enums.py,sha256=LplSVkXLBK-t8TWtJKj_f7ktWTd6CSHWRLb67XKMm54,1716
37
37
  vectorvein/types/exception.py,sha256=KtnqZ-1DstHm95SZAyZdHhkGq1bJ4A9Aw3Zfdu-VIFo,130
38
- vectorvein/types/llm_parameters.py,sha256=DfT9Tb3nmZReW2rid466HTCyRCaMPDYKM9UI22LpaBg,8867
38
+ vectorvein/types/llm_parameters.py,sha256=ZQXASYCbct95tVUOXU_rgE3dxffKzyXJG6tVp6FHFkY,9388
39
39
  vectorvein/types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  vectorvein/types/settings.py,sha256=5wINBiT9qj3ZwDiE6Kf4r6wD3yY1bKN40xxZ7F6jEfI,4844
41
41
  vectorvein/utilities/media_processing.py,sha256=TPm73MS_a1WVqpYv0N9BrZcOK-kxWa3QHSFUI_7WgmU,8257
@@ -65,4 +65,4 @@ vectorvein/workflow/utils/analyse.py,sha256=msmvyz35UTYTwqQR5sg9H0sm1vxmGDSmep9X
65
65
  vectorvein/workflow/utils/check.py,sha256=B_NdwqIqnc7Ko2HHqFpfOmWVaAu21tPITe0szKfiZKc,11414
66
66
  vectorvein/workflow/utils/json_to_code.py,sha256=P8dhhSNgKhTnW17qXNjLO2aLdb0rA8qMAWxhObol2TU,7295
67
67
  vectorvein/workflow/utils/layout.py,sha256=j0bRD3uaXu40xCS6U6BGahBI8FrHa5MiF55GbTrZ1LM,4565
68
- vectorvein-0.2.89.dist-info/RECORD,,
68
+ vectorvein-0.2.90.dist-info/RECORD,,