dify-oapi2 0.1.1__py3-none-any.whl → 0.3.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.
Files changed (140) hide show
  1. dify_oapi/api/completion/v1/model/annotation/annotation_info.py +43 -0
  2. dify_oapi/api/completion/v1/model/annotation/annotation_reply_settings_request.py +39 -0
  3. dify_oapi/api/completion/v1/model/annotation/annotation_reply_settings_request_body.py +33 -0
  4. dify_oapi/api/completion/v1/model/annotation/annotation_reply_settings_response.py +9 -0
  5. dify_oapi/api/completion/v1/model/annotation/create_annotation_request.py +32 -0
  6. dify_oapi/api/completion/v1/model/annotation/create_annotation_request_body.py +28 -0
  7. dify_oapi/api/completion/v1/model/annotation/create_annotation_response.py +9 -0
  8. dify_oapi/api/completion/v1/model/annotation/delete_annotation_request.py +30 -0
  9. dify_oapi/api/completion/v1/model/annotation/delete_annotation_response.py +7 -0
  10. dify_oapi/api/completion/v1/model/annotation/job_status_info.py +35 -0
  11. dify_oapi/api/completion/v1/model/annotation/list_annotations_request.py +32 -0
  12. dify_oapi/api/completion/v1/model/annotation/list_annotations_response.py +13 -0
  13. dify_oapi/api/completion/v1/model/annotation/query_annotation_reply_status_request.py +38 -0
  14. dify_oapi/api/completion/v1/model/annotation/query_annotation_reply_status_response.py +9 -0
  15. dify_oapi/api/completion/v1/model/annotation/update_annotation_request.py +38 -0
  16. dify_oapi/api/completion/v1/model/annotation/update_annotation_request_body.py +28 -0
  17. dify_oapi/api/completion/v1/model/annotation/update_annotation_response.py +9 -0
  18. dify_oapi/api/completion/v1/model/audio/audio_info.py +28 -0
  19. dify_oapi/api/completion/v1/model/audio/text_to_audio_request.py +32 -0
  20. dify_oapi/api/completion/v1/model/audio/text_to_audio_request_body.py +33 -0
  21. dify_oapi/api/completion/v1/model/audio/text_to_audio_response.py +9 -0
  22. dify_oapi/api/completion/v1/model/completion/completion_inputs.py +28 -0
  23. dify_oapi/api/completion/v1/model/completion/completion_message_info.py +46 -0
  24. dify_oapi/api/completion/v1/model/completion/completion_types.py +27 -0
  25. dify_oapi/api/completion/v1/model/completion/metadata.py +31 -0
  26. dify_oapi/api/completion/v1/model/completion/retriever_resource.py +58 -0
  27. dify_oapi/api/completion/v1/model/completion/send_message_request.py +32 -0
  28. dify_oapi/api/completion/v1/model/completion/send_message_request_body.py +76 -0
  29. dify_oapi/api/completion/v1/model/completion/send_message_response.py +9 -0
  30. dify_oapi/api/completion/v1/model/completion/stop_response_request.py +38 -0
  31. dify_oapi/api/completion/v1/model/completion/stop_response_request_body.py +23 -0
  32. dify_oapi/api/completion/v1/model/{stop_completion_response.py → completion/stop_response_response.py} +3 -1
  33. dify_oapi/api/completion/v1/model/completion/usage.py +78 -0
  34. dify_oapi/api/completion/v1/model/feedback/feedback_info.py +53 -0
  35. dify_oapi/api/completion/v1/model/feedback/get_feedbacks_request.py +32 -0
  36. dify_oapi/api/completion/v1/model/feedback/get_feedbacks_response.py +9 -0
  37. dify_oapi/api/completion/v1/model/feedback/message_feedback_request.py +38 -0
  38. dify_oapi/api/completion/v1/model/feedback/message_feedback_request_body.py +35 -0
  39. dify_oapi/api/completion/v1/model/feedback/message_feedback_response.py +7 -0
  40. dify_oapi/api/completion/v1/model/file/file_info.py +53 -0
  41. dify_oapi/api/completion/v1/model/file/upload_file_request.py +42 -0
  42. dify_oapi/api/completion/v1/model/file/upload_file_request_body.py +23 -0
  43. dify_oapi/api/completion/v1/model/file/upload_file_response.py +9 -0
  44. dify_oapi/api/completion/v1/model/info/app_info.py +43 -0
  45. dify_oapi/api/completion/v1/model/info/file_upload_config.py +23 -0
  46. dify_oapi/api/completion/v1/model/info/get_info_request.py +24 -0
  47. dify_oapi/api/completion/v1/model/info/get_info_response.py +9 -0
  48. dify_oapi/api/completion/v1/model/info/get_parameters_request.py +24 -0
  49. dify_oapi/api/completion/v1/model/info/get_parameters_response.py +9 -0
  50. dify_oapi/api/completion/v1/model/info/get_site_request.py +24 -0
  51. dify_oapi/api/completion/v1/model/info/get_site_response.py +9 -0
  52. dify_oapi/api/completion/v1/model/info/parameters_info.py +67 -0
  53. dify_oapi/api/completion/v1/model/info/site_info.py +90 -0
  54. dify_oapi/api/completion/v1/model/info/system_parameters.py +38 -0
  55. dify_oapi/api/completion/v1/model/info/user_input_form.py +43 -0
  56. dify_oapi/api/completion/v1/resource/__init__.py +5 -0
  57. dify_oapi/api/completion/v1/resource/annotation.py +99 -0
  58. dify_oapi/api/completion/v1/resource/audio.py +19 -0
  59. dify_oapi/api/completion/v1/resource/completion.py +36 -46
  60. dify_oapi/api/completion/v1/resource/feedback.py +33 -0
  61. dify_oapi/api/completion/v1/resource/file.py +19 -0
  62. dify_oapi/api/completion/v1/resource/info.py +39 -0
  63. dify_oapi/api/completion/v1/version.py +11 -1
  64. dify_oapi/api/knowledge_base/v1/model/dataset/create_request_body.py +3 -4
  65. dify_oapi/api/knowledge_base/v1/model/dataset/dataset_types.py +36 -0
  66. dify_oapi/api/knowledge_base/v1/model/dataset/retrieval_model.py +3 -6
  67. dify_oapi/api/knowledge_base/v1/model/document/create_by_text_request_body.py +7 -12
  68. dify_oapi/api/knowledge_base/v1/model/document/document_types.py +36 -0
  69. dify_oapi/api/knowledge_base/v1/model/metadata/metadata_types.py +15 -0
  70. dify_oapi/api/knowledge_base/v1/model/segment/segment_types.py +24 -0
  71. dify_oapi/api/knowledge_base/v1/model/tag/tag_types.py +12 -0
  72. dify_oapi/api/knowledge_base/v1/model/tag/update_response.py +5 -1
  73. dify_oapi/api/workflow/v1/model/file/__init__.py +1 -0
  74. dify_oapi/api/workflow/v1/model/file/file_info.py +53 -0
  75. dify_oapi/api/workflow/v1/model/file/preview_file_request.py +34 -0
  76. dify_oapi/api/workflow/v1/model/file/preview_file_response.py +9 -0
  77. dify_oapi/api/workflow/v1/model/file/upload_file_request.py +42 -0
  78. dify_oapi/api/workflow/v1/model/file/upload_file_request_body.py +23 -0
  79. dify_oapi/api/workflow/v1/model/file/upload_file_response.py +9 -0
  80. dify_oapi/api/workflow/v1/model/info/app_info.py +45 -0
  81. dify_oapi/api/workflow/v1/model/info/file_upload_config.py +45 -0
  82. dify_oapi/api/workflow/v1/model/info/get_info_request.py +24 -0
  83. dify_oapi/api/workflow/v1/model/info/get_info_response.py +9 -0
  84. dify_oapi/api/workflow/v1/model/info/get_parameters_request.py +24 -0
  85. dify_oapi/api/workflow/v1/model/info/get_parameters_response.py +9 -0
  86. dify_oapi/api/workflow/v1/model/info/get_site_request.py +24 -0
  87. dify_oapi/api/workflow/v1/model/info/get_site_response.py +9 -0
  88. dify_oapi/api/workflow/v1/model/info/parameters_info.py +37 -0
  89. dify_oapi/api/workflow/v1/model/info/site_info.py +75 -0
  90. dify_oapi/api/workflow/v1/model/info/system_parameters.py +38 -0
  91. dify_oapi/api/workflow/v1/model/info/user_input_form.py +43 -0
  92. dify_oapi/api/workflow/v1/model/log/__init__.py +0 -0
  93. dify_oapi/api/workflow/v1/model/log/end_user_info.py +38 -0
  94. dify_oapi/api/workflow/v1/model/log/get_workflow_logs_request.py +48 -0
  95. dify_oapi/api/workflow/v1/model/log/get_workflow_logs_response.py +13 -0
  96. dify_oapi/api/workflow/v1/model/log/log_info.py +57 -0
  97. dify_oapi/api/workflow/v1/model/log/workflow_run_log_info.py +65 -0
  98. dify_oapi/api/workflow/v1/model/workflow/execution_metadata.py +33 -0
  99. dify_oapi/api/workflow/v1/model/workflow/get_workflow_run_detail_request.py +30 -0
  100. dify_oapi/api/workflow/v1/model/{run_workflow_response.py → workflow/get_workflow_run_detail_response.py} +8 -11
  101. dify_oapi/api/workflow/v1/model/workflow/node_info.py +88 -0
  102. dify_oapi/api/workflow/v1/model/workflow/run_specific_workflow_request.py +38 -0
  103. dify_oapi/api/workflow/v1/model/workflow/run_specific_workflow_request_body.py +47 -0
  104. dify_oapi/api/workflow/v1/model/workflow/run_specific_workflow_response.py +9 -0
  105. dify_oapi/api/workflow/v1/model/{run_workflow_request.py → workflow/run_workflow_request.py} +4 -4
  106. dify_oapi/api/workflow/v1/model/workflow/run_workflow_request_body.py +47 -0
  107. dify_oapi/api/workflow/v1/model/workflow/run_workflow_response.py +9 -0
  108. dify_oapi/api/workflow/v1/model/{stop_workflow_request.py → workflow/stop_workflow_request.py} +9 -9
  109. dify_oapi/api/workflow/v1/model/{stop_workflow_request_body.py → workflow/stop_workflow_request_body.py} +3 -3
  110. dify_oapi/api/workflow/v1/model/{stop_workflow_response.py → workflow/stop_workflow_response.py} +2 -0
  111. dify_oapi/api/workflow/v1/model/workflow/streaming_event.py +42 -0
  112. dify_oapi/api/workflow/v1/model/workflow/workflow_file_info.py +40 -0
  113. dify_oapi/api/workflow/v1/model/workflow/workflow_inputs.py +56 -0
  114. dify_oapi/api/workflow/v1/model/workflow/workflow_run_data.py +72 -0
  115. dify_oapi/api/workflow/v1/model/workflow/workflow_run_info.py +35 -0
  116. dify_oapi/api/workflow/v1/model/workflow/workflow_types.py +54 -0
  117. dify_oapi/api/workflow/v1/resource/__init__.py +0 -1
  118. dify_oapi/api/workflow/v1/resource/file.py +63 -0
  119. dify_oapi/api/workflow/v1/resource/info.py +93 -0
  120. dify_oapi/api/workflow/v1/resource/log.py +43 -0
  121. dify_oapi/api/workflow/v1/resource/workflow.py +171 -53
  122. dify_oapi/api/workflow/v1/version.py +7 -1
  123. dify_oapi/core/http/transport/_misc.py +54 -14
  124. {dify_oapi2-0.1.1.dist-info → dify_oapi2-0.3.0.dist-info}/METADATA +10 -6
  125. {dify_oapi2-0.1.1.dist-info → dify_oapi2-0.3.0.dist-info}/RECORD +127 -34
  126. dify_oapi/api/completion/v1/model/completion_request.py +0 -34
  127. dify_oapi/api/completion/v1/model/completion_request_body.py +0 -43
  128. dify_oapi/api/completion/v1/model/completion_request_body_input.py +0 -38
  129. dify_oapi/api/completion/v1/model/completion_request_file.py +0 -49
  130. dify_oapi/api/completion/v1/model/completion_response.py +0 -18
  131. dify_oapi/api/completion/v1/model/stop_completion_request.py +0 -38
  132. dify_oapi/api/completion/v1/model/stop_completion_request_body.py +0 -23
  133. dify_oapi/api/workflow/v1/model/get_workflow_log_request.py +0 -50
  134. dify_oapi/api/workflow/v1/model/get_workflow_log_response.py +0 -42
  135. dify_oapi/api/workflow/v1/model/get_workflow_result_request.py +0 -30
  136. dify_oapi/api/workflow/v1/model/get_workflow_result_response.py +0 -17
  137. dify_oapi/api/workflow/v1/model/run_workflow_request_body.py +0 -42
  138. dify_oapi/api/workflow/v1/model/run_workflow_request_file.py +0 -50
  139. {dify_oapi2-0.1.1.dist-info → dify_oapi2-0.3.0.dist-info}/LICENSE +0 -0
  140. {dify_oapi2-0.1.1.dist-info → dify_oapi2-0.3.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,93 @@
1
+ from __future__ import annotations
2
+
3
+ from dify_oapi.core.http.transport import ATransport, Transport
4
+ from dify_oapi.core.model.config import Config
5
+ from dify_oapi.core.model.request_option import RequestOption
6
+
7
+ from ..model.info.get_info_request import GetInfoRequest
8
+ from ..model.info.get_info_response import GetInfoResponse
9
+ from ..model.info.get_parameters_request import GetParametersRequest
10
+ from ..model.info.get_parameters_response import GetParametersResponse
11
+ from ..model.info.get_site_request import GetSiteRequest
12
+ from ..model.info.get_site_response import GetSiteResponse
13
+
14
+
15
+ class Info:
16
+ def __init__(self, config: Config) -> None:
17
+ self.config = config
18
+
19
+ def get_info(self, request: GetInfoRequest, request_option: RequestOption) -> GetInfoResponse:
20
+ """Get application basic information.
21
+
22
+ Args:
23
+ request: The get info request
24
+ request_option: Request options including API key
25
+
26
+ Returns:
27
+ GetInfoResponse with application information
28
+ """
29
+ return Transport.execute(self.config, request, unmarshal_as=GetInfoResponse, option=request_option)
30
+
31
+ async def aget_info(self, request: GetInfoRequest, request_option: RequestOption) -> GetInfoResponse:
32
+ """Get application basic information asynchronously.
33
+
34
+ Args:
35
+ request: The get info request
36
+ request_option: Request options including API key
37
+
38
+ Returns:
39
+ GetInfoResponse with application information
40
+ """
41
+ return await ATransport.aexecute(self.config, request, unmarshal_as=GetInfoResponse, option=request_option)
42
+
43
+ def get_parameters(self, request: GetParametersRequest, request_option: RequestOption) -> GetParametersResponse:
44
+ """Get application parameters.
45
+
46
+ Args:
47
+ request: The get parameters request
48
+ request_option: Request options including API key
49
+
50
+ Returns:
51
+ GetParametersResponse with application parameters
52
+ """
53
+ return Transport.execute(self.config, request, unmarshal_as=GetParametersResponse, option=request_option)
54
+
55
+ async def aget_parameters(
56
+ self, request: GetParametersRequest, request_option: RequestOption
57
+ ) -> GetParametersResponse:
58
+ """Get application parameters asynchronously.
59
+
60
+ Args:
61
+ request: The get parameters request
62
+ request_option: Request options including API key
63
+
64
+ Returns:
65
+ GetParametersResponse with application parameters
66
+ """
67
+ return await ATransport.aexecute(
68
+ self.config, request, unmarshal_as=GetParametersResponse, option=request_option
69
+ )
70
+
71
+ def get_site(self, request: GetSiteRequest, request_option: RequestOption) -> GetSiteResponse:
72
+ """Get WebApp settings.
73
+
74
+ Args:
75
+ request: The get site request
76
+ request_option: Request options including API key
77
+
78
+ Returns:
79
+ GetSiteResponse with WebApp settings
80
+ """
81
+ return Transport.execute(self.config, request, unmarshal_as=GetSiteResponse, option=request_option)
82
+
83
+ async def aget_site(self, request: GetSiteRequest, request_option: RequestOption) -> GetSiteResponse:
84
+ """Get WebApp settings asynchronously.
85
+
86
+ Args:
87
+ request: The get site request
88
+ request_option: Request options including API key
89
+
90
+ Returns:
91
+ GetSiteResponse with WebApp settings
92
+ """
93
+ return await ATransport.aexecute(self.config, request, unmarshal_as=GetSiteResponse, option=request_option)
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ from dify_oapi.core.http.transport import ATransport, Transport
4
+ from dify_oapi.core.model.config import Config
5
+ from dify_oapi.core.model.request_option import RequestOption
6
+
7
+ from ..model.log.get_workflow_logs_request import GetWorkflowLogsRequest
8
+ from ..model.log.get_workflow_logs_response import GetWorkflowLogsResponse
9
+
10
+
11
+ class Log:
12
+ def __init__(self, config: Config) -> None:
13
+ self.config = config
14
+
15
+ def get_workflow_logs(
16
+ self, request: GetWorkflowLogsRequest, request_option: RequestOption
17
+ ) -> GetWorkflowLogsResponse:
18
+ """Get workflow execution logs.
19
+
20
+ Args:
21
+ request: The get workflow logs request
22
+ request_option: Request options including API key
23
+
24
+ Returns:
25
+ GetWorkflowLogsResponse with workflow logs
26
+ """
27
+ return Transport.execute(self.config, request, unmarshal_as=GetWorkflowLogsResponse, option=request_option)
28
+
29
+ async def aget_workflow_logs(
30
+ self, request: GetWorkflowLogsRequest, request_option: RequestOption
31
+ ) -> GetWorkflowLogsResponse:
32
+ """Get workflow execution logs asynchronously.
33
+
34
+ Args:
35
+ request: The get workflow logs request
36
+ request_option: Request options including API key
37
+
38
+ Returns:
39
+ GetWorkflowLogsResponse with workflow logs
40
+ """
41
+ return await ATransport.aexecute(
42
+ self.config, request, unmarshal_as=GetWorkflowLogsResponse, option=request_option
43
+ )
@@ -5,98 +5,216 @@ 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_workflow_log_request import GetWorkflowLogRequest
9
- from ..model.get_workflow_log_response import GetWorkflowLogResponse
10
- from ..model.get_workflow_result_request import GetWorkflowResultRequest
11
- from ..model.get_workflow_result_response import GetWorkflowResultResponse
12
- from ..model.run_workflow_request import RunWorkflowRequest
13
- from ..model.run_workflow_response import RunWorkflowResponse
14
- from ..model.stop_workflow_request import StopWorkflowRequest
15
- from ..model.stop_workflow_response import StopWorkflowResponse
8
+ from ..model.workflow.get_workflow_run_detail_request import GetWorkflowRunDetailRequest
9
+ from ..model.workflow.get_workflow_run_detail_response import GetWorkflowRunDetailResponse
10
+ from ..model.workflow.run_specific_workflow_request import RunSpecificWorkflowRequest
11
+ from ..model.workflow.run_specific_workflow_response import RunSpecificWorkflowResponse
12
+ from ..model.workflow.run_workflow_request import RunWorkflowRequest
13
+ from ..model.workflow.run_workflow_response import RunWorkflowResponse
14
+ from ..model.workflow.stop_workflow_request import StopWorkflowRequest
15
+ from ..model.workflow.stop_workflow_response import StopWorkflowResponse
16
16
 
17
17
 
18
18
  class Workflow:
19
19
  def __init__(self, config: Config) -> None:
20
- self.config: Config = config
20
+ self.config = config
21
21
 
22
22
  @overload
23
- def run(
23
+ def run_workflow(
24
24
  self,
25
25
  request: RunWorkflowRequest,
26
- option: RequestOption | None,
26
+ request_option: RequestOption,
27
27
  stream: Literal[True],
28
28
  ) -> Generator[bytes, None, None]: ...
29
29
 
30
30
  @overload
31
- def run(
31
+ def run_workflow(
32
32
  self,
33
33
  request: RunWorkflowRequest,
34
- option: RequestOption | None,
35
- stream: Literal[False],
34
+ request_option: RequestOption,
35
+ stream: Literal[False] = False,
36
36
  ) -> RunWorkflowResponse: ...
37
37
 
38
- @overload
39
- def run(self, request: RunWorkflowRequest, option: RequestOption | None) -> RunWorkflowResponse: ...
40
-
41
- def run(
38
+ def run_workflow(
42
39
  self,
43
40
  request: RunWorkflowRequest,
44
- option: RequestOption | None = None,
41
+ request_option: RequestOption,
45
42
  stream: bool = False,
46
- ):
43
+ ) -> RunWorkflowResponse | Generator[bytes, None, None]:
44
+ """Execute workflow.
45
+
46
+ Args:
47
+ request: The run workflow request
48
+ request_option: Request options including API key
49
+ stream: Whether to use streaming mode
50
+
51
+ Returns:
52
+ RunWorkflowResponse for blocking mode or Generator[bytes, None, None] for streaming mode
53
+ """
47
54
  if stream:
48
- return Transport.execute(self.config, request, option=option, stream=True)
49
- else:
50
- return Transport.execute(self.config, request, unmarshal_as=RunWorkflowResponse, option=option)
55
+ return Transport.execute(self.config, request, stream=True, option=request_option)
56
+ return Transport.execute(self.config, request, unmarshal_as=RunWorkflowResponse, option=request_option)
51
57
 
52
58
  @overload
53
- async def arun(
59
+ async def arun_workflow(
54
60
  self,
55
61
  request: RunWorkflowRequest,
56
- option: RequestOption | None,
62
+ request_option: RequestOption,
57
63
  stream: Literal[True],
58
64
  ) -> AsyncGenerator[bytes, None]: ...
59
65
 
60
66
  @overload
61
- async def arun(
67
+ async def arun_workflow(
62
68
  self,
63
69
  request: RunWorkflowRequest,
64
- option: RequestOption | None,
65
- stream: Literal[False],
70
+ request_option: RequestOption,
71
+ stream: Literal[False] = False,
66
72
  ) -> RunWorkflowResponse: ...
67
73
 
68
- @overload
69
- async def arun(self, request: RunWorkflowRequest, option: RequestOption | None) -> RunWorkflowResponse: ...
70
-
71
- async def arun(
74
+ async def arun_workflow(
72
75
  self,
73
76
  request: RunWorkflowRequest,
74
- option: RequestOption | None = None,
77
+ request_option: RequestOption,
75
78
  stream: bool = False,
76
- ):
79
+ ) -> RunWorkflowResponse | AsyncGenerator[bytes, None]:
80
+ """Execute workflow asynchronously.
81
+
82
+ Args:
83
+ request: The run workflow request
84
+ request_option: Request options including API key
85
+ stream: Whether to use streaming mode
86
+
87
+ Returns:
88
+ RunWorkflowResponse for blocking mode or AsyncGenerator[bytes, None] for streaming mode
89
+ """
77
90
  if stream:
78
- return await ATransport.aexecute(self.config, request, option=option, stream=True)
79
- else:
80
- return await ATransport.aexecute(self.config, request, unmarshal_as=RunWorkflowResponse, option=option)
91
+ return await ATransport.aexecute(self.config, request, stream=True, option=request_option)
92
+ return await ATransport.aexecute(self.config, request, unmarshal_as=RunWorkflowResponse, option=request_option)
93
+
94
+ @overload
95
+ def run_specific_workflow(
96
+ self,
97
+ request: RunSpecificWorkflowRequest,
98
+ request_option: RequestOption,
99
+ stream: Literal[True],
100
+ ) -> Generator[bytes, None, None]: ...
101
+
102
+ @overload
103
+ def run_specific_workflow(
104
+ self,
105
+ request: RunSpecificWorkflowRequest,
106
+ request_option: RequestOption,
107
+ stream: Literal[False] = False,
108
+ ) -> RunSpecificWorkflowResponse: ...
81
109
 
82
- def stop(self, request: StopWorkflowRequest, option: RequestOption | None = None) -> StopWorkflowResponse:
83
- return Transport.execute(self.config, request, unmarshal_as=StopWorkflowResponse, option=option)
110
+ def run_specific_workflow(
111
+ self,
112
+ request: RunSpecificWorkflowRequest,
113
+ request_option: RequestOption,
114
+ stream: bool = False,
115
+ ) -> RunSpecificWorkflowResponse | Generator[bytes, None, None]:
116
+ """Execute specific version workflow.
84
117
 
85
- async def astop(self, request: StopWorkflowRequest, option: RequestOption | None = None) -> StopWorkflowResponse:
86
- return await ATransport.aexecute(self.config, request, unmarshal_as=StopWorkflowResponse, option=option)
118
+ Args:
119
+ request: The run specific workflow request
120
+ request_option: Request options including API key
121
+ stream: Whether to use streaming mode
87
122
 
88
- def result(
89
- self, request: GetWorkflowResultRequest, option: RequestOption | None = None
90
- ) -> GetWorkflowResultResponse:
91
- return Transport.execute(self.config, request, unmarshal_as=GetWorkflowResultResponse, option=option)
123
+ Returns:
124
+ RunSpecificWorkflowResponse for blocking mode or Generator[bytes, None, None] for streaming mode
125
+ """
126
+ if stream:
127
+ return Transport.execute(self.config, request, stream=True, option=request_option)
128
+ return Transport.execute(self.config, request, unmarshal_as=RunSpecificWorkflowResponse, option=request_option)
92
129
 
93
- async def aresult(
94
- self, request: GetWorkflowResultRequest, option: RequestOption | None = None
95
- ) -> GetWorkflowResultResponse:
96
- return await ATransport.aexecute(self.config, request, unmarshal_as=GetWorkflowResultResponse, option=option)
130
+ @overload
131
+ async def arun_specific_workflow(
132
+ self,
133
+ request: RunSpecificWorkflowRequest,
134
+ request_option: RequestOption,
135
+ stream: Literal[True],
136
+ ) -> AsyncGenerator[bytes, None]: ...
97
137
 
98
- def log(self, request: GetWorkflowLogRequest, option: RequestOption | None = None) -> GetWorkflowLogResponse:
99
- return Transport.execute(self.config, request, unmarshal_as=GetWorkflowLogResponse, option=option)
138
+ @overload
139
+ async def arun_specific_workflow(
140
+ self,
141
+ request: RunSpecificWorkflowRequest,
142
+ request_option: RequestOption,
143
+ stream: Literal[False] = False,
144
+ ) -> RunSpecificWorkflowResponse: ...
100
145
 
101
- async def alog(self, request: GetWorkflowLogRequest, option: RequestOption | None = None) -> GetWorkflowLogResponse:
102
- return await ATransport.aexecute(self.config, request, unmarshal_as=GetWorkflowLogResponse, option=option)
146
+ async def arun_specific_workflow(
147
+ self,
148
+ request: RunSpecificWorkflowRequest,
149
+ request_option: RequestOption,
150
+ stream: bool = False,
151
+ ) -> RunSpecificWorkflowResponse | AsyncGenerator[bytes, None]:
152
+ """Execute specific version workflow asynchronously.
153
+
154
+ Args:
155
+ request: The run specific workflow request
156
+ request_option: Request options including API key
157
+ stream: Whether to use streaming mode
158
+
159
+ Returns:
160
+ RunSpecificWorkflowResponse for blocking mode or AsyncGenerator[bytes, None] for streaming mode
161
+ """
162
+ if stream:
163
+ return await ATransport.aexecute(self.config, request, stream=True, option=request_option)
164
+ return await ATransport.aexecute(
165
+ self.config, request, unmarshal_as=RunSpecificWorkflowResponse, option=request_option
166
+ )
167
+
168
+ def get_workflow_run_detail(
169
+ self, request: GetWorkflowRunDetailRequest, request_option: RequestOption
170
+ ) -> GetWorkflowRunDetailResponse:
171
+ """Get workflow execution details.
172
+
173
+ Args:
174
+ request: The get workflow run detail request
175
+ request_option: Request options including API key
176
+
177
+ Returns:
178
+ GetWorkflowRunDetailResponse with workflow execution details
179
+ """
180
+ return Transport.execute(self.config, request, unmarshal_as=GetWorkflowRunDetailResponse, option=request_option)
181
+
182
+ async def aget_workflow_run_detail(
183
+ self, request: GetWorkflowRunDetailRequest, request_option: RequestOption
184
+ ) -> GetWorkflowRunDetailResponse:
185
+ """Get workflow execution details asynchronously.
186
+
187
+ Args:
188
+ request: The get workflow run detail request
189
+ request_option: Request options including API key
190
+
191
+ Returns:
192
+ GetWorkflowRunDetailResponse with workflow execution details
193
+ """
194
+ return await ATransport.aexecute(
195
+ self.config, request, unmarshal_as=GetWorkflowRunDetailResponse, option=request_option
196
+ )
197
+
198
+ def stop_workflow(self, request: StopWorkflowRequest, request_option: RequestOption) -> StopWorkflowResponse:
199
+ """Stop workflow execution.
200
+
201
+ Args:
202
+ request: The stop workflow request
203
+ request_option: Request options including API key
204
+
205
+ Returns:
206
+ StopWorkflowResponse with stop result
207
+ """
208
+ return Transport.execute(self.config, request, unmarshal_as=StopWorkflowResponse, option=request_option)
209
+
210
+ async def astop_workflow(self, request: StopWorkflowRequest, request_option: RequestOption) -> StopWorkflowResponse:
211
+ """Stop workflow execution asynchronously.
212
+
213
+ Args:
214
+ request: The stop workflow request
215
+ request_option: Request options including API key
216
+
217
+ Returns:
218
+ StopWorkflowResponse with stop result
219
+ """
220
+ return await ATransport.aexecute(self.config, request, unmarshal_as=StopWorkflowResponse, option=request_option)
@@ -1,8 +1,14 @@
1
1
  from dify_oapi.core.model.config import Config
2
2
 
3
- from .resource import Workflow
3
+ from .resource.file import File
4
+ from .resource.info import Info
5
+ from .resource.log import Log
6
+ from .resource.workflow import Workflow
4
7
 
5
8
 
6
9
  class V1:
7
10
  def __init__(self, config: Config):
8
11
  self.workflow: Workflow = Workflow(config)
12
+ self.file: File = File(config)
13
+ self.log: Log = Log(config)
14
+ self.info: Info = Info(config)
@@ -48,8 +48,15 @@ def _merge_dicts(*dicts: dict | None) -> dict:
48
48
  def _create_no_content_response(unmarshal_as: type[T]) -> T:
49
49
  """Create response for 204 No Content status."""
50
50
  try:
51
- if hasattr(unmarshal_as, "__annotations__") and "result" in unmarshal_as.__annotations__:
52
- return unmarshal_as(result="success")
51
+ # Check if the model has a 'result' field in its annotations
52
+ annotations = getattr(unmarshal_as, "__annotations__", {})
53
+ if "result" in annotations:
54
+ # Only pass result if the specific model supports it
55
+ try:
56
+ return unmarshal_as(result="success") # type: ignore
57
+ except TypeError:
58
+ # Fallback if constructor doesn't accept result
59
+ pass
53
60
  return unmarshal_as()
54
61
  except Exception:
55
62
  resp = unmarshal_as.__new__(unmarshal_as)
@@ -77,23 +84,56 @@ def _handle_json_response(content: str, unmarshal_as: type[T]) -> T:
77
84
 
78
85
  def _handle_array_response(data: list, unmarshal_as: type[T]) -> T:
79
86
  """Handle array JSON responses."""
80
- if hasattr(unmarshal_as, "__annotations__") and "data" in unmarshal_as.__annotations__:
81
- return unmarshal_as(data=data)
82
- return unmarshal_as(data=data)
87
+ try:
88
+ # Check if the model has a 'data' field in its annotations
89
+ annotations = getattr(unmarshal_as, "__annotations__", {})
90
+ if "data" in annotations:
91
+ try:
92
+ return unmarshal_as(data=data) # type: ignore
93
+ except TypeError:
94
+ # Fallback if constructor doesn't accept data
95
+ pass
96
+ return unmarshal_as()
97
+ except Exception:
98
+ resp = unmarshal_as.__new__(unmarshal_as)
99
+ if hasattr(resp, "data"):
100
+ try:
101
+ object.__setattr__(resp, "data", data)
102
+ except Exception:
103
+ pass
104
+ return resp
83
105
 
84
106
 
85
107
  def _handle_primitive_response(value, unmarshal_as: type[T]) -> T:
86
108
  """Handle primitive JSON responses."""
87
- if not hasattr(unmarshal_as, "__annotations__"):
88
- return unmarshal_as()
89
-
90
- annotations = unmarshal_as.__annotations__
91
- if "result" in annotations:
92
- return unmarshal_as(result=str(value))
93
- elif "data" in annotations:
94
- return unmarshal_as(data=value)
95
- else:
109
+ try:
110
+ annotations = getattr(unmarshal_as, "__annotations__", {})
111
+ if "result" in annotations:
112
+ try:
113
+ return unmarshal_as(result=str(value)) # type: ignore
114
+ except TypeError:
115
+ # Fallback if constructor doesn't accept result
116
+ pass
117
+ elif "data" in annotations:
118
+ try:
119
+ return unmarshal_as(data=value) # type: ignore
120
+ except TypeError:
121
+ # Fallback if constructor doesn't accept data
122
+ pass
96
123
  return unmarshal_as()
124
+ except Exception:
125
+ resp = unmarshal_as.__new__(unmarshal_as)
126
+ if hasattr(resp, "result"):
127
+ try:
128
+ object.__setattr__(resp, "result", str(value))
129
+ except Exception:
130
+ pass
131
+ elif hasattr(resp, "data"):
132
+ try:
133
+ object.__setattr__(resp, "data", value)
134
+ except Exception:
135
+ pass
136
+ return resp
97
137
 
98
138
 
99
139
  def _set_raw_response(resp: T, raw_resp: RawResponse) -> T:
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dify-oapi2
3
- Version: 0.1.1
3
+ Version: 0.3.0
4
4
  Summary: A package for interacting with the Dify Service-API
5
5
  License: MIT
6
6
  Keywords: dify,nlp,ai,language-processing
7
7
  Author: Oscaner Miao
8
- Author-email: oscaner1997@163.com
8
+ Author-email: oscaner1997@gmail.com
9
9
  Requires-Python: >=3.10
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Programming Language :: Python :: 3
@@ -122,10 +122,13 @@ asyncio.run(async_chat())
122
122
  - Conversation and message history management
123
123
  - Streaming and blocking response modes
124
124
 
125
- ### Completion API
126
- - Text generation and completion
127
- - Custom input parameters
128
- - Streaming support
125
+ ### Completion API (15 APIs)
126
+ - **Message Processing**: Send messages and control responses
127
+ - **Annotation Management**: Create, update, and manage annotations
128
+ - **Audio Processing**: Text-to-audio conversion
129
+ - **Feedback System**: Collect and analyze user feedback
130
+ - **File Upload**: Support for document and media files
131
+ - **Application Info**: Configuration and metadata retrieval
129
132
 
130
133
  ### Knowledge Base API (39 APIs)
131
134
  - **Dataset Management**: CRUD operations for datasets
@@ -261,6 +264,7 @@ dify-oapi/
261
264
  ## 📖 Documentation
262
265
 
263
266
  - [**Project Overview**](./docs/overview.md) - Architecture and technical details
267
+ - [**Completion APIs**](./docs/completion/apis.md) - Complete completion API documentation
264
268
  - [**Knowledge Base APIs**](./docs/datasets/apis.md) - Complete dataset API documentation
265
269
  - [**Examples**](./examples/README.md) - Usage examples and patterns
266
270