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
@@ -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
|
-
[](https://badge.fury.io/py/dify-oapi2)
|
25
|
-
[](https://www.python.org/downloads/)
|
26
|
-
[](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
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|