dify-oapi2 0.4.0__py3-none-any.whl → 1.0.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/{completion/v1/model/info → chat/v1/model}/app_info.py +6 -14
- dify_oapi/api/chat/v1/model/app_parameters.py +494 -0
- 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 +13 -2
- dify_oapi/api/chat/v1/model/chat_types.py +65 -0
- dify_oapi/api/chat/v1/model/configure_annotation_reply_request.py +37 -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 +30 -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/{completion/v1/model/feedback → chat/v1/model}/feedback_info.py +29 -7
- dify_oapi/api/{completion/v1/model/file → chat/v1/model}/file_info.py +6 -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_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_conversations_request.py +49 -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/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 +34 -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/{completion/v1/model/file → chat/v1/model}/upload_file_request_body.py +9 -3
- dify_oapi/api/chat/v1/model/usage_info.py +84 -0
- dify_oapi/api/chat/v1/resource/__init__.py +1 -4
- dify_oapi/api/chat/v1/resource/annotation.py +87 -0
- dify_oapi/api/chat/v1/resource/chat.py +47 -25
- dify_oapi/api/chat/v1/resource/conversation.py +45 -33
- dify_oapi/api/chat/v1/resource/message.py +22 -20
- dify_oapi/api/chat/v1/version.py +18 -5
- dify_oapi/api/chatflow/__init__.py +0 -0
- dify_oapi/api/chatflow/service.py +8 -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/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_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_suggested_questions_request.py +32 -0
- dify_oapi/api/{completion/v1/model/feedback/message_feedback_response.py → chatflow/v1/model/get_suggested_questions_response.py} +2 -3
- 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/{dify/v1/model/message_feedback_response.py → chatflow/v1/model/stop_chat_message_response.py} +1 -1
- 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/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 +87 -0
- dify_oapi/api/chatflow/v1/resource/chatflow.py +78 -0
- dify_oapi/api/chatflow/v1/resource/conversation.py +75 -0
- dify_oapi/api/chatflow/v1/version.py +22 -0
- dify_oapi/api/completion/v1/resource/__init__.py +0 -6
- dify_oapi/api/completion/v1/version.py +8 -6
- dify_oapi/api/{chat → dify}/v1/model/audio_to_text_request_body.py +2 -2
- dify_oapi/api/{completion/v1/model/feedback → dify/v1/model}/get_feedbacks_request.py +12 -12
- dify_oapi/api/dify/v1/model/get_feedbacks_response.py +26 -0
- dify_oapi/api/{workflow → dify}/v1/model/get_parameters_request.py +4 -0
- dify_oapi/api/dify/v1/model/{get_parameter_response.py → get_parameters_response.py} +6 -2
- dify_oapi/api/dify/v1/model/get_site_response.py +17 -0
- dify_oapi/api/dify/v1/model/submit_feedback_request.py +34 -0
- dify_oapi/api/dify/v1/model/submit_feedback_request_body.py +35 -0
- dify_oapi/api/dify/v1/model/submit_feedback_response.py +7 -0
- dify_oapi/api/dify/v1/resource/__init__.py +0 -6
- dify_oapi/api/dify/v1/resource/audio.py +12 -0
- dify_oapi/api/dify/v1/resource/feedback.py +31 -0
- dify_oapi/api/dify/v1/resource/info.py +34 -2
- dify_oapi/api/dify/v1/version.py +5 -4
- dify_oapi/api/knowledge/service.py +3 -3
- dify_oapi/api/knowledge/v1/model/create_document_by_file_request.py +1 -3
- dify_oapi/api/knowledge/v1/model/create_document_by_file_request_body.py +4 -46
- dify_oapi/api/knowledge/v1/model/create_document_by_file_request_body_data.py +73 -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/process_rule.py +0 -6
- dify_oapi/api/knowledge/v1/model/retrieval_model.py +10 -4
- dify_oapi/api/knowledge/v1/model/update_document_by_file_request.py +1 -3
- dify_oapi/api/knowledge/v1/model/update_document_by_file_request_body.py +4 -41
- dify_oapi/api/knowledge/v1/model/update_document_by_file_request_body_data.py +68 -0
- dify_oapi/api/knowledge/v1/model/weights.py +27 -0
- dify_oapi/api/knowledge/v1/resource/__init__.py +0 -8
- 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/api/workflow/v1/resource/workflow.py +0 -34
- dify_oapi/api/workflow/v1/version.py +9 -0
- dify_oapi/client.py +49 -4
- 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-1.0.0.dist-info/METADATA +365 -0
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-1.0.0.dist-info}/RECORD +174 -98
- 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_oapi/api/chat/v1/resource/audio.py +0 -17
- dify_oapi/api/completion/v1/model/audio/audio_info.py +0 -28
- dify_oapi/api/completion/v1/model/audio/text_to_audio_request.py +0 -32
- dify_oapi/api/completion/v1/model/audio/text_to_audio_request_body.py +0 -33
- dify_oapi/api/completion/v1/model/audio/text_to_audio_response.py +0 -9
- dify_oapi/api/completion/v1/model/feedback/get_feedbacks_response.py +0 -9
- dify_oapi/api/completion/v1/model/feedback/message_feedback_request.py +0 -38
- dify_oapi/api/completion/v1/model/feedback/message_feedback_request_body.py +0 -35
- dify_oapi/api/completion/v1/model/file/upload_file_request.py +0 -42
- dify_oapi/api/completion/v1/model/file/upload_file_response.py +0 -9
- dify_oapi/api/completion/v1/model/info/feature_config.py +0 -91
- dify_oapi/api/completion/v1/model/info/file_upload_config.py +0 -23
- dify_oapi/api/completion/v1/model/info/get_info_request.py +0 -24
- dify_oapi/api/completion/v1/model/info/get_info_response.py +0 -9
- dify_oapi/api/completion/v1/model/info/get_parameters_request.py +0 -24
- dify_oapi/api/completion/v1/model/info/get_parameters_response.py +0 -9
- dify_oapi/api/completion/v1/model/info/get_site_response.py +0 -9
- dify_oapi/api/completion/v1/model/info/parameters_info.py +0 -75
- dify_oapi/api/completion/v1/model/info/site_info.py +0 -90
- dify_oapi/api/completion/v1/model/info/system_parameters.py +0 -38
- dify_oapi/api/completion/v1/model/info/user_input_form.py +0 -158
- dify_oapi/api/completion/v1/resource/audio.py +0 -19
- dify_oapi/api/completion/v1/resource/feedback.py +0 -33
- dify_oapi/api/completion/v1/resource/file.py +0 -19
- dify_oapi/api/completion/v1/resource/info.py +0 -39
- dify_oapi/api/dify/v1/model/get_parameter_request.py +0 -30
- dify_oapi/api/dify/v1/model/message_feedback_request.py +0 -38
- dify_oapi/api/dify/v1/model/message_feedback_request_body.py +0 -30
- dify_oapi/api/dify/v1/resource/message.py +0 -21
- dify_oapi/api/dify/v1/resource/meta.py +0 -17
- dify_oapi/api/dify/v1/resource/parameter.py +0 -19
- dify_oapi/api/workflow/v1/model/get_info_request.py +0 -24
- dify_oapi/api/workflow/v1/model/get_info_response.py +0 -9
- dify_oapi/api/workflow/v1/model/get_parameters_response.py +0 -9
- dify_oapi/api/workflow/v1/model/get_site_request.py +0 -24
- dify_oapi/api/workflow/v1/model/get_site_response.py +0 -9
- dify_oapi/api/workflow/v1/model/upload_file_request.py +0 -42
- dify_oapi/api/workflow/v1/model/upload_file_response.py +0 -9
- dify_oapi2-0.4.0.dist-info/METADATA +0 -303
- /dify_oapi/api/{chat → dify}/v1/model/audio_to_text_request.py +0 -0
- /dify_oapi/api/{chat → dify}/v1/model/audio_to_text_response.py +0 -0
- /dify_oapi/api/{completion/v1/model/info → dify/v1/model}/get_site_request.py +0 -0
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-1.0.0.dist-info}/LICENSE +0 -0
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-1.0.0.dist-info}/WHEEL +0 -0
@@ -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}$"
|
@@ -5,12 +5,6 @@ from dify_oapi.core.http.transport import ATransport, Transport
|
|
5
5
|
from dify_oapi.core.model.config import Config
|
6
6
|
from dify_oapi.core.model.request_option import RequestOption
|
7
7
|
|
8
|
-
from ..model.get_info_request import GetInfoRequest
|
9
|
-
from ..model.get_info_response import GetInfoResponse
|
10
|
-
from ..model.get_parameters_request import GetParametersRequest
|
11
|
-
from ..model.get_parameters_response import GetParametersResponse
|
12
|
-
from ..model.get_site_request import GetSiteRequest
|
13
|
-
from ..model.get_site_response import GetSiteResponse
|
14
8
|
from ..model.get_workflow_logs_request import GetWorkflowLogsRequest
|
15
9
|
from ..model.get_workflow_logs_response import GetWorkflowLogsResponse
|
16
10
|
from ..model.get_workflow_run_detail_request import GetWorkflowRunDetailRequest
|
@@ -19,8 +13,6 @@ from ..model.run_workflow_request import RunWorkflowRequest
|
|
19
13
|
from ..model.run_workflow_response import RunWorkflowResponse
|
20
14
|
from ..model.stop_workflow_request import StopWorkflowRequest
|
21
15
|
from ..model.stop_workflow_response import StopWorkflowResponse
|
22
|
-
from ..model.upload_file_request import UploadFileRequest
|
23
|
-
from ..model.upload_file_response import UploadFileResponse
|
24
16
|
|
25
17
|
|
26
18
|
class Workflow:
|
@@ -97,12 +89,6 @@ class Workflow:
|
|
97
89
|
async def astop(self, request: StopWorkflowRequest, request_option: RequestOption) -> StopWorkflowResponse:
|
98
90
|
return await ATransport.aexecute(self.config, request, unmarshal_as=StopWorkflowResponse, option=request_option)
|
99
91
|
|
100
|
-
def upload(self, request: UploadFileRequest, request_option: RequestOption) -> UploadFileResponse:
|
101
|
-
return Transport.execute(self.config, request, unmarshal_as=UploadFileResponse, option=request_option)
|
102
|
-
|
103
|
-
async def aupload(self, request: UploadFileRequest, request_option: RequestOption) -> UploadFileResponse:
|
104
|
-
return await ATransport.aexecute(self.config, request, unmarshal_as=UploadFileResponse, option=request_option)
|
105
|
-
|
106
92
|
def logs(self, request: GetWorkflowLogsRequest, request_option: RequestOption) -> GetWorkflowLogsResponse:
|
107
93
|
return Transport.execute(self.config, request, unmarshal_as=GetWorkflowLogsResponse, option=request_option)
|
108
94
|
|
@@ -110,23 +96,3 @@ class Workflow:
|
|
110
96
|
return await ATransport.aexecute(
|
111
97
|
self.config, request, unmarshal_as=GetWorkflowLogsResponse, option=request_option
|
112
98
|
)
|
113
|
-
|
114
|
-
def info(self, request: GetInfoRequest, request_option: RequestOption) -> GetInfoResponse:
|
115
|
-
return Transport.execute(self.config, request, unmarshal_as=GetInfoResponse, option=request_option)
|
116
|
-
|
117
|
-
async def ainfo(self, request: GetInfoRequest, request_option: RequestOption) -> GetInfoResponse:
|
118
|
-
return await ATransport.aexecute(self.config, request, unmarshal_as=GetInfoResponse, option=request_option)
|
119
|
-
|
120
|
-
def parameters(self, request: GetParametersRequest, request_option: RequestOption) -> GetParametersResponse:
|
121
|
-
return Transport.execute(self.config, request, unmarshal_as=GetParametersResponse, option=request_option)
|
122
|
-
|
123
|
-
async def aparameters(self, request: GetParametersRequest, request_option: RequestOption) -> GetParametersResponse:
|
124
|
-
return await ATransport.aexecute(
|
125
|
-
self.config, request, unmarshal_as=GetParametersResponse, option=request_option
|
126
|
-
)
|
127
|
-
|
128
|
-
def site(self, request: GetSiteRequest, request_option: RequestOption) -> GetSiteResponse:
|
129
|
-
return Transport.execute(self.config, request, unmarshal_as=GetSiteResponse, option=request_option)
|
130
|
-
|
131
|
-
async def asite(self, request: GetSiteRequest, request_option: RequestOption) -> GetSiteResponse:
|
132
|
-
return await ATransport.aexecute(self.config, request, unmarshal_as=GetSiteResponse, option=request_option)
|
@@ -1,3 +1,7 @@
|
|
1
|
+
from dify_oapi.api.dify.v1.resource.audio import Audio
|
2
|
+
from dify_oapi.api.dify.v1.resource.feedback import Feedback
|
3
|
+
from dify_oapi.api.dify.v1.resource.file import File
|
4
|
+
from dify_oapi.api.dify.v1.resource.info import Info
|
1
5
|
from dify_oapi.core.model.config import Config
|
2
6
|
|
3
7
|
from .resource.workflow import Workflow
|
@@ -6,3 +10,8 @@ from .resource.workflow import Workflow
|
|
6
10
|
class V1:
|
7
11
|
def __init__(self, config: Config):
|
8
12
|
self.workflow = Workflow(config)
|
13
|
+
# System APIs - delegate to dify module
|
14
|
+
self.file = File(config)
|
15
|
+
self.audio = Audio(config)
|
16
|
+
self.info = Info(config)
|
17
|
+
self.feedback = Feedback(config)
|
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
|
-
from .api.knowledge.service import
|
9
|
+
from .api.knowledge.service import KnowledgeService
|
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,10 +20,11 @@ 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
|
22
|
-
self._knowledge:
|
27
|
+
self._knowledge: KnowledgeService | None = None
|
23
28
|
|
24
29
|
@property
|
25
30
|
def chat(self) -> ChatService:
|
@@ -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:
|
@@ -46,7 +57,7 @@ class Client:
|
|
46
57
|
return self._workflow
|
47
58
|
|
48
59
|
@property
|
49
|
-
def knowledge(self) ->
|
60
|
+
def knowledge(self) -> KnowledgeService:
|
50
61
|
if self._knowledge is None:
|
51
62
|
raise RuntimeError("Knowledge base service has not been initialized")
|
52
63
|
return self._knowledge
|
@@ -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,10 +131,11 @@ 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)
|
93
|
-
client._knowledge =
|
138
|
+
client._knowledge = KnowledgeService(self._config)
|
94
139
|
return client
|
95
140
|
|
96
141
|
def _init_logger(self):
|
@@ -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"]
|