dify-oapi2 0.4.0__py3-none-any.whl → 0.5.0__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.
- dify_oapi/api/chat/v1/model/__init__.py +37 -0
- dify_oapi/api/chat/v1/model/agent_thought.py +69 -0
- dify_oapi/api/chat/v1/model/annotation_info.py +43 -0
- dify_oapi/api/chat/v1/model/app_info.py +35 -0
- dify_oapi/api/chat/v1/model/app_parameters.py +494 -0
- dify_oapi/api/chat/v1/model/audio_to_text_request_body.py +2 -2
- dify_oapi/api/chat/v1/model/chat_file.py +53 -0
- dify_oapi/api/chat/v1/model/chat_request_body.py +26 -13
- dify_oapi/api/chat/v1/model/chat_response.py +12 -2
- dify_oapi/api/chat/v1/model/chat_types.py +65 -0
- dify_oapi/api/chat/v1/model/configure_annotation_reply_request.py +36 -0
- dify_oapi/api/chat/v1/model/configure_annotation_reply_request_body.py +39 -0
- dify_oapi/api/chat/v1/model/configure_annotation_reply_response.py +10 -0
- dify_oapi/api/chat/v1/model/conversation_info.py +57 -0
- dify_oapi/api/chat/v1/model/conversation_variable.py +55 -0
- dify_oapi/api/chat/v1/model/create_annotation_request.py +29 -0
- dify_oapi/api/chat/v1/model/create_annotation_request_body.py +32 -0
- dify_oapi/api/chat/v1/model/create_annotation_response.py +9 -0
- dify_oapi/api/chat/v1/model/delete_annotation_request.py +26 -0
- dify_oapi/api/chat/v1/model/delete_annotation_response.py +7 -0
- dify_oapi/api/chat/v1/model/feedback_info.py +75 -0
- dify_oapi/api/chat/v1/model/file_info.py +59 -0
- dify_oapi/api/chat/v1/model/get_annotation_reply_status_request.py +32 -0
- dify_oapi/api/chat/v1/model/get_annotation_reply_status_response.py +11 -0
- dify_oapi/api/chat/v1/model/get_app_info_request.py +24 -0
- dify_oapi/api/chat/v1/model/get_app_info_response.py +9 -0
- dify_oapi/api/chat/v1/model/get_app_meta_request.py +24 -0
- dify_oapi/api/chat/v1/model/get_app_meta_response.py +9 -0
- dify_oapi/api/chat/v1/model/get_app_parameters_request.py +28 -0
- dify_oapi/api/chat/v1/model/get_app_parameters_response.py +9 -0
- dify_oapi/api/chat/v1/model/get_conversation_list_request.py +25 -24
- dify_oapi/api/chat/v1/model/get_conversation_list_response.py +4 -15
- dify_oapi/api/chat/v1/model/get_conversation_variables_request.py +54 -0
- dify_oapi/api/chat/v1/model/get_conversation_variables_response.py +10 -0
- dify_oapi/api/chat/v1/model/get_feedbacks_request.py +32 -0
- dify_oapi/api/chat/v1/model/get_feedbacks_response.py +7 -0
- dify_oapi/api/chat/v1/model/get_site_settings_request.py +24 -0
- dify_oapi/api/chat/v1/model/get_site_settings_response.py +9 -0
- dify_oapi/api/chat/v1/model/get_suggested_questions_request.py +36 -0
- dify_oapi/api/chat/v1/model/{message_suggested_response.py → get_suggested_questions_response.py} +1 -1
- dify_oapi/api/chat/v1/model/list_annotations_request.py +32 -0
- dify_oapi/api/chat/v1/model/list_annotations_response.py +11 -0
- dify_oapi/api/chat/v1/model/message_file.py +46 -0
- dify_oapi/api/chat/v1/model/message_history_request.py +24 -24
- dify_oapi/api/chat/v1/model/message_history_response.py +4 -43
- dify_oapi/api/chat/v1/model/message_info.py +73 -0
- dify_oapi/api/chat/v1/model/pagination_info.py +44 -0
- dify_oapi/api/chat/v1/model/rename_conversation_request_body.py +1 -1
- dify_oapi/api/chat/v1/model/retriever_resource.py +64 -0
- dify_oapi/api/chat/v1/model/site_settings.py +92 -0
- dify_oapi/api/chat/v1/model/submit_feedback_request.py +34 -0
- dify_oapi/api/chat/v1/model/submit_feedback_request_body.py +33 -0
- dify_oapi/api/chat/v1/model/submit_feedback_response.py +5 -0
- dify_oapi/api/chat/v1/model/text_to_audio_request.py +32 -0
- dify_oapi/api/chat/v1/model/text_to_audio_request_body.py +33 -0
- dify_oapi/api/chat/v1/model/text_to_audio_response.py +7 -0
- dify_oapi/api/chat/v1/model/tool_icon.py +52 -0
- dify_oapi/api/chat/v1/model/update_annotation_request.py +33 -0
- dify_oapi/api/chat/v1/model/update_annotation_request_body.py +32 -0
- dify_oapi/api/chat/v1/model/update_annotation_response.py +9 -0
- dify_oapi/api/chat/v1/model/upload_file_request.py +54 -0
- dify_oapi/api/chat/v1/model/upload_file_request_body.py +29 -0
- dify_oapi/api/chat/v1/model/upload_file_response.py +10 -0
- dify_oapi/api/chat/v1/model/usage_info.py +84 -0
- dify_oapi/api/chat/v1/resource/__init__.py +7 -3
- dify_oapi/api/chat/v1/resource/annotation.py +77 -0
- dify_oapi/api/chat/v1/resource/app.py +47 -0
- dify_oapi/api/chat/v1/resource/audio.py +13 -0
- dify_oapi/api/chat/v1/resource/chat.py +14 -0
- dify_oapi/api/chat/v1/resource/conversation.py +55 -9
- dify_oapi/api/chat/v1/resource/feedback.py +31 -0
- dify_oapi/api/chat/v1/resource/file.py +25 -0
- dify_oapi/api/chat/v1/resource/message.py +19 -15
- dify_oapi/api/chat/v1/version.py +8 -2
- dify_oapi/api/chatflow/__init__.py +0 -0
- dify_oapi/api/chatflow/service.py +25 -0
- dify_oapi/api/chatflow/v1/__init__.py +0 -0
- dify_oapi/api/chatflow/v1/model/__init__.py +0 -0
- dify_oapi/api/chatflow/v1/model/annotation_info.py +43 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_settings_request.py +37 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_settings_request_body.py +33 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_settings_response.py +10 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_status_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_status_response.py +11 -0
- dify_oapi/api/chatflow/v1/model/app_info.py +33 -0
- dify_oapi/api/chatflow/v1/model/app_parameters.py +276 -0
- dify_oapi/api/chatflow/v1/model/audio_to_text_request.py +37 -0
- dify_oapi/api/chatflow/v1/model/audio_to_text_response.py +21 -0
- dify_oapi/api/chatflow/v1/model/chat_file.py +40 -0
- dify_oapi/api/chatflow/v1/model/chat_message.py +88 -0
- dify_oapi/api/chatflow/v1/model/chatflow_types.py +210 -0
- dify_oapi/api/chatflow/v1/model/conversation_info.py +53 -0
- dify_oapi/api/chatflow/v1/model/conversation_variable.py +55 -0
- dify_oapi/api/chatflow/v1/model/create_annotation_request.py +30 -0
- dify_oapi/api/chatflow/v1/model/create_annotation_request_body.py +28 -0
- dify_oapi/api/chatflow/v1/model/create_annotation_response.py +9 -0
- dify_oapi/api/chatflow/v1/model/delete_annotation_request.py +28 -0
- dify_oapi/api/chatflow/v1/model/delete_annotation_response.py +7 -0
- dify_oapi/api/chatflow/v1/model/delete_conversation_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/delete_conversation_request_body.py +21 -0
- dify_oapi/api/chatflow/v1/model/delete_conversation_response.py +17 -0
- dify_oapi/api/chatflow/v1/model/feedback_info.py +75 -0
- dify_oapi/api/chatflow/v1/model/file_info.py +53 -0
- dify_oapi/api/chatflow/v1/model/get_annotations_request.py +30 -0
- dify_oapi/api/chatflow/v1/model/get_annotations_response.py +13 -0
- dify_oapi/api/chatflow/v1/model/get_app_feedbacks_request.py +30 -0
- dify_oapi/api/chatflow/v1/model/get_app_feedbacks_response.py +23 -0
- dify_oapi/api/chatflow/v1/model/get_conversation_messages_request.py +38 -0
- dify_oapi/api/chatflow/v1/model/get_conversation_messages_response.py +33 -0
- dify_oapi/api/chatflow/v1/model/get_conversation_variables_request.py +44 -0
- dify_oapi/api/chatflow/v1/model/get_conversation_variables_response.py +33 -0
- dify_oapi/api/chatflow/v1/model/get_conversations_request.py +40 -0
- dify_oapi/api/chatflow/v1/model/get_conversations_response.py +33 -0
- dify_oapi/api/chatflow/v1/model/get_info_request.py +22 -0
- dify_oapi/api/chatflow/v1/model/get_info_response.py +7 -0
- dify_oapi/api/chatflow/v1/model/get_meta_request.py +22 -0
- dify_oapi/api/chatflow/v1/model/get_meta_response.py +7 -0
- dify_oapi/api/chatflow/v1/model/get_parameters_request.py +22 -0
- dify_oapi/api/chatflow/v1/model/get_parameters_response.py +7 -0
- dify_oapi/api/chatflow/v1/model/get_site_request.py +22 -0
- dify_oapi/api/chatflow/v1/model/get_site_response.py +7 -0
- dify_oapi/api/chatflow/v1/model/get_suggested_questions_request.py +32 -0
- dify_oapi/api/chatflow/v1/model/get_suggested_questions_response.py +6 -0
- dify_oapi/api/chatflow/v1/model/message_feedback_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/message_feedback_request_body.py +33 -0
- dify_oapi/api/chatflow/v1/model/message_feedback_response.py +21 -0
- dify_oapi/api/chatflow/v1/model/rename_conversation_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/rename_conversation_request_body.py +31 -0
- dify_oapi/api/chatflow/v1/model/rename_conversation_response.py +53 -0
- dify_oapi/api/chatflow/v1/model/retriever_resource.py +58 -0
- dify_oapi/api/chatflow/v1/model/send_chat_message_request.py +30 -0
- dify_oapi/api/chatflow/v1/model/send_chat_message_request_body.py +54 -0
- dify_oapi/api/chatflow/v1/model/send_chat_message_response.py +7 -0
- dify_oapi/api/chatflow/v1/model/stop_chat_message_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/stop_chat_message_request_body.py +21 -0
- dify_oapi/api/chatflow/v1/model/stop_chat_message_response.py +5 -0
- dify_oapi/api/chatflow/v1/model/text_to_audio_request.py +30 -0
- dify_oapi/api/chatflow/v1/model/text_to_audio_request_body.py +36 -0
- dify_oapi/api/chatflow/v1/model/text_to_audio_response.py +19 -0
- dify_oapi/api/chatflow/v1/model/tool_icon.py +48 -0
- dify_oapi/api/chatflow/v1/model/update_annotation_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/update_annotation_request_body.py +28 -0
- dify_oapi/api/chatflow/v1/model/update_annotation_response.py +9 -0
- dify_oapi/api/chatflow/v1/model/upload_file_request.py +41 -0
- dify_oapi/api/chatflow/v1/model/upload_file_response.py +11 -0
- dify_oapi/api/chatflow/v1/model/usage_info.py +78 -0
- dify_oapi/api/chatflow/v1/model/user_input_form.py +141 -0
- dify_oapi/api/chatflow/v1/model/webapp_settings.py +88 -0
- dify_oapi/api/chatflow/v1/resource/__init__.py +0 -0
- dify_oapi/api/chatflow/v1/resource/annotation.py +122 -0
- dify_oapi/api/chatflow/v1/resource/application.py +76 -0
- dify_oapi/api/chatflow/v1/resource/chatflow.py +91 -0
- dify_oapi/api/chatflow/v1/resource/conversation.py +104 -0
- dify_oapi/api/chatflow/v1/resource/feedback.py +69 -0
- dify_oapi/api/chatflow/v1/resource/file.py +39 -0
- dify_oapi/api/chatflow/v1/resource/tts.py +29 -0
- dify_oapi/api/chatflow/v1/version.py +29 -0
- dify_oapi/api/knowledge/v1/model/data_source_detail.py +23 -0
- dify_oapi/api/knowledge/v1/model/dataset_info.py +10 -9
- dify_oapi/api/knowledge/v1/model/dataset_metadata.py +14 -0
- dify_oapi/api/knowledge/v1/model/document_info.py +18 -6
- dify_oapi/api/knowledge/v1/model/external_knowledge_info.py +11 -1
- dify_oapi/api/knowledge/v1/model/external_retrieval_model.py +13 -0
- dify_oapi/api/knowledge/v1/model/knowledge_types.py +2 -2
- dify_oapi/api/knowledge/v1/model/retrieval_model.py +10 -4
- dify_oapi/api/knowledge/v1/model/weights.py +27 -0
- dify_oapi/api/workflow/v1/model/chunk_workflow_event.py +74 -0
- dify_oapi/api/workflow/v1/model/input_file_object_workflow.py +76 -0
- dify_oapi/api/workflow/v1/model/node_finished_data.py +118 -0
- dify_oapi/api/workflow/v1/model/node_started_data.py +81 -0
- dify_oapi/api/workflow/v1/model/ping_data.py +28 -0
- dify_oapi/api/workflow/v1/model/run_workflow_request_body.py +1 -1
- dify_oapi/api/workflow/v1/model/text_chunk_data.py +39 -0
- dify_oapi/api/workflow/v1/model/tts_message_data.py +45 -0
- dify_oapi/api/workflow/v1/model/tts_message_end_data.py +45 -0
- dify_oapi/api/workflow/v1/model/workflow_completion_response.py +50 -0
- dify_oapi/api/workflow/v1/model/workflow_finished_data.py +93 -0
- dify_oapi/api/workflow/v1/model/workflow_started_data.py +51 -0
- dify_oapi/api/workflow/v1/model/workflow_types.py +27 -12
- dify_oapi/client.py +45 -0
- dify_oapi/core/http/transport/__init__.py +2 -1
- dify_oapi/core/http/transport/async_transport.py +73 -50
- dify_oapi/core/http/transport/connection_pool.py +131 -0
- dify_oapi/core/http/transport/sync_transport.py +73 -50
- dify_oapi/core/model/config.py +10 -0
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-0.5.0.dist-info}/METADATA +44 -12
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-0.5.0.dist-info}/RECORD +189 -34
- dify_oapi/api/chat/v1/model/chat_request_file.py +0 -46
- dify_oapi/api/chat/v1/model/message_suggested_request.py +0 -36
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-0.5.0.dist-info}/LICENSE +0 -0
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-0.5.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
"""Node started event data model.
|
2
|
+
|
3
|
+
This module defines the data structure for node_started streaming events.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from typing import Any, Optional
|
7
|
+
|
8
|
+
from pydantic import BaseModel
|
9
|
+
|
10
|
+
from .workflow_types import NodeType
|
11
|
+
|
12
|
+
|
13
|
+
class NodeStartedData(BaseModel):
|
14
|
+
"""Data structure for node_started streaming event."""
|
15
|
+
|
16
|
+
id: str
|
17
|
+
node_id: str
|
18
|
+
node_type: NodeType
|
19
|
+
title: str
|
20
|
+
index: int
|
21
|
+
predecessor_node_id: Optional[str] = None
|
22
|
+
inputs: dict[str, Any]
|
23
|
+
created_at: int
|
24
|
+
|
25
|
+
@staticmethod
|
26
|
+
def builder() -> "NodeStartedDataBuilder":
|
27
|
+
"""Create a new NodeStartedData builder."""
|
28
|
+
return NodeStartedDataBuilder()
|
29
|
+
|
30
|
+
|
31
|
+
class NodeStartedDataBuilder:
|
32
|
+
"""Builder for NodeStartedData."""
|
33
|
+
|
34
|
+
def __init__(self):
|
35
|
+
self._node_started_data = NodeStartedData(
|
36
|
+
id="", node_id="", node_type="start", title="", index=0, inputs={}, created_at=0
|
37
|
+
)
|
38
|
+
|
39
|
+
def build(self) -> NodeStartedData:
|
40
|
+
"""Build the NodeStartedData instance."""
|
41
|
+
return self._node_started_data
|
42
|
+
|
43
|
+
def id(self, id: str) -> "NodeStartedDataBuilder":
|
44
|
+
"""Set the node execution ID."""
|
45
|
+
self._node_started_data.id = id
|
46
|
+
return self
|
47
|
+
|
48
|
+
def node_id(self, node_id: str) -> "NodeStartedDataBuilder":
|
49
|
+
"""Set the node ID."""
|
50
|
+
self._node_started_data.node_id = node_id
|
51
|
+
return self
|
52
|
+
|
53
|
+
def node_type(self, node_type: NodeType) -> "NodeStartedDataBuilder":
|
54
|
+
"""Set the node type."""
|
55
|
+
self._node_started_data.node_type = node_type
|
56
|
+
return self
|
57
|
+
|
58
|
+
def title(self, title: str) -> "NodeStartedDataBuilder":
|
59
|
+
"""Set the node title."""
|
60
|
+
self._node_started_data.title = title
|
61
|
+
return self
|
62
|
+
|
63
|
+
def index(self, index: int) -> "NodeStartedDataBuilder":
|
64
|
+
"""Set the node index."""
|
65
|
+
self._node_started_data.index = index
|
66
|
+
return self
|
67
|
+
|
68
|
+
def predecessor_node_id(self, predecessor_node_id: str) -> "NodeStartedDataBuilder":
|
69
|
+
"""Set the predecessor node ID."""
|
70
|
+
self._node_started_data.predecessor_node_id = predecessor_node_id
|
71
|
+
return self
|
72
|
+
|
73
|
+
def inputs(self, inputs: dict[str, Any]) -> "NodeStartedDataBuilder":
|
74
|
+
"""Set the node inputs."""
|
75
|
+
self._node_started_data.inputs = inputs
|
76
|
+
return self
|
77
|
+
|
78
|
+
def created_at(self, created_at: int) -> "NodeStartedDataBuilder":
|
79
|
+
"""Set the creation timestamp."""
|
80
|
+
self._node_started_data.created_at = created_at
|
81
|
+
return self
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"""Ping event data model.
|
2
|
+
|
3
|
+
This module defines the data structure for ping streaming events.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from pydantic import BaseModel
|
7
|
+
|
8
|
+
|
9
|
+
class PingData(BaseModel):
|
10
|
+
"""Data structure for ping streaming event (empty data)."""
|
11
|
+
|
12
|
+
pass
|
13
|
+
|
14
|
+
@staticmethod
|
15
|
+
def builder() -> "PingDataBuilder":
|
16
|
+
"""Create a new PingData builder."""
|
17
|
+
return PingDataBuilder()
|
18
|
+
|
19
|
+
|
20
|
+
class PingDataBuilder:
|
21
|
+
"""Builder for PingData."""
|
22
|
+
|
23
|
+
def __init__(self):
|
24
|
+
self._ping_data = PingData()
|
25
|
+
|
26
|
+
def build(self) -> PingData:
|
27
|
+
"""Build the PingData instance."""
|
28
|
+
return self._ping_data
|
@@ -9,7 +9,7 @@ from .workflow_types import ResponseMode
|
|
9
9
|
|
10
10
|
class RunWorkflowRequestBody(BaseModel):
|
11
11
|
inputs: WorkflowInputs | None = None
|
12
|
-
response_mode: ResponseMode | None =
|
12
|
+
response_mode: ResponseMode | None = "streaming"
|
13
13
|
user: str | None = None
|
14
14
|
files: list[WorkflowFileInfo] | None = None
|
15
15
|
trace_id: str | None = None
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"""Text chunk event data model.
|
2
|
+
|
3
|
+
This module defines the data structure for text_chunk streaming events.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from pydantic import BaseModel
|
7
|
+
|
8
|
+
|
9
|
+
class TextChunkData(BaseModel):
|
10
|
+
"""Data structure for text_chunk streaming event."""
|
11
|
+
|
12
|
+
text: str
|
13
|
+
from_variable_selector: list[str]
|
14
|
+
|
15
|
+
@staticmethod
|
16
|
+
def builder() -> "TextChunkDataBuilder":
|
17
|
+
"""Create a new TextChunkData builder."""
|
18
|
+
return TextChunkDataBuilder()
|
19
|
+
|
20
|
+
|
21
|
+
class TextChunkDataBuilder:
|
22
|
+
"""Builder for TextChunkData."""
|
23
|
+
|
24
|
+
def __init__(self):
|
25
|
+
self._text_chunk_data = TextChunkData(text="", from_variable_selector=[])
|
26
|
+
|
27
|
+
def build(self) -> TextChunkData:
|
28
|
+
"""Build the TextChunkData instance."""
|
29
|
+
return self._text_chunk_data
|
30
|
+
|
31
|
+
def text(self, text: str) -> "TextChunkDataBuilder":
|
32
|
+
"""Set the text chunk."""
|
33
|
+
self._text_chunk_data.text = text
|
34
|
+
return self
|
35
|
+
|
36
|
+
def from_variable_selector(self, from_variable_selector: list[str]) -> "TextChunkDataBuilder":
|
37
|
+
"""Set the variable selector path."""
|
38
|
+
self._text_chunk_data.from_variable_selector = from_variable_selector
|
39
|
+
return self
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"""TTS message event data model.
|
2
|
+
|
3
|
+
This module defines the data structure for tts_message streaming events.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from pydantic import BaseModel
|
7
|
+
|
8
|
+
|
9
|
+
class TtsMessageData(BaseModel):
|
10
|
+
"""Data structure for tts_message streaming event."""
|
11
|
+
|
12
|
+
message_id: str
|
13
|
+
audio: str # Base64 encoded audio data
|
14
|
+
created_at: int
|
15
|
+
|
16
|
+
@staticmethod
|
17
|
+
def builder() -> "TtsMessageDataBuilder":
|
18
|
+
"""Create a new TtsMessageData builder."""
|
19
|
+
return TtsMessageDataBuilder()
|
20
|
+
|
21
|
+
|
22
|
+
class TtsMessageDataBuilder:
|
23
|
+
"""Builder for TtsMessageData."""
|
24
|
+
|
25
|
+
def __init__(self):
|
26
|
+
self._tts_message_data = TtsMessageData(message_id="", audio="", created_at=0)
|
27
|
+
|
28
|
+
def build(self) -> TtsMessageData:
|
29
|
+
"""Build the TtsMessageData instance."""
|
30
|
+
return self._tts_message_data
|
31
|
+
|
32
|
+
def message_id(self, message_id: str) -> "TtsMessageDataBuilder":
|
33
|
+
"""Set the message ID."""
|
34
|
+
self._tts_message_data.message_id = message_id
|
35
|
+
return self
|
36
|
+
|
37
|
+
def audio(self, audio: str) -> "TtsMessageDataBuilder":
|
38
|
+
"""Set the base64 encoded audio data."""
|
39
|
+
self._tts_message_data.audio = audio
|
40
|
+
return self
|
41
|
+
|
42
|
+
def created_at(self, created_at: int) -> "TtsMessageDataBuilder":
|
43
|
+
"""Set the creation timestamp."""
|
44
|
+
self._tts_message_data.created_at = created_at
|
45
|
+
return self
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"""TTS message end event data model.
|
2
|
+
|
3
|
+
This module defines the data structure for tts_message_end streaming events.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from pydantic import BaseModel
|
7
|
+
|
8
|
+
|
9
|
+
class TtsMessageEndData(BaseModel):
|
10
|
+
"""Data structure for tts_message_end streaming event."""
|
11
|
+
|
12
|
+
message_id: str
|
13
|
+
audio: str # Empty string for end event
|
14
|
+
created_at: int
|
15
|
+
|
16
|
+
@staticmethod
|
17
|
+
def builder() -> "TtsMessageEndDataBuilder":
|
18
|
+
"""Create a new TtsMessageEndData builder."""
|
19
|
+
return TtsMessageEndDataBuilder()
|
20
|
+
|
21
|
+
|
22
|
+
class TtsMessageEndDataBuilder:
|
23
|
+
"""Builder for TtsMessageEndData."""
|
24
|
+
|
25
|
+
def __init__(self):
|
26
|
+
self._tts_message_end_data = TtsMessageEndData(message_id="", audio="", created_at=0)
|
27
|
+
|
28
|
+
def build(self) -> TtsMessageEndData:
|
29
|
+
"""Build the TtsMessageEndData instance."""
|
30
|
+
return self._tts_message_end_data
|
31
|
+
|
32
|
+
def message_id(self, message_id: str) -> "TtsMessageEndDataBuilder":
|
33
|
+
"""Set the message ID."""
|
34
|
+
self._tts_message_end_data.message_id = message_id
|
35
|
+
return self
|
36
|
+
|
37
|
+
def audio(self, audio: str) -> "TtsMessageEndDataBuilder":
|
38
|
+
"""Set the audio data (empty for end event)."""
|
39
|
+
self._tts_message_end_data.audio = audio
|
40
|
+
return self
|
41
|
+
|
42
|
+
def created_at(self, created_at: int) -> "TtsMessageEndDataBuilder":
|
43
|
+
"""Set the creation timestamp."""
|
44
|
+
self._tts_message_end_data.created_at = created_at
|
45
|
+
return self
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"""Workflow completion response for blocking mode.
|
2
|
+
|
3
|
+
This module defines the WorkflowCompletionResponse model for handling
|
4
|
+
workflow execution results in blocking mode.
|
5
|
+
"""
|
6
|
+
|
7
|
+
from pydantic import BaseModel
|
8
|
+
|
9
|
+
from .workflow_run_data import WorkflowRunData
|
10
|
+
|
11
|
+
|
12
|
+
class WorkflowCompletionResponse(BaseModel):
|
13
|
+
"""Response structure for workflow execution in blocking mode."""
|
14
|
+
|
15
|
+
workflow_run_id: str
|
16
|
+
task_id: str
|
17
|
+
data: WorkflowRunData
|
18
|
+
|
19
|
+
@staticmethod
|
20
|
+
def builder() -> "WorkflowCompletionResponseBuilder":
|
21
|
+
"""Create a new WorkflowCompletionResponse builder."""
|
22
|
+
return WorkflowCompletionResponseBuilder()
|
23
|
+
|
24
|
+
|
25
|
+
class WorkflowCompletionResponseBuilder:
|
26
|
+
"""Builder for WorkflowCompletionResponse."""
|
27
|
+
|
28
|
+
def __init__(self):
|
29
|
+
self._workflow_completion_response = WorkflowCompletionResponse(
|
30
|
+
workflow_run_id="", task_id="", data=WorkflowRunData()
|
31
|
+
)
|
32
|
+
|
33
|
+
def build(self) -> WorkflowCompletionResponse:
|
34
|
+
"""Build the WorkflowCompletionResponse instance."""
|
35
|
+
return self._workflow_completion_response
|
36
|
+
|
37
|
+
def workflow_run_id(self, workflow_run_id: str) -> "WorkflowCompletionResponseBuilder":
|
38
|
+
"""Set the workflow run ID."""
|
39
|
+
self._workflow_completion_response.workflow_run_id = workflow_run_id
|
40
|
+
return self
|
41
|
+
|
42
|
+
def task_id(self, task_id: str) -> "WorkflowCompletionResponseBuilder":
|
43
|
+
"""Set the task ID."""
|
44
|
+
self._workflow_completion_response.task_id = task_id
|
45
|
+
return self
|
46
|
+
|
47
|
+
def data(self, data: WorkflowRunData) -> "WorkflowCompletionResponseBuilder":
|
48
|
+
"""Set the workflow run data."""
|
49
|
+
self._workflow_completion_response.data = data
|
50
|
+
return self
|
@@ -0,0 +1,93 @@
|
|
1
|
+
"""Workflow finished event data model.
|
2
|
+
|
3
|
+
This module defines the data structure for workflow_finished streaming events.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from typing import Any, Optional
|
7
|
+
|
8
|
+
from pydantic import BaseModel
|
9
|
+
|
10
|
+
from .workflow_types import WorkflowStatus
|
11
|
+
|
12
|
+
|
13
|
+
class WorkflowFinishedData(BaseModel):
|
14
|
+
"""Data structure for workflow_finished streaming event."""
|
15
|
+
|
16
|
+
id: str
|
17
|
+
workflow_id: str
|
18
|
+
status: WorkflowStatus
|
19
|
+
outputs: Optional[dict[str, Any]] = None
|
20
|
+
error: Optional[str] = None
|
21
|
+
elapsed_time: Optional[float] = None
|
22
|
+
total_tokens: Optional[int] = None
|
23
|
+
total_steps: int
|
24
|
+
created_at: int
|
25
|
+
finished_at: int
|
26
|
+
|
27
|
+
@staticmethod
|
28
|
+
def builder() -> "WorkflowFinishedDataBuilder":
|
29
|
+
"""Create a new WorkflowFinishedData builder."""
|
30
|
+
return WorkflowFinishedDataBuilder()
|
31
|
+
|
32
|
+
|
33
|
+
class WorkflowFinishedDataBuilder:
|
34
|
+
"""Builder for WorkflowFinishedData."""
|
35
|
+
|
36
|
+
def __init__(self):
|
37
|
+
self._workflow_finished_data = WorkflowFinishedData(
|
38
|
+
id="", workflow_id="", status="succeeded", total_steps=0, created_at=0, finished_at=0
|
39
|
+
)
|
40
|
+
|
41
|
+
def build(self) -> WorkflowFinishedData:
|
42
|
+
"""Build the WorkflowFinishedData instance."""
|
43
|
+
return self._workflow_finished_data
|
44
|
+
|
45
|
+
def id(self, id: str) -> "WorkflowFinishedDataBuilder":
|
46
|
+
"""Set the workflow run ID."""
|
47
|
+
self._workflow_finished_data.id = id
|
48
|
+
return self
|
49
|
+
|
50
|
+
def workflow_id(self, workflow_id: str) -> "WorkflowFinishedDataBuilder":
|
51
|
+
"""Set the workflow ID."""
|
52
|
+
self._workflow_finished_data.workflow_id = workflow_id
|
53
|
+
return self
|
54
|
+
|
55
|
+
def status(self, status: WorkflowStatus) -> "WorkflowFinishedDataBuilder":
|
56
|
+
"""Set the workflow status."""
|
57
|
+
self._workflow_finished_data.status = status
|
58
|
+
return self
|
59
|
+
|
60
|
+
def outputs(self, outputs: dict[str, Any]) -> "WorkflowFinishedDataBuilder":
|
61
|
+
"""Set the workflow outputs."""
|
62
|
+
self._workflow_finished_data.outputs = outputs
|
63
|
+
return self
|
64
|
+
|
65
|
+
def error(self, error: str) -> "WorkflowFinishedDataBuilder":
|
66
|
+
"""Set the error message."""
|
67
|
+
self._workflow_finished_data.error = error
|
68
|
+
return self
|
69
|
+
|
70
|
+
def elapsed_time(self, elapsed_time: float) -> "WorkflowFinishedDataBuilder":
|
71
|
+
"""Set the elapsed time."""
|
72
|
+
self._workflow_finished_data.elapsed_time = elapsed_time
|
73
|
+
return self
|
74
|
+
|
75
|
+
def total_tokens(self, total_tokens: int) -> "WorkflowFinishedDataBuilder":
|
76
|
+
"""Set the total tokens."""
|
77
|
+
self._workflow_finished_data.total_tokens = total_tokens
|
78
|
+
return self
|
79
|
+
|
80
|
+
def total_steps(self, total_steps: int) -> "WorkflowFinishedDataBuilder":
|
81
|
+
"""Set the total steps."""
|
82
|
+
self._workflow_finished_data.total_steps = total_steps
|
83
|
+
return self
|
84
|
+
|
85
|
+
def created_at(self, created_at: int) -> "WorkflowFinishedDataBuilder":
|
86
|
+
"""Set the creation timestamp."""
|
87
|
+
self._workflow_finished_data.created_at = created_at
|
88
|
+
return self
|
89
|
+
|
90
|
+
def finished_at(self, finished_at: int) -> "WorkflowFinishedDataBuilder":
|
91
|
+
"""Set the finish timestamp."""
|
92
|
+
self._workflow_finished_data.finished_at = finished_at
|
93
|
+
return self
|
@@ -0,0 +1,51 @@
|
|
1
|
+
"""Workflow started event data model.
|
2
|
+
|
3
|
+
This module defines the data structure for workflow_started streaming events.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from pydantic import BaseModel
|
7
|
+
|
8
|
+
|
9
|
+
class WorkflowStartedData(BaseModel):
|
10
|
+
"""Data structure for workflow_started streaming event."""
|
11
|
+
|
12
|
+
id: str
|
13
|
+
workflow_id: str
|
14
|
+
sequence_number: int
|
15
|
+
created_at: int
|
16
|
+
|
17
|
+
@staticmethod
|
18
|
+
def builder() -> "WorkflowStartedDataBuilder":
|
19
|
+
"""Create a new WorkflowStartedData builder."""
|
20
|
+
return WorkflowStartedDataBuilder()
|
21
|
+
|
22
|
+
|
23
|
+
class WorkflowStartedDataBuilder:
|
24
|
+
"""Builder for WorkflowStartedData."""
|
25
|
+
|
26
|
+
def __init__(self):
|
27
|
+
self._workflow_started_data = WorkflowStartedData(id="", workflow_id="", sequence_number=0, created_at=0)
|
28
|
+
|
29
|
+
def build(self) -> WorkflowStartedData:
|
30
|
+
"""Build the WorkflowStartedData instance."""
|
31
|
+
return self._workflow_started_data
|
32
|
+
|
33
|
+
def id(self, id: str) -> "WorkflowStartedDataBuilder":
|
34
|
+
"""Set the workflow run ID."""
|
35
|
+
self._workflow_started_data.id = id
|
36
|
+
return self
|
37
|
+
|
38
|
+
def workflow_id(self, workflow_id: str) -> "WorkflowStartedDataBuilder":
|
39
|
+
"""Set the workflow ID."""
|
40
|
+
self._workflow_started_data.workflow_id = workflow_id
|
41
|
+
return self
|
42
|
+
|
43
|
+
def sequence_number(self, sequence_number: int) -> "WorkflowStartedDataBuilder":
|
44
|
+
"""Set the sequence number."""
|
45
|
+
self._workflow_started_data.sequence_number = sequence_number
|
46
|
+
return self
|
47
|
+
|
48
|
+
def created_at(self, created_at: int) -> "WorkflowStartedDataBuilder":
|
49
|
+
"""Set the creation timestamp."""
|
50
|
+
self._workflow_started_data.created_at = created_at
|
51
|
+
return self
|
@@ -1,18 +1,27 @@
|
|
1
|
+
"""Workflow API type definitions.
|
2
|
+
|
3
|
+
This module contains all Literal type definitions for the Workflow API,
|
4
|
+
ensuring strict type safety throughout the workflow module.
|
5
|
+
"""
|
6
|
+
|
1
7
|
from typing import Literal
|
2
8
|
|
3
|
-
# Response mode types
|
9
|
+
# Response mode types for workflow execution
|
4
10
|
ResponseMode = Literal["streaming", "blocking"]
|
5
11
|
|
6
|
-
# File types
|
12
|
+
# File types supported in workflow inputs
|
7
13
|
FileType = Literal["document", "image", "audio", "video", "custom"]
|
8
14
|
|
9
|
-
#
|
15
|
+
# File transfer methods
|
10
16
|
TransferMethod = Literal["remote_url", "local_file"]
|
11
17
|
|
12
|
-
# Workflow status
|
18
|
+
# Workflow execution status
|
13
19
|
WorkflowStatus = Literal["running", "succeeded", "failed", "stopped"]
|
14
20
|
|
15
|
-
#
|
21
|
+
# Node execution status
|
22
|
+
NodeStatus = Literal["running", "succeeded", "failed", "stopped"]
|
23
|
+
|
24
|
+
# Streaming event types
|
16
25
|
EventType = Literal[
|
17
26
|
"workflow_started",
|
18
27
|
"node_started",
|
@@ -24,7 +33,7 @@ EventType = Literal[
|
|
24
33
|
"ping",
|
25
34
|
]
|
26
35
|
|
27
|
-
#
|
36
|
+
# Workflow node types
|
28
37
|
NodeType = Literal[
|
29
38
|
"start",
|
30
39
|
"end",
|
@@ -38,17 +47,23 @@ NodeType = Literal[
|
|
38
47
|
"parameter_extractor",
|
39
48
|
]
|
40
49
|
|
41
|
-
#
|
50
|
+
# WebApp icon types
|
42
51
|
IconType = Literal["emoji", "image"]
|
43
52
|
|
44
|
-
#
|
53
|
+
# Application mode types
|
45
54
|
AppMode = Literal["workflow"]
|
46
55
|
|
47
|
-
# Log status types
|
48
|
-
LogStatus = Literal["succeeded", "failed", "stopped"]
|
56
|
+
# Log status filter types (includes "running" for filtering)
|
57
|
+
LogStatus = Literal["succeeded", "failed", "stopped", "running"]
|
49
58
|
|
50
|
-
#
|
59
|
+
# Creator role types
|
51
60
|
CreatedByRole = Literal["end_user", "account"]
|
52
61
|
|
53
|
-
#
|
62
|
+
# Creation source types
|
54
63
|
CreatedFrom = Literal["service-api", "web-app"]
|
64
|
+
|
65
|
+
# User input form control types
|
66
|
+
UserInputFormType = Literal["text-input", "paragraph", "select"]
|
67
|
+
|
68
|
+
# UUID format validation pattern
|
69
|
+
UUID_PATTERN = r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
|
dify_oapi/client.py
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import ssl
|
4
|
+
|
3
5
|
from .api.chat.service import ChatService
|
6
|
+
from .api.chatflow.service import ChatflowService
|
4
7
|
from .api.completion.service import CompletionService
|
5
8
|
from .api.dify.service import DifyService
|
6
9
|
from .api.knowledge.service import Knowledge
|
7
10
|
from .api.workflow.service import WorkflowService
|
8
11
|
from .core.enum import LogLevel
|
9
12
|
from .core.http.transport import Transport
|
13
|
+
from .core.http.transport.connection_pool import connection_pool
|
10
14
|
from .core.log import logger
|
11
15
|
from .core.model.base_request import BaseRequest
|
12
16
|
from .core.model.config import Config
|
@@ -16,6 +20,7 @@ class Client:
|
|
16
20
|
def __init__(self):
|
17
21
|
self._config: Config | None = None
|
18
22
|
self._chat: ChatService | None = None
|
23
|
+
self._chatflow: ChatflowService | None = None
|
19
24
|
self._completion: CompletionService | None = None
|
20
25
|
self._dify: DifyService | None = None
|
21
26
|
self._workflow: WorkflowService | None = None
|
@@ -27,6 +32,12 @@ class Client:
|
|
27
32
|
raise RuntimeError("Chat service has not been initialized")
|
28
33
|
return self._chat
|
29
34
|
|
35
|
+
@property
|
36
|
+
def chatflow(self) -> ChatflowService:
|
37
|
+
if self._chatflow is None:
|
38
|
+
raise RuntimeError("Chatflow service has not been initialized")
|
39
|
+
return self._chatflow
|
40
|
+
|
30
41
|
@property
|
31
42
|
def completion(self) -> CompletionService:
|
32
43
|
if self._completion is None:
|
@@ -57,6 +68,14 @@ class Client:
|
|
57
68
|
resp = Transport.execute(self._config, request)
|
58
69
|
return resp
|
59
70
|
|
71
|
+
def close(self):
|
72
|
+
"""Close all HTTP connections and clean up resources."""
|
73
|
+
connection_pool.close_all()
|
74
|
+
|
75
|
+
async def aclose(self):
|
76
|
+
"""Async version of close for proper cleanup of async connections."""
|
77
|
+
await connection_pool.aclose_all()
|
78
|
+
|
60
79
|
@staticmethod
|
61
80
|
def builder() -> ClientBuilder:
|
62
81
|
return ClientBuilder()
|
@@ -78,6 +97,31 @@ class ClientBuilder:
|
|
78
97
|
self._config.max_retry_count = count
|
79
98
|
return self
|
80
99
|
|
100
|
+
def max_keepalive_connections(self, count: int) -> ClientBuilder:
|
101
|
+
"""Set maximum keepalive connections per connection pool."""
|
102
|
+
self._config.max_keepalive_connections = count
|
103
|
+
return self
|
104
|
+
|
105
|
+
def max_connections(self, count: int) -> ClientBuilder:
|
106
|
+
"""Set maximum total connections per connection pool."""
|
107
|
+
self._config.max_connections = count
|
108
|
+
return self
|
109
|
+
|
110
|
+
def keepalive_expiry(self, seconds: float) -> ClientBuilder:
|
111
|
+
"""Set keepalive connection expiry time in seconds."""
|
112
|
+
self._config.keepalive_expiry = seconds
|
113
|
+
return self
|
114
|
+
|
115
|
+
def timeout(self, seconds: float) -> ClientBuilder:
|
116
|
+
"""Set client timeout in seconds."""
|
117
|
+
self._config.timeout = seconds
|
118
|
+
return self
|
119
|
+
|
120
|
+
def verify_ssl(self, verify: ssl.SSLContext | str | bool) -> ClientBuilder:
|
121
|
+
"""Set SSL certificate verification."""
|
122
|
+
self._config.verify_ssl = verify
|
123
|
+
return self
|
124
|
+
|
81
125
|
def build(self) -> Client:
|
82
126
|
client: Client = Client()
|
83
127
|
client._config = self._config
|
@@ -87,6 +131,7 @@ class ClientBuilder:
|
|
87
131
|
|
88
132
|
# Initialize services
|
89
133
|
client._chat = ChatService(self._config)
|
134
|
+
client._chatflow = ChatflowService(self._config)
|
90
135
|
client._completion = CompletionService(self._config)
|
91
136
|
client._dify = DifyService(self._config)
|
92
137
|
client._workflow = WorkflowService(self._config)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
from .async_transport import ATransport
|
2
|
+
from .connection_pool import ConnectionPoolManager, connection_pool
|
2
3
|
from .sync_transport import Transport
|
3
4
|
|
4
|
-
__all__ = ["Transport", "ATransport"]
|
5
|
+
__all__ = ["Transport", "ATransport", "ConnectionPoolManager", "connection_pool"]
|