dify-oapi2 0.1.0__py3-none-any.whl → 0.2.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/completion/v1/model/annotation/annotation_info.py +43 -0
- dify_oapi/api/completion/v1/model/annotation/annotation_reply_settings_request.py +39 -0
- dify_oapi/api/completion/v1/model/annotation/annotation_reply_settings_request_body.py +33 -0
- dify_oapi/api/completion/v1/model/annotation/annotation_reply_settings_response.py +9 -0
- dify_oapi/api/completion/v1/model/annotation/create_annotation_request.py +32 -0
- dify_oapi/api/completion/v1/model/annotation/create_annotation_request_body.py +28 -0
- dify_oapi/api/completion/v1/model/annotation/create_annotation_response.py +9 -0
- dify_oapi/api/completion/v1/model/annotation/delete_annotation_request.py +30 -0
- dify_oapi/api/completion/v1/model/annotation/delete_annotation_response.py +7 -0
- dify_oapi/api/completion/v1/model/annotation/job_status_info.py +35 -0
- dify_oapi/api/completion/v1/model/annotation/list_annotations_request.py +32 -0
- dify_oapi/api/completion/v1/model/annotation/list_annotations_response.py +13 -0
- dify_oapi/api/completion/v1/model/annotation/query_annotation_reply_status_request.py +38 -0
- dify_oapi/api/completion/v1/model/annotation/query_annotation_reply_status_response.py +9 -0
- dify_oapi/api/completion/v1/model/annotation/update_annotation_request.py +38 -0
- dify_oapi/api/completion/v1/model/annotation/update_annotation_request_body.py +28 -0
- dify_oapi/api/completion/v1/model/annotation/update_annotation_response.py +9 -0
- dify_oapi/api/completion/v1/model/audio/audio_info.py +28 -0
- dify_oapi/api/completion/v1/model/audio/text_to_audio_request.py +32 -0
- dify_oapi/api/completion/v1/model/audio/text_to_audio_request_body.py +33 -0
- dify_oapi/api/completion/v1/model/audio/text_to_audio_response.py +9 -0
- dify_oapi/api/completion/v1/model/completion/completion_inputs.py +28 -0
- dify_oapi/api/completion/v1/model/completion/completion_message_info.py +46 -0
- dify_oapi/api/completion/v1/model/completion/completion_types.py +27 -0
- dify_oapi/api/completion/v1/model/completion/metadata.py +31 -0
- dify_oapi/api/completion/v1/model/completion/retriever_resource.py +58 -0
- dify_oapi/api/completion/v1/model/completion/send_message_request.py +32 -0
- dify_oapi/api/completion/v1/model/completion/send_message_request_body.py +76 -0
- dify_oapi/api/completion/v1/model/completion/send_message_response.py +9 -0
- dify_oapi/api/completion/v1/model/completion/stop_response_request.py +38 -0
- dify_oapi/api/completion/v1/model/completion/stop_response_request_body.py +23 -0
- dify_oapi/api/completion/v1/model/{stop_completion_response.py → completion/stop_response_response.py} +3 -1
- dify_oapi/api/completion/v1/model/completion/usage.py +78 -0
- dify_oapi/api/completion/v1/model/feedback/feedback_info.py +53 -0
- dify_oapi/api/completion/v1/model/feedback/get_feedbacks_request.py +32 -0
- dify_oapi/api/completion/v1/model/feedback/get_feedbacks_response.py +9 -0
- dify_oapi/api/completion/v1/model/feedback/message_feedback_request.py +38 -0
- dify_oapi/api/completion/v1/model/feedback/message_feedback_request_body.py +35 -0
- dify_oapi/api/completion/v1/model/feedback/message_feedback_response.py +7 -0
- dify_oapi/api/completion/v1/model/file/file_info.py +53 -0
- dify_oapi/api/completion/v1/model/file/upload_file_request.py +42 -0
- dify_oapi/api/completion/v1/model/file/upload_file_request_body.py +23 -0
- dify_oapi/api/completion/v1/model/file/upload_file_response.py +9 -0
- dify_oapi/api/completion/v1/model/info/app_info.py +43 -0
- dify_oapi/api/completion/v1/model/info/file_upload_config.py +23 -0
- dify_oapi/api/completion/v1/model/info/get_info_request.py +24 -0
- dify_oapi/api/completion/v1/model/info/get_info_response.py +9 -0
- dify_oapi/api/completion/v1/model/info/get_parameters_request.py +24 -0
- dify_oapi/api/completion/v1/model/info/get_parameters_response.py +9 -0
- dify_oapi/api/completion/v1/model/info/get_site_request.py +24 -0
- dify_oapi/api/completion/v1/model/info/get_site_response.py +9 -0
- dify_oapi/api/completion/v1/model/info/parameters_info.py +67 -0
- dify_oapi/api/completion/v1/model/info/site_info.py +90 -0
- dify_oapi/api/completion/v1/model/info/system_parameters.py +38 -0
- dify_oapi/api/completion/v1/model/info/user_input_form.py +43 -0
- dify_oapi/api/completion/v1/resource/__init__.py +5 -0
- dify_oapi/api/completion/v1/resource/annotation.py +99 -0
- dify_oapi/api/completion/v1/resource/audio.py +19 -0
- dify_oapi/api/completion/v1/resource/completion.py +36 -46
- dify_oapi/api/completion/v1/resource/feedback.py +33 -0
- dify_oapi/api/completion/v1/resource/file.py +19 -0
- dify_oapi/api/completion/v1/resource/info.py +39 -0
- dify_oapi/api/completion/v1/version.py +11 -1
- dify_oapi/api/knowledge_base/v1/model/dataset/create_request_body.py +3 -4
- dify_oapi/api/knowledge_base/v1/model/dataset/dataset_types.py +36 -0
- dify_oapi/api/knowledge_base/v1/model/dataset/retrieval_model.py +3 -6
- dify_oapi/api/knowledge_base/v1/model/document/create_by_text_request_body.py +7 -12
- dify_oapi/api/knowledge_base/v1/model/document/document_types.py +36 -0
- dify_oapi/api/knowledge_base/v1/model/metadata/metadata_types.py +15 -0
- dify_oapi/api/knowledge_base/v1/model/segment/segment_types.py +24 -0
- dify_oapi/api/knowledge_base/v1/model/tag/tag_types.py +12 -0
- dify_oapi/api/knowledge_base/v1/model/tag/update_response.py +5 -1
- dify_oapi/core/http/transport/_misc.py +54 -14
- {dify_oapi2-0.1.0.dist-info → dify_oapi2-0.2.0.dist-info}/METADATA +9 -5
- {dify_oapi2-0.1.0.dist-info → dify_oapi2-0.2.0.dist-info}/RECORD +77 -20
- dify_oapi/api/completion/v1/model/completion_request.py +0 -34
- dify_oapi/api/completion/v1/model/completion_request_body.py +0 -43
- dify_oapi/api/completion/v1/model/completion_request_body_input.py +0 -38
- dify_oapi/api/completion/v1/model/completion_request_file.py +0 -49
- dify_oapi/api/completion/v1/model/completion_response.py +0 -18
- dify_oapi/api/completion/v1/model/stop_completion_request.py +0 -38
- dify_oapi/api/completion/v1/model/stop_completion_request_body.py +0 -23
- {dify_oapi2-0.1.0.dist-info → dify_oapi2-0.2.0.dist-info}/LICENSE +0 -0
- {dify_oapi2-0.1.0.dist-info → dify_oapi2-0.2.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,33 @@
|
|
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.feedback.get_feedbacks_request import GetFeedbacksRequest
|
8
|
+
from ..model.feedback.get_feedbacks_response import GetFeedbacksResponse
|
9
|
+
from ..model.feedback.message_feedback_request import MessageFeedbackRequest
|
10
|
+
from ..model.feedback.message_feedback_response import MessageFeedbackResponse
|
11
|
+
|
12
|
+
|
13
|
+
class Feedback:
|
14
|
+
def __init__(self, config: Config) -> None:
|
15
|
+
self.config: Config = config
|
16
|
+
|
17
|
+
def message_feedback(
|
18
|
+
self, request: MessageFeedbackRequest, request_option: RequestOption
|
19
|
+
) -> MessageFeedbackResponse:
|
20
|
+
return Transport.execute(self.config, request, unmarshal_as=MessageFeedbackResponse, option=request_option)
|
21
|
+
|
22
|
+
async def amessage_feedback(
|
23
|
+
self, request: MessageFeedbackRequest, request_option: RequestOption
|
24
|
+
) -> MessageFeedbackResponse:
|
25
|
+
return await ATransport.aexecute(
|
26
|
+
self.config, request, unmarshal_as=MessageFeedbackResponse, option=request_option
|
27
|
+
)
|
28
|
+
|
29
|
+
def get_feedbacks(self, request: GetFeedbacksRequest, request_option: RequestOption) -> GetFeedbacksResponse:
|
30
|
+
return Transport.execute(self.config, request, unmarshal_as=GetFeedbacksResponse, option=request_option)
|
31
|
+
|
32
|
+
async def aget_feedbacks(self, request: GetFeedbacksRequest, request_option: RequestOption) -> GetFeedbacksResponse:
|
33
|
+
return await ATransport.aexecute(self.config, request, unmarshal_as=GetFeedbacksResponse, option=request_option)
|
@@ -0,0 +1,19 @@
|
|
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.file.upload_file_request import UploadFileRequest
|
8
|
+
from ..model.file.upload_file_response import UploadFileResponse
|
9
|
+
|
10
|
+
|
11
|
+
class File:
|
12
|
+
def __init__(self, config: Config) -> None:
|
13
|
+
self.config: Config = config
|
14
|
+
|
15
|
+
def upload_file(self, request: UploadFileRequest, request_option: RequestOption) -> UploadFileResponse:
|
16
|
+
return Transport.execute(self.config, request, unmarshal_as=UploadFileResponse, option=request_option)
|
17
|
+
|
18
|
+
async def aupload_file(self, request: UploadFileRequest, request_option: RequestOption) -> UploadFileResponse:
|
19
|
+
return await ATransport.aexecute(self.config, request, unmarshal_as=UploadFileResponse, option=request_option)
|
@@ -0,0 +1,39 @@
|
|
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 = config
|
18
|
+
|
19
|
+
def get_info(self, request: GetInfoRequest, request_option: RequestOption) -> GetInfoResponse:
|
20
|
+
return Transport.execute(self.config, request, unmarshal_as=GetInfoResponse, option=request_option)
|
21
|
+
|
22
|
+
async def aget_info(self, request: GetInfoRequest, request_option: RequestOption) -> GetInfoResponse:
|
23
|
+
return await ATransport.aexecute(self.config, request, unmarshal_as=GetInfoResponse, option=request_option)
|
24
|
+
|
25
|
+
def get_parameters(self, request: GetParametersRequest, request_option: RequestOption) -> GetParametersResponse:
|
26
|
+
return Transport.execute(self.config, request, unmarshal_as=GetParametersResponse, option=request_option)
|
27
|
+
|
28
|
+
async def aget_parameters(
|
29
|
+
self, request: GetParametersRequest, request_option: RequestOption
|
30
|
+
) -> GetParametersResponse:
|
31
|
+
return await ATransport.aexecute(
|
32
|
+
self.config, request, unmarshal_as=GetParametersResponse, option=request_option
|
33
|
+
)
|
34
|
+
|
35
|
+
def get_site(self, request: GetSiteRequest, request_option: RequestOption) -> GetSiteResponse:
|
36
|
+
return Transport.execute(self.config, request, unmarshal_as=GetSiteResponse, option=request_option)
|
37
|
+
|
38
|
+
async def aget_site(self, request: GetSiteRequest, request_option: RequestOption) -> GetSiteResponse:
|
39
|
+
return await ATransport.aexecute(self.config, request, unmarshal_as=GetSiteResponse, option=request_option)
|
@@ -1,8 +1,18 @@
|
|
1
1
|
from dify_oapi.core.model.config import Config
|
2
2
|
|
3
|
-
from .resource import
|
3
|
+
from .resource.annotation import Annotation
|
4
|
+
from .resource.audio import Audio
|
5
|
+
from .resource.completion import Completion
|
6
|
+
from .resource.feedback import Feedback
|
7
|
+
from .resource.file import File
|
8
|
+
from .resource.info import Info
|
4
9
|
|
5
10
|
|
6
11
|
class V1:
|
7
12
|
def __init__(self, config: Config):
|
8
13
|
self.completion: Completion = Completion(config)
|
14
|
+
self.file: File = File(config)
|
15
|
+
self.feedback: Feedback = Feedback(config)
|
16
|
+
self.audio: Audio = Audio(config)
|
17
|
+
self.info: Info = Info(config)
|
18
|
+
self.annotation: Annotation = Annotation(config)
|
@@ -1,16 +1,15 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from typing import Literal
|
4
|
-
|
5
3
|
from pydantic import BaseModel
|
6
4
|
|
5
|
+
from .dataset_types import IndexingTechnique
|
7
6
|
from .retrieval_model import RetrievalModel
|
8
7
|
|
9
8
|
|
10
9
|
class CreateRequestBody(BaseModel):
|
11
10
|
name: str | None = None
|
12
11
|
description: str | None = None
|
13
|
-
indexing_technique:
|
12
|
+
indexing_technique: IndexingTechnique | None = None
|
14
13
|
permission: str | None = None
|
15
14
|
provider: str | None = None
|
16
15
|
external_knowledge_api_id: str | None = None
|
@@ -40,7 +39,7 @@ class CreateRequestBodyBuilder:
|
|
40
39
|
self._create_request_body.description = description
|
41
40
|
return self
|
42
41
|
|
43
|
-
def indexing_technique(self, indexing_technique:
|
42
|
+
def indexing_technique(self, indexing_technique: IndexingTechnique) -> CreateRequestBodyBuilder:
|
44
43
|
self._create_request_body.indexing_technique = indexing_technique
|
45
44
|
return self
|
46
45
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Literal
|
4
|
+
|
5
|
+
# Indexing technique types
|
6
|
+
IndexingTechnique = Literal["high_quality", "economy"]
|
7
|
+
|
8
|
+
# Search method types
|
9
|
+
SearchMethod = Literal["keyword_search", "semantic_search", "full_text_search", "hybrid_search"]
|
10
|
+
|
11
|
+
# Reranking model types
|
12
|
+
RerankingModelType = Literal["rerank-model"]
|
13
|
+
|
14
|
+
# Processing rule mode types
|
15
|
+
ProcessingRuleMode = Literal["automatic", "custom"]
|
16
|
+
|
17
|
+
# Data source types
|
18
|
+
DataSourceType = Literal["upload_file", "notion_import", "website_crawl"]
|
19
|
+
|
20
|
+
# Document status types
|
21
|
+
DocumentStatus = Literal["indexing", "completed", "error", "paused"]
|
22
|
+
|
23
|
+
# Metadata field types
|
24
|
+
MetadataFieldType = Literal["text", "number", "select"]
|
25
|
+
|
26
|
+
# Tag types
|
27
|
+
TagType = Literal["knowledge", "custom"]
|
28
|
+
|
29
|
+
# Built-in metadata actions
|
30
|
+
BuiltinMetadataAction = Literal["enable", "disable"]
|
31
|
+
|
32
|
+
# Filter operator types
|
33
|
+
FilterOperator = Literal["contains", "not_contains", "is", "is_not", "is_empty", "is_not_empty"]
|
34
|
+
|
35
|
+
# Reranking enable types
|
36
|
+
RerankingEnable = Literal[True, False]
|
@@ -1,9 +1,8 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from typing import Literal
|
4
|
-
|
5
3
|
from pydantic import BaseModel
|
6
4
|
|
5
|
+
from .dataset_types import SearchMethod
|
7
6
|
from .metadata_filtering_conditions import MetadataFilteringConditions
|
8
7
|
from .reranking_model import RerankingModel
|
9
8
|
|
@@ -84,7 +83,7 @@ class WeightsBuilder:
|
|
84
83
|
|
85
84
|
|
86
85
|
class RetrievalModel(BaseModel):
|
87
|
-
search_method:
|
86
|
+
search_method: SearchMethod | None = None
|
88
87
|
reranking_enable: bool | None = None
|
89
88
|
reranking_mode: str | None = None
|
90
89
|
reranking_model: RerankingModel | None = None
|
@@ -106,9 +105,7 @@ class RetrievalModelBuilder:
|
|
106
105
|
def build(self) -> RetrievalModel:
|
107
106
|
return self._retrieval_model
|
108
107
|
|
109
|
-
def search_method(
|
110
|
-
self, search_method: Literal["keyword_search", "semantic_search", "full_text_search", "hybrid_search"]
|
111
|
-
) -> RetrievalModelBuilder:
|
108
|
+
def search_method(self, search_method: SearchMethod) -> RetrievalModelBuilder:
|
112
109
|
self._retrieval_model.search_method = search_method
|
113
110
|
return self
|
114
111
|
|
@@ -1,9 +1,8 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from typing import Literal
|
4
|
-
|
5
3
|
from pydantic import BaseModel
|
6
4
|
|
5
|
+
from .document_types import DocumentForm, DocumentLanguage, IndexingTechnique
|
7
6
|
from .process_rule import ProcessRule
|
8
7
|
from .retrieval_model import RetrievalModel
|
9
8
|
|
@@ -13,9 +12,9 @@ class CreateByTextRequestBody(BaseModel):
|
|
13
12
|
|
14
13
|
name: str | None = None
|
15
14
|
text: str | None = None
|
16
|
-
indexing_technique:
|
17
|
-
doc_form:
|
18
|
-
doc_language:
|
15
|
+
indexing_technique: IndexingTechnique | None = None
|
16
|
+
doc_form: DocumentForm | None = None
|
17
|
+
doc_language: DocumentLanguage | None = None
|
19
18
|
process_rule: ProcessRule | None = None
|
20
19
|
retrieval_model: RetrievalModel | None = None
|
21
20
|
embedding_model: str | None = None
|
@@ -47,19 +46,15 @@ class CreateByTextRequestBodyBuilder:
|
|
47
46
|
self._create_by_text_request_body.text = text
|
48
47
|
return self
|
49
48
|
|
50
|
-
def indexing_technique(
|
51
|
-
self, indexing_technique: Literal["high_quality", "economy"]
|
52
|
-
) -> CreateByTextRequestBodyBuilder:
|
49
|
+
def indexing_technique(self, indexing_technique: IndexingTechnique) -> CreateByTextRequestBodyBuilder:
|
53
50
|
self._create_by_text_request_body.indexing_technique = indexing_technique
|
54
51
|
return self
|
55
52
|
|
56
|
-
def doc_form(
|
57
|
-
self, doc_form: Literal["text_model", "hierarchical_model", "qa_model"]
|
58
|
-
) -> CreateByTextRequestBodyBuilder:
|
53
|
+
def doc_form(self, doc_form: DocumentForm) -> CreateByTextRequestBodyBuilder:
|
59
54
|
self._create_by_text_request_body.doc_form = doc_form
|
60
55
|
return self
|
61
56
|
|
62
|
-
def doc_language(self, doc_language:
|
57
|
+
def doc_language(self, doc_language: DocumentLanguage) -> CreateByTextRequestBodyBuilder:
|
63
58
|
self._create_by_text_request_body.doc_language = doc_language
|
64
59
|
return self
|
65
60
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Literal
|
4
|
+
|
5
|
+
# Indexing technique types
|
6
|
+
IndexingTechnique = Literal["high_quality", "economy"]
|
7
|
+
|
8
|
+
# Document form types
|
9
|
+
DocumentForm = Literal["text_model", "hierarchical_model", "qa_model"]
|
10
|
+
|
11
|
+
# Document language types
|
12
|
+
DocumentLanguage = Literal["English", "Chinese", "Japanese", "Korean"]
|
13
|
+
|
14
|
+
# Processing rule mode types
|
15
|
+
ProcessingRuleMode = Literal["automatic", "custom"]
|
16
|
+
|
17
|
+
# Segmentation separator types
|
18
|
+
Separator = Literal["\\n\\n", "\\n", ".", "!", "?", ";"]
|
19
|
+
|
20
|
+
# Pre-processing rule types
|
21
|
+
PreProcessingRuleType = Literal["remove_extra_spaces", "remove_urls_emails"]
|
22
|
+
|
23
|
+
# Data source types
|
24
|
+
DataSourceType = Literal["upload_file", "notion_import", "website_crawl"]
|
25
|
+
|
26
|
+
# Document indexing status types
|
27
|
+
IndexingStatus = Literal["waiting", "parsing", "cleaning", "splitting", "indexing", "completed", "error", "paused"]
|
28
|
+
|
29
|
+
# Document status action types
|
30
|
+
StatusAction = Literal["enable", "disable", "archive"]
|
31
|
+
|
32
|
+
# Upload file status types
|
33
|
+
UploadFileStatus = Literal["success", "processing", "error"]
|
34
|
+
|
35
|
+
# Document enabled status
|
36
|
+
DocumentEnabled = Literal[True, False]
|
@@ -0,0 +1,15 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Literal
|
4
|
+
|
5
|
+
# Metadata field types
|
6
|
+
MetadataFieldType = Literal["text", "number", "select"]
|
7
|
+
|
8
|
+
# Built-in metadata actions
|
9
|
+
BuiltinMetadataAction = Literal["enable", "disable"]
|
10
|
+
|
11
|
+
# Metadata status types
|
12
|
+
MetadataStatus = Literal["active", "inactive"]
|
13
|
+
|
14
|
+
# Metadata scope types
|
15
|
+
MetadataScope = Literal["document", "segment"]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Literal
|
4
|
+
|
5
|
+
# Segment status types
|
6
|
+
SegmentStatus = Literal["waiting", "indexing", "completed", "error", "paused"]
|
7
|
+
|
8
|
+
# Segment enabled status types
|
9
|
+
SegmentEnabledStatus = Literal["enabled", "disabled"]
|
10
|
+
|
11
|
+
# Child chunk status types
|
12
|
+
ChildChunkStatus = Literal["waiting", "indexing", "completed", "error"]
|
13
|
+
|
14
|
+
# Segment search status types
|
15
|
+
SearchStatus = Literal["all", "enabled", "disabled"]
|
16
|
+
|
17
|
+
# Sort order types
|
18
|
+
SortOrder = Literal["created_at", "position", "word_count", "hit_count"]
|
19
|
+
|
20
|
+
# Sort direction types
|
21
|
+
SortDirection = Literal["asc", "desc"]
|
22
|
+
|
23
|
+
# Segment enabled boolean
|
24
|
+
SegmentEnabled = Literal[True, False]
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Literal
|
4
|
+
|
5
|
+
# Tag types
|
6
|
+
TagType = Literal["knowledge", "custom"]
|
7
|
+
|
8
|
+
# Tag status types
|
9
|
+
TagStatus = Literal["active", "inactive"]
|
10
|
+
|
11
|
+
# Tag binding status types
|
12
|
+
BindingStatus = Literal["bound", "unbound"]
|
@@ -11,9 +11,13 @@ class UpdateResponse(BaseResponse):
|
|
11
11
|
binding_count: int | str | None = None
|
12
12
|
|
13
13
|
def to_tag_info(self) -> TagInfo:
|
14
|
+
binding_count = None
|
15
|
+
if self.binding_count is not None:
|
16
|
+
binding_count = int(self.binding_count) if isinstance(self.binding_count, str) else self.binding_count
|
17
|
+
|
14
18
|
return TagInfo(
|
15
19
|
id=self.id or "",
|
16
20
|
name=self.name or "",
|
17
21
|
type=self.type or "",
|
18
|
-
binding_count=
|
22
|
+
binding_count=binding_count or 0,
|
19
23
|
)
|
@@ -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
|
52
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: dify-oapi2
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.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
|
@@ -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
|
-
-
|
127
|
-
-
|
128
|
-
-
|
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
|
|