vectorvein 0.2.43__tar.gz → 0.2.45__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.
Files changed (64) hide show
  1. {vectorvein-0.2.43 → vectorvein-0.2.45}/PKG-INFO +1 -1
  2. {vectorvein-0.2.43 → vectorvein-0.2.45}/pyproject.toml +1 -1
  3. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/anthropic_client.py +2 -2
  4. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/openai_compatible_client.py +2 -2
  5. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/utils.py +58 -5
  6. {vectorvein-0.2.43 → vectorvein-0.2.45}/README.md +0 -0
  7. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/__init__.py +0 -0
  8. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/api/__init__.py +0 -0
  9. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/api/client.py +0 -0
  10. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/api/exceptions.py +0 -0
  11. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/api/models.py +0 -0
  12. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/__init__.py +0 -0
  13. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/baichuan_client.py +0 -0
  14. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/base_client.py +0 -0
  15. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/deepseek_client.py +0 -0
  16. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/ernie_client.py +0 -0
  17. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/gemini_client.py +0 -0
  18. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/groq_client.py +0 -0
  19. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/local_client.py +0 -0
  20. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/minimax_client.py +0 -0
  21. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/mistral_client.py +0 -0
  22. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/moonshot_client.py +0 -0
  23. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/openai_client.py +0 -0
  24. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/py.typed +0 -0
  25. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/qwen_client.py +0 -0
  26. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/stepfun_client.py +0 -0
  27. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/xai_client.py +0 -0
  28. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/yi_client.py +0 -0
  29. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/chat_clients/zhipuai_client.py +0 -0
  30. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/py.typed +0 -0
  31. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/server/token_server.py +0 -0
  32. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/settings/__init__.py +0 -0
  33. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/settings/py.typed +0 -0
  34. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/types/__init__.py +0 -0
  35. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/types/defaults.py +0 -0
  36. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/types/enums.py +0 -0
  37. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/types/exception.py +0 -0
  38. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/types/llm_parameters.py +0 -0
  39. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/types/py.typed +0 -0
  40. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/types/settings.py +0 -0
  41. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/utilities/media_processing.py +0 -0
  42. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/utilities/rate_limiter.py +0 -0
  43. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/utilities/retry.py +0 -0
  44. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/graph/edge.py +0 -0
  45. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/graph/node.py +0 -0
  46. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/graph/port.py +0 -0
  47. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/graph/workflow.py +0 -0
  48. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/__init__.py +0 -0
  49. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/audio_generation.py +0 -0
  50. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/control_flows.py +0 -0
  51. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/file_processing.py +0 -0
  52. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/image_generation.py +0 -0
  53. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/llms.py +0 -0
  54. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/media_editing.py +0 -0
  55. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/media_processing.py +0 -0
  56. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/output.py +0 -0
  57. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/relational_db.py +0 -0
  58. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/text_processing.py +0 -0
  59. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/tools.py +0 -0
  60. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/triggers.py +0 -0
  61. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/vector_db.py +0 -0
  62. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/video_generation.py +0 -0
  63. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/nodes/web_crawlers.py +0 -0
  64. {vectorvein-0.2.43 → vectorvein-0.2.45}/src/vectorvein/workflow/utils/json_to_code.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.2.43
3
+ Version: 0.2.45
4
4
  Summary: VectorVein Python SDK
5
5
  Author-Email: Anderson <andersonby@163.com>
6
6
  License: MIT
@@ -17,7 +17,7 @@ description = "VectorVein Python SDK"
17
17
  name = "vectorvein"
18
18
  readme = "README.md"
19
19
  requires-python = ">=3.10"
20
- version = "0.2.43"
20
+ version = "0.2.45"
21
21
 
22
22
  [project.license]
23
23
  text = "MIT"
@@ -211,7 +211,7 @@ class AnthropicChatClient(BaseChatClient):
211
211
  def raw_client(self): # type: ignore
212
212
  self.endpoint, self.model_id = self._set_endpoint()
213
213
 
214
- if self.endpoint.proxy is not None and self.http_client is None:
214
+ if self.endpoint.proxy and self.http_client is None:
215
215
  self.http_client = httpx.Client(proxy=self.endpoint.proxy)
216
216
 
217
217
  if self.endpoint.is_vertex or self.endpoint.endpoint_type == "anthropic_vertex":
@@ -759,7 +759,7 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
759
759
  def raw_client(self): # type: ignore
760
760
  self.endpoint, self.model_id = self._set_endpoint()
761
761
 
762
- if self.endpoint.proxy is not None and self.http_client is None:
762
+ if self.endpoint.proxy and self.http_client is None:
763
763
  self.http_client = httpx.AsyncClient(proxy=self.endpoint.proxy)
764
764
 
765
765
  if self.endpoint.is_vertex or self.endpoint.endpoint_type == "anthropic_vertex":
@@ -90,7 +90,7 @@ class OpenAICompatibleChatClient(BaseChatClient):
90
90
  def raw_client(self) -> OpenAI | AzureOpenAI:
91
91
  self.endpoint, self.model_id = self._set_endpoint()
92
92
 
93
- if self.endpoint.proxy is not None and self.http_client is None:
93
+ if self.endpoint.proxy and self.http_client is None:
94
94
  self.http_client = httpx.Client(proxy=self.endpoint.proxy)
95
95
 
96
96
  if self.endpoint.is_azure or self.endpoint.endpoint_type == "openai_azure":
@@ -565,7 +565,7 @@ class AsyncOpenAICompatibleChatClient(BaseAsyncChatClient):
565
565
  def raw_client(self):
566
566
  self.endpoint, self.model_id = self._set_endpoint()
567
567
 
568
- if self.endpoint.proxy is not None and self.http_client is None:
568
+ if self.endpoint.proxy and self.http_client is None:
569
569
  self.http_client = httpx.AsyncClient(proxy=self.endpoint.proxy)
570
570
 
571
571
  if self.endpoint.is_azure or self.endpoint.endpoint_type == "openai_azure":
@@ -489,7 +489,9 @@ def format_workflow_messages(message: dict, content: str, backend: BackendType):
489
489
  "type": "function",
490
490
  "function": {
491
491
  "name": message["metadata"]["selected_workflow"]["function_name"],
492
- "arguments": json.dumps(message["metadata"]["selected_workflow"]["params"]),
492
+ "arguments": json.dumps(
493
+ message["metadata"]["selected_workflow"]["params"], ensure_ascii=False
494
+ ),
493
495
  },
494
496
  }
495
497
  ],
@@ -513,7 +515,7 @@ def format_workflow_messages(message: dict, content: str, backend: BackendType):
513
515
  "content": json.dumps(
514
516
  {
515
517
  "name": message["metadata"]["selected_workflow"]["function_name"],
516
- "arguments": json.dumps(message["metadata"]["selected_workflow"]["params"]),
518
+ "arguments": json.dumps(message["metadata"]["selected_workflow"]["params"], ensure_ascii=False),
517
519
  },
518
520
  ensure_ascii=False,
519
521
  ),
@@ -559,7 +561,12 @@ def format_workflow_messages(message: dict, content: str, backend: BackendType):
559
561
  return formatted_messages
560
562
 
561
563
 
562
- def transform_from_openai_message(message: ChatCompletionMessageParam, backend: BackendType):
564
+ def transform_from_openai_message(
565
+ message: ChatCompletionMessageParam,
566
+ backend: BackendType,
567
+ native_multimodal: bool = False,
568
+ function_call_available: bool = False,
569
+ ):
563
570
  role = message.get("role", "user")
564
571
  content = message.get("content", "")
565
572
  tool_calls = message.get("tool_calls", [])
@@ -613,13 +620,57 @@ def transform_from_openai_message(message: ChatCompletionMessageParam, backend:
613
620
  else:
614
621
  return {"role": role, "content": content}
615
622
  else:
616
- return message # 对于其他后端,保持原样
623
+ if isinstance(content, str):
624
+ if not function_call_available:
625
+ if message["role"] == "tool":
626
+ return {
627
+ "role": "user",
628
+ "content": f"Tool<tool_call_id: {message['tool_call_id']}> Call result: {content}",
629
+ }
630
+ elif message["role"] == "assistant":
631
+ if tool_calls:
632
+ tool_calls_content = json.dumps(tool_calls, ensure_ascii=False)
633
+ content += f"Tool calls: {tool_calls_content}"
634
+ return {"role": role, "content": content}
635
+
636
+ return message
637
+ elif isinstance(content, list):
638
+ formatted_content = []
639
+ for item in content:
640
+ if item["type"] == "image_url" and not native_multimodal:
641
+ formatted_content.append({"type": "text", "text": f"Image<image_url: {item['image_url']['url']}>"})
642
+ else:
643
+ formatted_content.append(item)
644
+
645
+ if not function_call_available:
646
+ if message["role"] == "tool":
647
+ role = "user"
648
+ formatted_content = [
649
+ {
650
+ "type": "text",
651
+ "text": f"Tool<tool_call_id: {message['tool_call_id']}> Call result: {formatted_content}",
652
+ }
653
+ ]
654
+ elif message["role"] == "assistant":
655
+ if tool_calls:
656
+ tool_calls_content = json.dumps(tool_calls, ensure_ascii=False)
657
+ formatted_content.append({"type": "text", "text": f"Tool calls: {tool_calls_content}"})
658
+
659
+ return {"role": role, "content": formatted_content}
660
+
661
+ if tool_calls:
662
+ return {"role": role, "content": formatted_content, "tool_calls": tool_calls}
663
+ else:
664
+ return {"role": role, "content": formatted_content}
665
+ else:
666
+ return message
617
667
 
618
668
 
619
669
  def format_messages(
620
670
  messages: list,
621
671
  backend: BackendType = BackendType.OpenAI,
622
672
  native_multimodal: bool = False,
673
+ function_call_available: bool = False,
623
674
  ) -> list:
624
675
  """将 VectorVein 和 OpenAI 的 Message 序列化后的格式转换为不同模型支持的格式
625
676
 
@@ -651,7 +702,9 @@ def format_messages(
651
702
  formatted_messages.extend(format_workflow_messages(message, content, backend))
652
703
  else:
653
704
  # 处理 OpenAI 格式的消息
654
- formatted_message = transform_from_openai_message(message, backend)
705
+ formatted_message = transform_from_openai_message(
706
+ message, backend, native_multimodal, function_call_available
707
+ )
655
708
  formatted_messages.append(formatted_message)
656
709
 
657
710
  return formatted_messages
File without changes