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.
Files changed (215) hide show
  1. dify_oapi/api/chat/v1/model/__init__.py +37 -0
  2. dify_oapi/api/chat/v1/model/agent_thought.py +69 -0
  3. dify_oapi/api/chat/v1/model/annotation_info.py +43 -0
  4. dify_oapi/api/{completion/v1/model/info → chat/v1/model}/app_info.py +6 -14
  5. dify_oapi/api/chat/v1/model/app_parameters.py +494 -0
  6. dify_oapi/api/chat/v1/model/chat_file.py +53 -0
  7. dify_oapi/api/chat/v1/model/chat_request_body.py +26 -13
  8. dify_oapi/api/chat/v1/model/chat_response.py +13 -2
  9. dify_oapi/api/chat/v1/model/chat_types.py +65 -0
  10. dify_oapi/api/chat/v1/model/configure_annotation_reply_request.py +37 -0
  11. dify_oapi/api/chat/v1/model/configure_annotation_reply_request_body.py +39 -0
  12. dify_oapi/api/chat/v1/model/configure_annotation_reply_response.py +10 -0
  13. dify_oapi/api/chat/v1/model/conversation_info.py +57 -0
  14. dify_oapi/api/chat/v1/model/conversation_variable.py +55 -0
  15. dify_oapi/api/chat/v1/model/create_annotation_request.py +30 -0
  16. dify_oapi/api/chat/v1/model/create_annotation_request_body.py +32 -0
  17. dify_oapi/api/chat/v1/model/create_annotation_response.py +9 -0
  18. dify_oapi/api/chat/v1/model/delete_annotation_request.py +26 -0
  19. dify_oapi/api/chat/v1/model/delete_annotation_response.py +7 -0
  20. dify_oapi/api/{completion/v1/model/feedback → chat/v1/model}/feedback_info.py +29 -7
  21. dify_oapi/api/{completion/v1/model/file → chat/v1/model}/file_info.py +6 -0
  22. dify_oapi/api/chat/v1/model/get_annotation_reply_status_request.py +32 -0
  23. dify_oapi/api/chat/v1/model/get_annotation_reply_status_response.py +11 -0
  24. dify_oapi/api/chat/v1/model/get_conversation_list_request.py +25 -24
  25. dify_oapi/api/chat/v1/model/get_conversation_list_response.py +4 -15
  26. dify_oapi/api/chat/v1/model/get_conversation_variables_request.py +54 -0
  27. dify_oapi/api/chat/v1/model/get_conversation_variables_response.py +10 -0
  28. dify_oapi/api/chat/v1/model/get_conversations_request.py +49 -0
  29. dify_oapi/api/chat/v1/model/get_suggested_questions_request.py +36 -0
  30. dify_oapi/api/chat/v1/model/{message_suggested_response.py → get_suggested_questions_response.py} +1 -1
  31. dify_oapi/api/chat/v1/model/list_annotations_request.py +32 -0
  32. dify_oapi/api/chat/v1/model/list_annotations_response.py +11 -0
  33. dify_oapi/api/chat/v1/model/message_file.py +46 -0
  34. dify_oapi/api/chat/v1/model/message_history_request.py +24 -24
  35. dify_oapi/api/chat/v1/model/message_history_response.py +4 -43
  36. dify_oapi/api/chat/v1/model/message_info.py +73 -0
  37. dify_oapi/api/chat/v1/model/pagination_info.py +44 -0
  38. dify_oapi/api/chat/v1/model/rename_conversation_request_body.py +1 -1
  39. dify_oapi/api/chat/v1/model/retriever_resource.py +64 -0
  40. dify_oapi/api/chat/v1/model/site_settings.py +92 -0
  41. dify_oapi/api/chat/v1/model/text_to_audio_response.py +7 -0
  42. dify_oapi/api/chat/v1/model/tool_icon.py +52 -0
  43. dify_oapi/api/chat/v1/model/update_annotation_request.py +34 -0
  44. dify_oapi/api/chat/v1/model/update_annotation_request_body.py +32 -0
  45. dify_oapi/api/chat/v1/model/update_annotation_response.py +9 -0
  46. dify_oapi/api/{completion/v1/model/file → chat/v1/model}/upload_file_request_body.py +9 -3
  47. dify_oapi/api/chat/v1/model/usage_info.py +84 -0
  48. dify_oapi/api/chat/v1/resource/__init__.py +1 -4
  49. dify_oapi/api/chat/v1/resource/annotation.py +87 -0
  50. dify_oapi/api/chat/v1/resource/chat.py +47 -25
  51. dify_oapi/api/chat/v1/resource/conversation.py +45 -33
  52. dify_oapi/api/chat/v1/resource/message.py +22 -20
  53. dify_oapi/api/chat/v1/version.py +18 -5
  54. dify_oapi/api/chatflow/__init__.py +0 -0
  55. dify_oapi/api/chatflow/service.py +8 -0
  56. dify_oapi/api/chatflow/v1/__init__.py +0 -0
  57. dify_oapi/api/chatflow/v1/model/__init__.py +0 -0
  58. dify_oapi/api/chatflow/v1/model/annotation_info.py +43 -0
  59. dify_oapi/api/chatflow/v1/model/annotation_reply_settings_request.py +37 -0
  60. dify_oapi/api/chatflow/v1/model/annotation_reply_settings_request_body.py +33 -0
  61. dify_oapi/api/chatflow/v1/model/annotation_reply_settings_response.py +10 -0
  62. dify_oapi/api/chatflow/v1/model/annotation_reply_status_request.py +36 -0
  63. dify_oapi/api/chatflow/v1/model/annotation_reply_status_response.py +11 -0
  64. dify_oapi/api/chatflow/v1/model/app_info.py +33 -0
  65. dify_oapi/api/chatflow/v1/model/app_parameters.py +276 -0
  66. dify_oapi/api/chatflow/v1/model/chat_file.py +40 -0
  67. dify_oapi/api/chatflow/v1/model/chat_message.py +88 -0
  68. dify_oapi/api/chatflow/v1/model/chatflow_types.py +210 -0
  69. dify_oapi/api/chatflow/v1/model/conversation_info.py +53 -0
  70. dify_oapi/api/chatflow/v1/model/conversation_variable.py +55 -0
  71. dify_oapi/api/chatflow/v1/model/create_annotation_request.py +30 -0
  72. dify_oapi/api/chatflow/v1/model/create_annotation_request_body.py +28 -0
  73. dify_oapi/api/chatflow/v1/model/create_annotation_response.py +9 -0
  74. dify_oapi/api/chatflow/v1/model/delete_annotation_request.py +28 -0
  75. dify_oapi/api/chatflow/v1/model/delete_annotation_response.py +7 -0
  76. dify_oapi/api/chatflow/v1/model/delete_conversation_request.py +36 -0
  77. dify_oapi/api/chatflow/v1/model/delete_conversation_request_body.py +21 -0
  78. dify_oapi/api/chatflow/v1/model/delete_conversation_response.py +17 -0
  79. dify_oapi/api/chatflow/v1/model/feedback_info.py +75 -0
  80. dify_oapi/api/chatflow/v1/model/file_info.py +53 -0
  81. dify_oapi/api/chatflow/v1/model/get_annotations_request.py +30 -0
  82. dify_oapi/api/chatflow/v1/model/get_annotations_response.py +13 -0
  83. dify_oapi/api/chatflow/v1/model/get_conversation_messages_request.py +38 -0
  84. dify_oapi/api/chatflow/v1/model/get_conversation_messages_response.py +33 -0
  85. dify_oapi/api/chatflow/v1/model/get_conversation_variables_request.py +44 -0
  86. dify_oapi/api/chatflow/v1/model/get_conversation_variables_response.py +33 -0
  87. dify_oapi/api/chatflow/v1/model/get_conversations_request.py +40 -0
  88. dify_oapi/api/chatflow/v1/model/get_conversations_response.py +33 -0
  89. dify_oapi/api/chatflow/v1/model/get_suggested_questions_request.py +32 -0
  90. dify_oapi/api/{completion/v1/model/feedback/message_feedback_response.py → chatflow/v1/model/get_suggested_questions_response.py} +2 -3
  91. dify_oapi/api/chatflow/v1/model/rename_conversation_request.py +36 -0
  92. dify_oapi/api/chatflow/v1/model/rename_conversation_request_body.py +31 -0
  93. dify_oapi/api/chatflow/v1/model/rename_conversation_response.py +53 -0
  94. dify_oapi/api/chatflow/v1/model/retriever_resource.py +58 -0
  95. dify_oapi/api/chatflow/v1/model/send_chat_message_request.py +30 -0
  96. dify_oapi/api/chatflow/v1/model/send_chat_message_request_body.py +54 -0
  97. dify_oapi/api/chatflow/v1/model/send_chat_message_response.py +7 -0
  98. dify_oapi/api/chatflow/v1/model/stop_chat_message_request.py +36 -0
  99. dify_oapi/api/chatflow/v1/model/stop_chat_message_request_body.py +21 -0
  100. dify_oapi/api/{dify/v1/model/message_feedback_response.py → chatflow/v1/model/stop_chat_message_response.py} +1 -1
  101. dify_oapi/api/chatflow/v1/model/tool_icon.py +48 -0
  102. dify_oapi/api/chatflow/v1/model/update_annotation_request.py +36 -0
  103. dify_oapi/api/chatflow/v1/model/update_annotation_request_body.py +28 -0
  104. dify_oapi/api/chatflow/v1/model/update_annotation_response.py +9 -0
  105. dify_oapi/api/chatflow/v1/model/usage_info.py +78 -0
  106. dify_oapi/api/chatflow/v1/model/user_input_form.py +141 -0
  107. dify_oapi/api/chatflow/v1/model/webapp_settings.py +88 -0
  108. dify_oapi/api/chatflow/v1/resource/__init__.py +0 -0
  109. dify_oapi/api/chatflow/v1/resource/annotation.py +87 -0
  110. dify_oapi/api/chatflow/v1/resource/chatflow.py +78 -0
  111. dify_oapi/api/chatflow/v1/resource/conversation.py +75 -0
  112. dify_oapi/api/chatflow/v1/version.py +22 -0
  113. dify_oapi/api/completion/v1/resource/__init__.py +0 -6
  114. dify_oapi/api/completion/v1/version.py +8 -6
  115. dify_oapi/api/{chat → dify}/v1/model/audio_to_text_request_body.py +2 -2
  116. dify_oapi/api/{completion/v1/model/feedback → dify/v1/model}/get_feedbacks_request.py +12 -12
  117. dify_oapi/api/dify/v1/model/get_feedbacks_response.py +26 -0
  118. dify_oapi/api/{workflow → dify}/v1/model/get_parameters_request.py +4 -0
  119. dify_oapi/api/dify/v1/model/{get_parameter_response.py → get_parameters_response.py} +6 -2
  120. dify_oapi/api/dify/v1/model/get_site_response.py +17 -0
  121. dify_oapi/api/dify/v1/model/submit_feedback_request.py +34 -0
  122. dify_oapi/api/dify/v1/model/submit_feedback_request_body.py +35 -0
  123. dify_oapi/api/dify/v1/model/submit_feedback_response.py +7 -0
  124. dify_oapi/api/dify/v1/resource/__init__.py +0 -6
  125. dify_oapi/api/dify/v1/resource/audio.py +12 -0
  126. dify_oapi/api/dify/v1/resource/feedback.py +31 -0
  127. dify_oapi/api/dify/v1/resource/info.py +34 -2
  128. dify_oapi/api/dify/v1/version.py +5 -4
  129. dify_oapi/api/knowledge/service.py +3 -3
  130. dify_oapi/api/knowledge/v1/model/create_document_by_file_request.py +1 -3
  131. dify_oapi/api/knowledge/v1/model/create_document_by_file_request_body.py +4 -46
  132. dify_oapi/api/knowledge/v1/model/create_document_by_file_request_body_data.py +73 -0
  133. dify_oapi/api/knowledge/v1/model/data_source_detail.py +23 -0
  134. dify_oapi/api/knowledge/v1/model/dataset_info.py +10 -9
  135. dify_oapi/api/knowledge/v1/model/dataset_metadata.py +14 -0
  136. dify_oapi/api/knowledge/v1/model/document_info.py +18 -6
  137. dify_oapi/api/knowledge/v1/model/external_knowledge_info.py +11 -1
  138. dify_oapi/api/knowledge/v1/model/external_retrieval_model.py +13 -0
  139. dify_oapi/api/knowledge/v1/model/knowledge_types.py +2 -2
  140. dify_oapi/api/knowledge/v1/model/process_rule.py +0 -6
  141. dify_oapi/api/knowledge/v1/model/retrieval_model.py +10 -4
  142. dify_oapi/api/knowledge/v1/model/update_document_by_file_request.py +1 -3
  143. dify_oapi/api/knowledge/v1/model/update_document_by_file_request_body.py +4 -41
  144. dify_oapi/api/knowledge/v1/model/update_document_by_file_request_body_data.py +68 -0
  145. dify_oapi/api/knowledge/v1/model/weights.py +27 -0
  146. dify_oapi/api/knowledge/v1/resource/__init__.py +0 -8
  147. dify_oapi/api/workflow/v1/model/chunk_workflow_event.py +74 -0
  148. dify_oapi/api/workflow/v1/model/input_file_object_workflow.py +76 -0
  149. dify_oapi/api/workflow/v1/model/node_finished_data.py +118 -0
  150. dify_oapi/api/workflow/v1/model/node_started_data.py +81 -0
  151. dify_oapi/api/workflow/v1/model/ping_data.py +28 -0
  152. dify_oapi/api/workflow/v1/model/run_workflow_request_body.py +1 -1
  153. dify_oapi/api/workflow/v1/model/text_chunk_data.py +39 -0
  154. dify_oapi/api/workflow/v1/model/tts_message_data.py +45 -0
  155. dify_oapi/api/workflow/v1/model/tts_message_end_data.py +45 -0
  156. dify_oapi/api/workflow/v1/model/workflow_completion_response.py +50 -0
  157. dify_oapi/api/workflow/v1/model/workflow_finished_data.py +93 -0
  158. dify_oapi/api/workflow/v1/model/workflow_started_data.py +51 -0
  159. dify_oapi/api/workflow/v1/model/workflow_types.py +27 -12
  160. dify_oapi/api/workflow/v1/resource/workflow.py +0 -34
  161. dify_oapi/api/workflow/v1/version.py +9 -0
  162. dify_oapi/client.py +49 -4
  163. dify_oapi/core/http/transport/__init__.py +2 -1
  164. dify_oapi/core/http/transport/async_transport.py +73 -50
  165. dify_oapi/core/http/transport/connection_pool.py +131 -0
  166. dify_oapi/core/http/transport/sync_transport.py +73 -50
  167. dify_oapi/core/model/config.py +10 -0
  168. dify_oapi2-1.0.0.dist-info/METADATA +365 -0
  169. {dify_oapi2-0.4.0.dist-info → dify_oapi2-1.0.0.dist-info}/RECORD +174 -98
  170. dify_oapi/api/chat/v1/model/chat_request_file.py +0 -46
  171. dify_oapi/api/chat/v1/model/message_suggested_request.py +0 -36
  172. dify_oapi/api/chat/v1/resource/audio.py +0 -17
  173. dify_oapi/api/completion/v1/model/audio/audio_info.py +0 -28
  174. dify_oapi/api/completion/v1/model/audio/text_to_audio_request.py +0 -32
  175. dify_oapi/api/completion/v1/model/audio/text_to_audio_request_body.py +0 -33
  176. dify_oapi/api/completion/v1/model/audio/text_to_audio_response.py +0 -9
  177. dify_oapi/api/completion/v1/model/feedback/get_feedbacks_response.py +0 -9
  178. dify_oapi/api/completion/v1/model/feedback/message_feedback_request.py +0 -38
  179. dify_oapi/api/completion/v1/model/feedback/message_feedback_request_body.py +0 -35
  180. dify_oapi/api/completion/v1/model/file/upload_file_request.py +0 -42
  181. dify_oapi/api/completion/v1/model/file/upload_file_response.py +0 -9
  182. dify_oapi/api/completion/v1/model/info/feature_config.py +0 -91
  183. dify_oapi/api/completion/v1/model/info/file_upload_config.py +0 -23
  184. dify_oapi/api/completion/v1/model/info/get_info_request.py +0 -24
  185. dify_oapi/api/completion/v1/model/info/get_info_response.py +0 -9
  186. dify_oapi/api/completion/v1/model/info/get_parameters_request.py +0 -24
  187. dify_oapi/api/completion/v1/model/info/get_parameters_response.py +0 -9
  188. dify_oapi/api/completion/v1/model/info/get_site_response.py +0 -9
  189. dify_oapi/api/completion/v1/model/info/parameters_info.py +0 -75
  190. dify_oapi/api/completion/v1/model/info/site_info.py +0 -90
  191. dify_oapi/api/completion/v1/model/info/system_parameters.py +0 -38
  192. dify_oapi/api/completion/v1/model/info/user_input_form.py +0 -158
  193. dify_oapi/api/completion/v1/resource/audio.py +0 -19
  194. dify_oapi/api/completion/v1/resource/feedback.py +0 -33
  195. dify_oapi/api/completion/v1/resource/file.py +0 -19
  196. dify_oapi/api/completion/v1/resource/info.py +0 -39
  197. dify_oapi/api/dify/v1/model/get_parameter_request.py +0 -30
  198. dify_oapi/api/dify/v1/model/message_feedback_request.py +0 -38
  199. dify_oapi/api/dify/v1/model/message_feedback_request_body.py +0 -30
  200. dify_oapi/api/dify/v1/resource/message.py +0 -21
  201. dify_oapi/api/dify/v1/resource/meta.py +0 -17
  202. dify_oapi/api/dify/v1/resource/parameter.py +0 -19
  203. dify_oapi/api/workflow/v1/model/get_info_request.py +0 -24
  204. dify_oapi/api/workflow/v1/model/get_info_response.py +0 -9
  205. dify_oapi/api/workflow/v1/model/get_parameters_response.py +0 -9
  206. dify_oapi/api/workflow/v1/model/get_site_request.py +0 -24
  207. dify_oapi/api/workflow/v1/model/get_site_response.py +0 -9
  208. dify_oapi/api/workflow/v1/model/upload_file_request.py +0 -42
  209. dify_oapi/api/workflow/v1/model/upload_file_response.py +0 -9
  210. dify_oapi2-0.4.0.dist-info/METADATA +0 -303
  211. /dify_oapi/api/{chat → dify}/v1/model/audio_to_text_request.py +0 -0
  212. /dify_oapi/api/{chat → dify}/v1/model/audio_to_text_response.py +0 -0
  213. /dify_oapi/api/{completion/v1/model/info → dify/v1/model}/get_site_request.py +0 -0
  214. {dify_oapi2-0.4.0.dist-info → dify_oapi2-1.0.0.dist-info}/LICENSE +0 -0
  215. {dify_oapi2-0.4.0.dist-info → dify_oapi2-1.0.0.dist-info}/WHEEL +0 -0
@@ -1,303 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: dify-oapi2
3
- Version: 0.4.0
4
- Summary: A package for interacting with the Dify Service-API
5
- License: MIT
6
- Keywords: dify,nlp,ai,language-processing
7
- Author: Oscaner Miao
8
- Author-email: oscaner1997@gmail.com
9
- Requires-Python: >=3.10
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Requires-Dist: httpx (>=0.24,<1.0)
17
- Requires-Dist: pydantic (>=1.10,<3.0.0)
18
- Project-URL: Homepage, https://github.com/nodite/dify-oapi2
19
- Project-URL: Source, https://github.com/nodite/dify-oapi2
20
- Description-Content-Type: text/markdown
21
-
22
- # Dify-OAPI
23
-
24
- [![PyPI version](https://badge.fury.io/py/dify-oapi2.svg)](https://badge.fury.io/py/dify-oapi2)
25
- [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
26
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
27
-
28
- A Python SDK for interacting with the Dify Service-API. This library provides a fluent, type-safe interface for building AI-powered applications using Dify's API services including chat, completion, knowledge base, and workflow features.
29
-
30
- > This project is based on https://github.com/QiMington/dify-oapi, with refactoring and support for the latest Dify API.
31
-
32
- ## ✨ Features
33
-
34
- - **Multiple API Services**: Chat, Completion, Knowledge Base (33 APIs), Workflow, and Core Dify APIs
35
- - **Builder Pattern**: Fluent, chainable interface for constructing requests
36
- - **Sync & Async Support**: Both synchronous and asynchronous operations
37
- - **Streaming Responses**: Real-time streaming for chat and completion
38
- - **Type Safety**: Comprehensive type hints with Pydantic validation
39
- - **File Upload**: Support for images and documents
40
- - **Modern HTTP Client**: Built on httpx for reliable API communication
41
-
42
- ## 📦 Installation
43
-
44
- ```bash
45
- pip install dify-oapi2
46
- ```
47
-
48
- **Requirements**: Python 3.10+
49
-
50
- **Dependencies**:
51
- - `pydantic` (>=1.10,<3.0.0) - Data validation and settings management
52
- - `httpx` (>=0.24,<1.0) - Modern HTTP client
53
-
54
- ## 🚀 Quick Start
55
-
56
- ### Basic Chat Example
57
-
58
- ```python
59
- from dify_oapi.api.chat.v1.model.chat_request import ChatRequest
60
- from dify_oapi.api.chat.v1.model.chat_request_body import ChatRequestBody
61
- from dify_oapi.client import Client
62
- from dify_oapi.core.model.request_option import RequestOption
63
-
64
- # Initialize client
65
- client = Client.builder().domain("https://api.dify.ai").build()
66
-
67
- # Build request
68
- req_body = (
69
- ChatRequestBody.builder()
70
- .inputs({})
71
- .query("What can Dify API do?")
72
- .response_mode("blocking")
73
- .user("user-123")
74
- .build()
75
- )
76
-
77
- req = ChatRequest.builder().request_body(req_body).build()
78
- req_option = RequestOption.builder().api_key("your-api-key").build()
79
-
80
- # Execute request
81
- response = client.chat.v1.chat.chat(req, req_option, False)
82
- print(response.answer)
83
- ```
84
-
85
- ### Streaming Chat Example
86
-
87
- ```python
88
- # Enable streaming for real-time responses
89
- req_body = (
90
- ChatRequestBody.builder()
91
- .query("Tell me a story")
92
- .response_mode("streaming")
93
- .user("user-123")
94
- .build()
95
- )
96
-
97
- req = ChatRequest.builder().request_body(req_body).build()
98
- response = client.chat.v1.chat.chat(req, req_option, True)
99
-
100
- # Process streaming response
101
- for chunk in response:
102
- print(chunk, end="", flush=True)
103
- ```
104
-
105
- ### Async Support
106
-
107
- ```python
108
- import asyncio
109
-
110
- async def async_chat():
111
- response = await client.chat.v1.chat.achat(req, req_option, False)
112
- print(response.answer)
113
-
114
- asyncio.run(async_chat())
115
- ```
116
-
117
- ## 🔧 API Services
118
-
119
- ### Chat API
120
- - Interactive conversations with AI assistants
121
- - File upload support (images, documents)
122
- - Conversation and message history management
123
- - Streaming and blocking response modes
124
-
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
132
-
133
- ### Knowledge Base API (33 APIs)
134
- - **Dataset Management**: 6 APIs for dataset CRUD operations and content retrieval
135
- - **Document Management**: 10 APIs for document upload, processing, and management
136
- - **Segment Management**: 5 APIs for fine-grained content segmentation
137
- - **Child Chunks Management**: 4 APIs for sub-segment management
138
- - **Tag Management**: 7 APIs for metadata and knowledge type tags
139
- - **Model Management**: 1 API for embedding model information
140
-
141
- ### Workflow API
142
- - Automated workflow execution
143
- - Parameter configuration
144
- - Status monitoring
145
-
146
- ### Dify Core API
147
- - Essential Dify service functionality
148
-
149
- ## 💡 Examples
150
-
151
- Explore comprehensive examples in the [examples directory](./examples):
152
-
153
- ### Chat Examples
154
- - [**Blocking Response**](./examples/chat/blocking_response.py) - Standard chat interactions
155
- - [**Streaming Response**](./examples/chat/streaming_response.py) - Real-time streaming chat
156
- - [**Conversation Management**](./examples/chat/conversation_management.py) - Managing chat history
157
-
158
- ### Completion Examples
159
- - [**Basic Completion**](./examples/completion/basic_completion.py) - Text generation
160
-
161
- ### Knowledge Base Examples
162
- - [**Dataset Management**](./examples/knowledge/dataset/) - Complete dataset operations
163
- - [**Document Processing**](./examples/knowledge/document/) - File upload and text processing
164
- - [**Content Organization**](./examples/knowledge/segment/) - Segment and chunk management
165
- - [**Tag Management**](./examples/knowledge/tag/) - Metadata and tagging system
166
-
167
- For detailed examples and usage patterns, see the [examples README](./examples/README.md).
168
-
169
- ## 🛠️ Development
170
-
171
- ### Prerequisites
172
- - Python 3.10+
173
- - Poetry
174
-
175
- ### Setup
176
-
177
- ```bash
178
- # Clone repository
179
- git clone https://github.com/nodite/dify-oapi2.git
180
- cd dify-oapi
181
-
182
- # Setup development environment (installs dependencies and pre-commit hooks)
183
- make dev-setup
184
- ```
185
-
186
- ### Code Quality Tools
187
-
188
- This project uses modern Python tooling:
189
-
190
- - **Ruff**: Fast Python linter and formatter
191
- - **MyPy**: Static type checking
192
- - **Pre-commit**: Git hooks for code quality
193
- - **Pylint**: Additional code analysis
194
-
195
- ```bash
196
- # Format code
197
- make format
198
-
199
- # Lint code
200
- make lint
201
-
202
- # Fix linting issues
203
- make fix
204
-
205
- # Run all checks (lint + type check)
206
- make check
207
-
208
- # Install pre-commit hooks
209
- make install-hooks
210
-
211
- # Run pre-commit hooks manually
212
- make pre-commit
213
- ```
214
-
215
- ### Testing
216
-
217
- ```bash
218
- # Set environment variables
219
- export DOMAIN="https://api.dify.ai"
220
- export CHAT_KEY="your-api-key"
221
-
222
- # Run tests
223
- make test
224
-
225
- # Run tests with coverage
226
- make test-cov
227
- ```
228
-
229
- ### Build & Publish
230
-
231
- ```bash
232
- # Configure PyPI tokens (one-time setup)
233
- poetry config http-basic.testpypi __token__ <your-testpypi-token>
234
- poetry config http-basic.pypi __token__ <your-pypi-token>
235
-
236
- # Build package
237
- make build
238
-
239
- # Publish to TestPyPI (for testing)
240
- make publish-test
241
-
242
- # Publish to PyPI (maintainers only)
243
- make publish
244
- ```
245
-
246
- ### Project Structure
247
-
248
- ```
249
- dify-oapi/
250
- ├── dify_oapi/ # Main SDK package
251
- │ ├── api/ # API service modules
252
- │ │ ├── chat/ # Chat API
253
- │ │ ├── completion/ # Completion API
254
- │ │ ├── dify/ # Core Dify API
255
- │ │ ├── knowledge/ # Knowledge Base API (33 APIs)
256
- │ │ └── workflow/ # Workflow API
257
- │ ├── core/ # Core functionality
258
- │ │ ├── http/ # HTTP transport layer
259
- │ │ ├── model/ # Base models
260
- │ │ └── utils/ # Utilities
261
- │ └── client.py # Main client interface
262
- ├── docs/ # Documentation
263
- ├── examples/ # Usage examples
264
- ├── tests/ # Test suite
265
- └── pyproject.toml # Project configuration
266
- ```
267
-
268
- ## 📖 Documentation
269
-
270
- - [**Project Overview**](./docs/overview.md) - Architecture and technical details
271
- - [**Completion APIs**](./docs/completion/apis.md) - Complete completion API documentation
272
- - [**Knowledge Base APIs**](./docs/knowledge/apis.md) - Complete knowledge base API documentation
273
- - [**Examples**](./examples/README.md) - Usage examples and patterns
274
-
275
- ## 🤝 Contributing
276
-
277
- Contributions are welcome! Please:
278
-
279
- 1. Fork the repository
280
- 2. Create a feature branch
281
- 3. Make your changes with tests
282
- 4. Ensure code quality (`ruff format`, `ruff check`, `mypy`)
283
- 5. Submit a pull request
284
-
285
- ## 📄 License
286
-
287
- This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
288
-
289
- ## 🔗 Links
290
-
291
- - **PyPI Package**: https://pypi.org/project/dify-oapi2/
292
- - **Source Code**: https://github.com/nodite/dify-oapi2
293
- - **Dify Platform**: https://dify.ai/
294
- - **Dify API Docs**: https://docs.dify.ai/
295
-
296
- ## 📄 License
297
-
298
- MIT License - see [LICENSE](./LICENSE) file for details.
299
-
300
- ---
301
-
302
- **Keywords**: dify, nlp, ai, language-processing
303
-