dify-oapi2 0.4.0__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dify_oapi/api/chat/v1/model/__init__.py +37 -0
- dify_oapi/api/chat/v1/model/agent_thought.py +69 -0
- dify_oapi/api/chat/v1/model/annotation_info.py +43 -0
- dify_oapi/api/{completion/v1/model/info → chat/v1/model}/app_info.py +6 -14
- dify_oapi/api/chat/v1/model/app_parameters.py +494 -0
- dify_oapi/api/chat/v1/model/chat_file.py +53 -0
- dify_oapi/api/chat/v1/model/chat_request_body.py +26 -13
- dify_oapi/api/chat/v1/model/chat_response.py +13 -2
- dify_oapi/api/chat/v1/model/chat_types.py +65 -0
- dify_oapi/api/chat/v1/model/configure_annotation_reply_request.py +37 -0
- dify_oapi/api/chat/v1/model/configure_annotation_reply_request_body.py +39 -0
- dify_oapi/api/chat/v1/model/configure_annotation_reply_response.py +10 -0
- dify_oapi/api/chat/v1/model/conversation_info.py +57 -0
- dify_oapi/api/chat/v1/model/conversation_variable.py +55 -0
- dify_oapi/api/chat/v1/model/create_annotation_request.py +30 -0
- dify_oapi/api/chat/v1/model/create_annotation_request_body.py +32 -0
- dify_oapi/api/chat/v1/model/create_annotation_response.py +9 -0
- dify_oapi/api/chat/v1/model/delete_annotation_request.py +26 -0
- dify_oapi/api/chat/v1/model/delete_annotation_response.py +7 -0
- dify_oapi/api/{completion/v1/model/feedback → chat/v1/model}/feedback_info.py +29 -7
- dify_oapi/api/{completion/v1/model/file → chat/v1/model}/file_info.py +6 -0
- dify_oapi/api/chat/v1/model/get_annotation_reply_status_request.py +32 -0
- dify_oapi/api/chat/v1/model/get_annotation_reply_status_response.py +11 -0
- dify_oapi/api/chat/v1/model/get_conversation_list_request.py +25 -24
- dify_oapi/api/chat/v1/model/get_conversation_list_response.py +4 -15
- dify_oapi/api/chat/v1/model/get_conversation_variables_request.py +54 -0
- dify_oapi/api/chat/v1/model/get_conversation_variables_response.py +10 -0
- dify_oapi/api/chat/v1/model/get_conversations_request.py +49 -0
- dify_oapi/api/chat/v1/model/get_suggested_questions_request.py +36 -0
- dify_oapi/api/chat/v1/model/{message_suggested_response.py → get_suggested_questions_response.py} +1 -1
- dify_oapi/api/chat/v1/model/list_annotations_request.py +32 -0
- dify_oapi/api/chat/v1/model/list_annotations_response.py +11 -0
- dify_oapi/api/chat/v1/model/message_file.py +46 -0
- dify_oapi/api/chat/v1/model/message_history_request.py +24 -24
- dify_oapi/api/chat/v1/model/message_history_response.py +4 -43
- dify_oapi/api/chat/v1/model/message_info.py +73 -0
- dify_oapi/api/chat/v1/model/pagination_info.py +44 -0
- dify_oapi/api/chat/v1/model/rename_conversation_request_body.py +1 -1
- dify_oapi/api/chat/v1/model/retriever_resource.py +64 -0
- dify_oapi/api/chat/v1/model/site_settings.py +92 -0
- dify_oapi/api/chat/v1/model/text_to_audio_response.py +7 -0
- dify_oapi/api/chat/v1/model/tool_icon.py +52 -0
- dify_oapi/api/chat/v1/model/update_annotation_request.py +34 -0
- dify_oapi/api/chat/v1/model/update_annotation_request_body.py +32 -0
- dify_oapi/api/chat/v1/model/update_annotation_response.py +9 -0
- dify_oapi/api/{completion/v1/model/file → chat/v1/model}/upload_file_request_body.py +9 -3
- dify_oapi/api/chat/v1/model/usage_info.py +84 -0
- dify_oapi/api/chat/v1/resource/__init__.py +1 -4
- dify_oapi/api/chat/v1/resource/annotation.py +87 -0
- dify_oapi/api/chat/v1/resource/chat.py +47 -25
- dify_oapi/api/chat/v1/resource/conversation.py +45 -33
- dify_oapi/api/chat/v1/resource/message.py +22 -20
- dify_oapi/api/chat/v1/version.py +18 -5
- dify_oapi/api/chatflow/__init__.py +0 -0
- dify_oapi/api/chatflow/service.py +8 -0
- dify_oapi/api/chatflow/v1/__init__.py +0 -0
- dify_oapi/api/chatflow/v1/model/__init__.py +0 -0
- dify_oapi/api/chatflow/v1/model/annotation_info.py +43 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_settings_request.py +37 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_settings_request_body.py +33 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_settings_response.py +10 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_status_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/annotation_reply_status_response.py +11 -0
- dify_oapi/api/chatflow/v1/model/app_info.py +33 -0
- dify_oapi/api/chatflow/v1/model/app_parameters.py +276 -0
- dify_oapi/api/chatflow/v1/model/chat_file.py +40 -0
- dify_oapi/api/chatflow/v1/model/chat_message.py +88 -0
- dify_oapi/api/chatflow/v1/model/chatflow_types.py +210 -0
- dify_oapi/api/chatflow/v1/model/conversation_info.py +53 -0
- dify_oapi/api/chatflow/v1/model/conversation_variable.py +55 -0
- dify_oapi/api/chatflow/v1/model/create_annotation_request.py +30 -0
- dify_oapi/api/chatflow/v1/model/create_annotation_request_body.py +28 -0
- dify_oapi/api/chatflow/v1/model/create_annotation_response.py +9 -0
- dify_oapi/api/chatflow/v1/model/delete_annotation_request.py +28 -0
- dify_oapi/api/chatflow/v1/model/delete_annotation_response.py +7 -0
- dify_oapi/api/chatflow/v1/model/delete_conversation_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/delete_conversation_request_body.py +21 -0
- dify_oapi/api/chatflow/v1/model/delete_conversation_response.py +17 -0
- dify_oapi/api/chatflow/v1/model/feedback_info.py +75 -0
- dify_oapi/api/chatflow/v1/model/file_info.py +53 -0
- dify_oapi/api/chatflow/v1/model/get_annotations_request.py +30 -0
- dify_oapi/api/chatflow/v1/model/get_annotations_response.py +13 -0
- dify_oapi/api/chatflow/v1/model/get_conversation_messages_request.py +38 -0
- dify_oapi/api/chatflow/v1/model/get_conversation_messages_response.py +33 -0
- dify_oapi/api/chatflow/v1/model/get_conversation_variables_request.py +44 -0
- dify_oapi/api/chatflow/v1/model/get_conversation_variables_response.py +33 -0
- dify_oapi/api/chatflow/v1/model/get_conversations_request.py +40 -0
- dify_oapi/api/chatflow/v1/model/get_conversations_response.py +33 -0
- dify_oapi/api/chatflow/v1/model/get_suggested_questions_request.py +32 -0
- dify_oapi/api/{completion/v1/model/feedback/message_feedback_response.py → chatflow/v1/model/get_suggested_questions_response.py} +2 -3
- dify_oapi/api/chatflow/v1/model/rename_conversation_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/rename_conversation_request_body.py +31 -0
- dify_oapi/api/chatflow/v1/model/rename_conversation_response.py +53 -0
- dify_oapi/api/chatflow/v1/model/retriever_resource.py +58 -0
- dify_oapi/api/chatflow/v1/model/send_chat_message_request.py +30 -0
- dify_oapi/api/chatflow/v1/model/send_chat_message_request_body.py +54 -0
- dify_oapi/api/chatflow/v1/model/send_chat_message_response.py +7 -0
- dify_oapi/api/chatflow/v1/model/stop_chat_message_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/stop_chat_message_request_body.py +21 -0
- dify_oapi/api/{dify/v1/model/message_feedback_response.py → chatflow/v1/model/stop_chat_message_response.py} +1 -1
- dify_oapi/api/chatflow/v1/model/tool_icon.py +48 -0
- dify_oapi/api/chatflow/v1/model/update_annotation_request.py +36 -0
- dify_oapi/api/chatflow/v1/model/update_annotation_request_body.py +28 -0
- dify_oapi/api/chatflow/v1/model/update_annotation_response.py +9 -0
- dify_oapi/api/chatflow/v1/model/usage_info.py +78 -0
- dify_oapi/api/chatflow/v1/model/user_input_form.py +141 -0
- dify_oapi/api/chatflow/v1/model/webapp_settings.py +88 -0
- dify_oapi/api/chatflow/v1/resource/__init__.py +0 -0
- dify_oapi/api/chatflow/v1/resource/annotation.py +87 -0
- dify_oapi/api/chatflow/v1/resource/chatflow.py +78 -0
- dify_oapi/api/chatflow/v1/resource/conversation.py +75 -0
- dify_oapi/api/chatflow/v1/version.py +22 -0
- dify_oapi/api/completion/v1/resource/__init__.py +0 -6
- dify_oapi/api/completion/v1/version.py +8 -6
- dify_oapi/api/{chat → dify}/v1/model/audio_to_text_request_body.py +2 -2
- dify_oapi/api/{completion/v1/model/feedback → dify/v1/model}/get_feedbacks_request.py +12 -12
- dify_oapi/api/dify/v1/model/get_feedbacks_response.py +26 -0
- dify_oapi/api/{workflow → dify}/v1/model/get_parameters_request.py +4 -0
- dify_oapi/api/dify/v1/model/{get_parameter_response.py → get_parameters_response.py} +6 -2
- dify_oapi/api/dify/v1/model/get_site_response.py +17 -0
- dify_oapi/api/dify/v1/model/submit_feedback_request.py +34 -0
- dify_oapi/api/dify/v1/model/submit_feedback_request_body.py +35 -0
- dify_oapi/api/dify/v1/model/submit_feedback_response.py +7 -0
- dify_oapi/api/dify/v1/resource/__init__.py +0 -6
- dify_oapi/api/dify/v1/resource/audio.py +12 -0
- dify_oapi/api/dify/v1/resource/feedback.py +31 -0
- dify_oapi/api/dify/v1/resource/info.py +34 -2
- dify_oapi/api/dify/v1/version.py +5 -4
- dify_oapi/api/knowledge/service.py +3 -3
- dify_oapi/api/knowledge/v1/model/create_document_by_file_request.py +1 -3
- dify_oapi/api/knowledge/v1/model/create_document_by_file_request_body.py +4 -46
- dify_oapi/api/knowledge/v1/model/create_document_by_file_request_body_data.py +73 -0
- dify_oapi/api/knowledge/v1/model/data_source_detail.py +23 -0
- dify_oapi/api/knowledge/v1/model/dataset_info.py +10 -9
- dify_oapi/api/knowledge/v1/model/dataset_metadata.py +14 -0
- dify_oapi/api/knowledge/v1/model/document_info.py +18 -6
- dify_oapi/api/knowledge/v1/model/external_knowledge_info.py +11 -1
- dify_oapi/api/knowledge/v1/model/external_retrieval_model.py +13 -0
- dify_oapi/api/knowledge/v1/model/knowledge_types.py +2 -2
- dify_oapi/api/knowledge/v1/model/process_rule.py +0 -6
- dify_oapi/api/knowledge/v1/model/retrieval_model.py +10 -4
- dify_oapi/api/knowledge/v1/model/update_document_by_file_request.py +1 -3
- dify_oapi/api/knowledge/v1/model/update_document_by_file_request_body.py +4 -41
- dify_oapi/api/knowledge/v1/model/update_document_by_file_request_body_data.py +68 -0
- dify_oapi/api/knowledge/v1/model/weights.py +27 -0
- dify_oapi/api/knowledge/v1/resource/__init__.py +0 -8
- dify_oapi/api/workflow/v1/model/chunk_workflow_event.py +74 -0
- dify_oapi/api/workflow/v1/model/input_file_object_workflow.py +76 -0
- dify_oapi/api/workflow/v1/model/node_finished_data.py +118 -0
- dify_oapi/api/workflow/v1/model/node_started_data.py +81 -0
- dify_oapi/api/workflow/v1/model/ping_data.py +28 -0
- dify_oapi/api/workflow/v1/model/run_workflow_request_body.py +1 -1
- dify_oapi/api/workflow/v1/model/text_chunk_data.py +39 -0
- dify_oapi/api/workflow/v1/model/tts_message_data.py +45 -0
- dify_oapi/api/workflow/v1/model/tts_message_end_data.py +45 -0
- dify_oapi/api/workflow/v1/model/workflow_completion_response.py +50 -0
- dify_oapi/api/workflow/v1/model/workflow_finished_data.py +93 -0
- dify_oapi/api/workflow/v1/model/workflow_started_data.py +51 -0
- dify_oapi/api/workflow/v1/model/workflow_types.py +27 -12
- dify_oapi/api/workflow/v1/resource/workflow.py +0 -34
- dify_oapi/api/workflow/v1/version.py +9 -0
- dify_oapi/client.py +49 -4
- dify_oapi/core/http/transport/__init__.py +2 -1
- dify_oapi/core/http/transport/async_transport.py +73 -50
- dify_oapi/core/http/transport/connection_pool.py +131 -0
- dify_oapi/core/http/transport/sync_transport.py +73 -50
- dify_oapi/core/model/config.py +10 -0
- dify_oapi2-1.0.0.dist-info/METADATA +365 -0
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-1.0.0.dist-info}/RECORD +174 -98
- dify_oapi/api/chat/v1/model/chat_request_file.py +0 -46
- dify_oapi/api/chat/v1/model/message_suggested_request.py +0 -36
- dify_oapi/api/chat/v1/resource/audio.py +0 -17
- dify_oapi/api/completion/v1/model/audio/audio_info.py +0 -28
- dify_oapi/api/completion/v1/model/audio/text_to_audio_request.py +0 -32
- dify_oapi/api/completion/v1/model/audio/text_to_audio_request_body.py +0 -33
- dify_oapi/api/completion/v1/model/audio/text_to_audio_response.py +0 -9
- dify_oapi/api/completion/v1/model/feedback/get_feedbacks_response.py +0 -9
- dify_oapi/api/completion/v1/model/feedback/message_feedback_request.py +0 -38
- dify_oapi/api/completion/v1/model/feedback/message_feedback_request_body.py +0 -35
- dify_oapi/api/completion/v1/model/file/upload_file_request.py +0 -42
- dify_oapi/api/completion/v1/model/file/upload_file_response.py +0 -9
- dify_oapi/api/completion/v1/model/info/feature_config.py +0 -91
- dify_oapi/api/completion/v1/model/info/file_upload_config.py +0 -23
- dify_oapi/api/completion/v1/model/info/get_info_request.py +0 -24
- dify_oapi/api/completion/v1/model/info/get_info_response.py +0 -9
- dify_oapi/api/completion/v1/model/info/get_parameters_request.py +0 -24
- dify_oapi/api/completion/v1/model/info/get_parameters_response.py +0 -9
- dify_oapi/api/completion/v1/model/info/get_site_response.py +0 -9
- dify_oapi/api/completion/v1/model/info/parameters_info.py +0 -75
- dify_oapi/api/completion/v1/model/info/site_info.py +0 -90
- dify_oapi/api/completion/v1/model/info/system_parameters.py +0 -38
- dify_oapi/api/completion/v1/model/info/user_input_form.py +0 -158
- dify_oapi/api/completion/v1/resource/audio.py +0 -19
- dify_oapi/api/completion/v1/resource/feedback.py +0 -33
- dify_oapi/api/completion/v1/resource/file.py +0 -19
- dify_oapi/api/completion/v1/resource/info.py +0 -39
- dify_oapi/api/dify/v1/model/get_parameter_request.py +0 -30
- dify_oapi/api/dify/v1/model/message_feedback_request.py +0 -38
- dify_oapi/api/dify/v1/model/message_feedback_request_body.py +0 -30
- dify_oapi/api/dify/v1/resource/message.py +0 -21
- dify_oapi/api/dify/v1/resource/meta.py +0 -17
- dify_oapi/api/dify/v1/resource/parameter.py +0 -19
- dify_oapi/api/workflow/v1/model/get_info_request.py +0 -24
- dify_oapi/api/workflow/v1/model/get_info_response.py +0 -9
- dify_oapi/api/workflow/v1/model/get_parameters_response.py +0 -9
- dify_oapi/api/workflow/v1/model/get_site_request.py +0 -24
- dify_oapi/api/workflow/v1/model/get_site_response.py +0 -9
- dify_oapi/api/workflow/v1/model/upload_file_request.py +0 -42
- dify_oapi/api/workflow/v1/model/upload_file_response.py +0 -9
- dify_oapi2-0.4.0.dist-info/METADATA +0 -303
- /dify_oapi/api/{chat → dify}/v1/model/audio_to_text_request.py +0 -0
- /dify_oapi/api/{chat → dify}/v1/model/audio_to_text_response.py +0 -0
- /dify_oapi/api/{completion/v1/model/info → dify/v1/model}/get_site_request.py +0 -0
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-1.0.0.dist-info}/LICENSE +0 -0
- {dify_oapi2-0.4.0.dist-info → dify_oapi2-1.0.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
"""Retriever resource model for Chat API."""
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from pydantic import BaseModel
|
6
|
+
|
7
|
+
|
8
|
+
class RetrieverResource(BaseModel):
|
9
|
+
"""Retriever resource model."""
|
10
|
+
|
11
|
+
position: int | None = None
|
12
|
+
dataset_id: str | None = None
|
13
|
+
dataset_name: str | None = None
|
14
|
+
document_id: str | None = None
|
15
|
+
document_name: str | None = None
|
16
|
+
segment_id: str | None = None
|
17
|
+
score: float | None = None
|
18
|
+
content: str | None = None
|
19
|
+
|
20
|
+
@staticmethod
|
21
|
+
def builder() -> RetrieverResourceBuilder:
|
22
|
+
return RetrieverResourceBuilder()
|
23
|
+
|
24
|
+
|
25
|
+
class RetrieverResourceBuilder:
|
26
|
+
"""Builder for RetrieverResource."""
|
27
|
+
|
28
|
+
def __init__(self):
|
29
|
+
self._retriever_resource = RetrieverResource()
|
30
|
+
|
31
|
+
def build(self) -> RetrieverResource:
|
32
|
+
return self._retriever_resource
|
33
|
+
|
34
|
+
def position(self, position: int) -> RetrieverResourceBuilder:
|
35
|
+
self._retriever_resource.position = position
|
36
|
+
return self
|
37
|
+
|
38
|
+
def dataset_id(self, dataset_id: str) -> RetrieverResourceBuilder:
|
39
|
+
self._retriever_resource.dataset_id = dataset_id
|
40
|
+
return self
|
41
|
+
|
42
|
+
def dataset_name(self, dataset_name: str) -> RetrieverResourceBuilder:
|
43
|
+
self._retriever_resource.dataset_name = dataset_name
|
44
|
+
return self
|
45
|
+
|
46
|
+
def document_id(self, document_id: str) -> RetrieverResourceBuilder:
|
47
|
+
self._retriever_resource.document_id = document_id
|
48
|
+
return self
|
49
|
+
|
50
|
+
def document_name(self, document_name: str) -> RetrieverResourceBuilder:
|
51
|
+
self._retriever_resource.document_name = document_name
|
52
|
+
return self
|
53
|
+
|
54
|
+
def segment_id(self, segment_id: str) -> RetrieverResourceBuilder:
|
55
|
+
self._retriever_resource.segment_id = segment_id
|
56
|
+
return self
|
57
|
+
|
58
|
+
def score(self, score: float) -> RetrieverResourceBuilder:
|
59
|
+
self._retriever_resource.score = score
|
60
|
+
return self
|
61
|
+
|
62
|
+
def content(self, content: str) -> RetrieverResourceBuilder:
|
63
|
+
self._retriever_resource.content = content
|
64
|
+
return self
|
@@ -0,0 +1,92 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from pydantic import BaseModel
|
4
|
+
|
5
|
+
from .chat_types import IconType
|
6
|
+
|
7
|
+
|
8
|
+
class SiteSettings(BaseModel):
|
9
|
+
"""Site settings configuration."""
|
10
|
+
|
11
|
+
title: str | None = None
|
12
|
+
chat_color_theme: str | None = None
|
13
|
+
chat_color_theme_inverted: bool | None = None
|
14
|
+
icon_type: IconType | None = None
|
15
|
+
icon: str | None = None
|
16
|
+
icon_background: str | None = None
|
17
|
+
icon_url: str | None = None
|
18
|
+
description: str | None = None
|
19
|
+
copyright: str | None = None
|
20
|
+
privacy_policy: str | None = None
|
21
|
+
custom_disclaimer: str | None = None
|
22
|
+
default_language: str | None = None
|
23
|
+
show_workflow_steps: bool | None = None
|
24
|
+
use_icon_as_answer_icon: bool | None = None
|
25
|
+
|
26
|
+
@staticmethod
|
27
|
+
def builder() -> SiteSettingsBuilder:
|
28
|
+
return SiteSettingsBuilder()
|
29
|
+
|
30
|
+
|
31
|
+
class SiteSettingsBuilder:
|
32
|
+
def __init__(self):
|
33
|
+
self._site_settings = SiteSettings()
|
34
|
+
|
35
|
+
def build(self) -> SiteSettings:
|
36
|
+
return self._site_settings
|
37
|
+
|
38
|
+
def title(self, title: str) -> SiteSettingsBuilder:
|
39
|
+
self._site_settings.title = title
|
40
|
+
return self
|
41
|
+
|
42
|
+
def chat_color_theme(self, chat_color_theme: str) -> SiteSettingsBuilder:
|
43
|
+
self._site_settings.chat_color_theme = chat_color_theme
|
44
|
+
return self
|
45
|
+
|
46
|
+
def chat_color_theme_inverted(self, chat_color_theme_inverted: bool) -> SiteSettingsBuilder:
|
47
|
+
self._site_settings.chat_color_theme_inverted = chat_color_theme_inverted
|
48
|
+
return self
|
49
|
+
|
50
|
+
def icon_type(self, icon_type: IconType) -> SiteSettingsBuilder:
|
51
|
+
self._site_settings.icon_type = icon_type
|
52
|
+
return self
|
53
|
+
|
54
|
+
def icon(self, icon: str) -> SiteSettingsBuilder:
|
55
|
+
self._site_settings.icon = icon
|
56
|
+
return self
|
57
|
+
|
58
|
+
def icon_background(self, icon_background: str) -> SiteSettingsBuilder:
|
59
|
+
self._site_settings.icon_background = icon_background
|
60
|
+
return self
|
61
|
+
|
62
|
+
def icon_url(self, icon_url: str) -> SiteSettingsBuilder:
|
63
|
+
self._site_settings.icon_url = icon_url
|
64
|
+
return self
|
65
|
+
|
66
|
+
def description(self, description: str) -> SiteSettingsBuilder:
|
67
|
+
self._site_settings.description = description
|
68
|
+
return self
|
69
|
+
|
70
|
+
def copyright(self, copyright: str) -> SiteSettingsBuilder:
|
71
|
+
self._site_settings.copyright = copyright
|
72
|
+
return self
|
73
|
+
|
74
|
+
def privacy_policy(self, privacy_policy: str) -> SiteSettingsBuilder:
|
75
|
+
self._site_settings.privacy_policy = privacy_policy
|
76
|
+
return self
|
77
|
+
|
78
|
+
def custom_disclaimer(self, custom_disclaimer: str) -> SiteSettingsBuilder:
|
79
|
+
self._site_settings.custom_disclaimer = custom_disclaimer
|
80
|
+
return self
|
81
|
+
|
82
|
+
def default_language(self, default_language: str) -> SiteSettingsBuilder:
|
83
|
+
self._site_settings.default_language = default_language
|
84
|
+
return self
|
85
|
+
|
86
|
+
def show_workflow_steps(self, show_workflow_steps: bool) -> SiteSettingsBuilder:
|
87
|
+
self._site_settings.show_workflow_steps = show_workflow_steps
|
88
|
+
return self
|
89
|
+
|
90
|
+
def use_icon_as_answer_icon(self, use_icon_as_answer_icon: bool) -> SiteSettingsBuilder:
|
91
|
+
self._site_settings.use_icon_as_answer_icon = use_icon_as_answer_icon
|
92
|
+
return self
|
@@ -0,0 +1,52 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from pydantic import BaseModel
|
4
|
+
|
5
|
+
|
6
|
+
class ToolIconDetail(BaseModel):
|
7
|
+
"""Tool icon detail configuration."""
|
8
|
+
|
9
|
+
background: str
|
10
|
+
content: str
|
11
|
+
|
12
|
+
@staticmethod
|
13
|
+
def builder() -> ToolIconDetailBuilder:
|
14
|
+
return ToolIconDetailBuilder()
|
15
|
+
|
16
|
+
|
17
|
+
class ToolIconDetailBuilder:
|
18
|
+
def __init__(self):
|
19
|
+
self._tool_icon_detail = ToolIconDetail(background="", content="")
|
20
|
+
|
21
|
+
def build(self) -> ToolIconDetail:
|
22
|
+
return self._tool_icon_detail
|
23
|
+
|
24
|
+
def background(self, background: str) -> ToolIconDetailBuilder:
|
25
|
+
self._tool_icon_detail.background = background
|
26
|
+
return self
|
27
|
+
|
28
|
+
def content(self, content: str) -> ToolIconDetailBuilder:
|
29
|
+
self._tool_icon_detail.content = content
|
30
|
+
return self
|
31
|
+
|
32
|
+
|
33
|
+
class ToolIcon(BaseModel):
|
34
|
+
"""Tool icon configuration."""
|
35
|
+
|
36
|
+
tool_icons: dict[str, str | ToolIconDetail] | None = None
|
37
|
+
|
38
|
+
@staticmethod
|
39
|
+
def builder() -> ToolIconBuilder:
|
40
|
+
return ToolIconBuilder()
|
41
|
+
|
42
|
+
|
43
|
+
class ToolIconBuilder:
|
44
|
+
def __init__(self):
|
45
|
+
self._tool_icon = ToolIcon()
|
46
|
+
|
47
|
+
def build(self) -> ToolIcon:
|
48
|
+
return self._tool_icon
|
49
|
+
|
50
|
+
def tool_icons(self, tool_icons: dict[str, str | ToolIconDetail]) -> ToolIconBuilder:
|
51
|
+
self._tool_icon.tool_icons = tool_icons
|
52
|
+
return self
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from dify_oapi.core.enum import HttpMethod
|
2
|
+
from dify_oapi.core.model.base_request import BaseRequest
|
3
|
+
|
4
|
+
from .update_annotation_request_body import UpdateAnnotationRequestBody
|
5
|
+
|
6
|
+
|
7
|
+
class UpdateAnnotationRequest(BaseRequest):
|
8
|
+
def __init__(self) -> None:
|
9
|
+
super().__init__()
|
10
|
+
self.request_body: UpdateAnnotationRequestBody | None = None
|
11
|
+
|
12
|
+
@staticmethod
|
13
|
+
def builder() -> "UpdateAnnotationRequestBuilder":
|
14
|
+
return UpdateAnnotationRequestBuilder()
|
15
|
+
|
16
|
+
|
17
|
+
class UpdateAnnotationRequestBuilder:
|
18
|
+
def __init__(self) -> None:
|
19
|
+
update_annotation_request = UpdateAnnotationRequest()
|
20
|
+
update_annotation_request.http_method = HttpMethod.PUT
|
21
|
+
update_annotation_request.uri = "/v1/apps/annotations/:annotation_id"
|
22
|
+
self._update_annotation_request = update_annotation_request
|
23
|
+
|
24
|
+
def annotation_id(self, annotation_id: str) -> "UpdateAnnotationRequestBuilder":
|
25
|
+
self._update_annotation_request.paths["annotation_id"] = annotation_id
|
26
|
+
return self
|
27
|
+
|
28
|
+
def request_body(self, request_body: UpdateAnnotationRequestBody) -> "UpdateAnnotationRequestBuilder":
|
29
|
+
self._update_annotation_request.request_body = request_body
|
30
|
+
self._update_annotation_request.body = request_body.model_dump(exclude_none=True, mode="json")
|
31
|
+
return self
|
32
|
+
|
33
|
+
def build(self) -> UpdateAnnotationRequest:
|
34
|
+
return self._update_annotation_request
|
@@ -0,0 +1,32 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from pydantic import BaseModel
|
4
|
+
|
5
|
+
|
6
|
+
class UpdateAnnotationRequestBody(BaseModel):
|
7
|
+
"""Request body for updating annotation."""
|
8
|
+
|
9
|
+
question: str = ""
|
10
|
+
answer: str = ""
|
11
|
+
|
12
|
+
@staticmethod
|
13
|
+
def builder() -> UpdateAnnotationRequestBodyBuilder:
|
14
|
+
return UpdateAnnotationRequestBodyBuilder()
|
15
|
+
|
16
|
+
|
17
|
+
class UpdateAnnotationRequestBodyBuilder:
|
18
|
+
"""Builder for UpdateAnnotationRequestBody."""
|
19
|
+
|
20
|
+
def __init__(self):
|
21
|
+
self._update_annotation_request_body = UpdateAnnotationRequestBody()
|
22
|
+
|
23
|
+
def build(self) -> UpdateAnnotationRequestBody:
|
24
|
+
return self._update_annotation_request_body
|
25
|
+
|
26
|
+
def question(self, question: str) -> UpdateAnnotationRequestBodyBuilder:
|
27
|
+
self._update_annotation_request_body.question = question
|
28
|
+
return self
|
29
|
+
|
30
|
+
def answer(self, answer: str) -> UpdateAnnotationRequestBodyBuilder:
|
31
|
+
self._update_annotation_request_body.answer = answer
|
32
|
+
return self
|
@@ -1,10 +1,14 @@
|
|
1
|
+
"""Upload file request body model."""
|
2
|
+
|
1
3
|
from __future__ import annotations
|
2
4
|
|
3
5
|
from pydantic import BaseModel
|
4
6
|
|
5
7
|
|
6
8
|
class UploadFileRequestBody(BaseModel):
|
7
|
-
|
9
|
+
"""Request body for upload file API."""
|
10
|
+
|
11
|
+
user: str
|
8
12
|
|
9
13
|
@staticmethod
|
10
14
|
def builder() -> UploadFileRequestBodyBuilder:
|
@@ -12,8 +16,10 @@ class UploadFileRequestBody(BaseModel):
|
|
12
16
|
|
13
17
|
|
14
18
|
class UploadFileRequestBodyBuilder:
|
15
|
-
|
16
|
-
|
19
|
+
"""Builder for UploadFileRequestBody."""
|
20
|
+
|
21
|
+
def __init__(self) -> None:
|
22
|
+
self._upload_file_request_body = UploadFileRequestBody(user="")
|
17
23
|
|
18
24
|
def build(self) -> UploadFileRequestBody:
|
19
25
|
return self._upload_file_request_body
|
@@ -0,0 +1,84 @@
|
|
1
|
+
"""Usage information model for Chat API."""
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from pydantic import BaseModel
|
6
|
+
|
7
|
+
|
8
|
+
class UsageInfo(BaseModel):
|
9
|
+
"""Usage information model."""
|
10
|
+
|
11
|
+
prompt_tokens: int | None = None
|
12
|
+
prompt_unit_price: str | None = None
|
13
|
+
prompt_price_unit: str | None = None
|
14
|
+
prompt_price: str | None = None
|
15
|
+
completion_tokens: int | None = None
|
16
|
+
completion_unit_price: str | None = None
|
17
|
+
completion_price_unit: str | None = None
|
18
|
+
completion_price: str | None = None
|
19
|
+
total_tokens: int | None = None
|
20
|
+
total_price: str | None = None
|
21
|
+
currency: str | None = None
|
22
|
+
latency: float | None = None
|
23
|
+
|
24
|
+
@staticmethod
|
25
|
+
def builder() -> UsageInfoBuilder:
|
26
|
+
return UsageInfoBuilder()
|
27
|
+
|
28
|
+
|
29
|
+
class UsageInfoBuilder:
|
30
|
+
"""Builder for UsageInfo."""
|
31
|
+
|
32
|
+
def __init__(self):
|
33
|
+
self._usage_info = UsageInfo()
|
34
|
+
|
35
|
+
def build(self) -> UsageInfo:
|
36
|
+
return self._usage_info
|
37
|
+
|
38
|
+
def prompt_tokens(self, prompt_tokens: int) -> UsageInfoBuilder:
|
39
|
+
self._usage_info.prompt_tokens = prompt_tokens
|
40
|
+
return self
|
41
|
+
|
42
|
+
def prompt_unit_price(self, prompt_unit_price: str) -> UsageInfoBuilder:
|
43
|
+
self._usage_info.prompt_unit_price = prompt_unit_price
|
44
|
+
return self
|
45
|
+
|
46
|
+
def prompt_price_unit(self, prompt_price_unit: str) -> UsageInfoBuilder:
|
47
|
+
self._usage_info.prompt_price_unit = prompt_price_unit
|
48
|
+
return self
|
49
|
+
|
50
|
+
def prompt_price(self, prompt_price: str) -> UsageInfoBuilder:
|
51
|
+
self._usage_info.prompt_price = prompt_price
|
52
|
+
return self
|
53
|
+
|
54
|
+
def completion_tokens(self, completion_tokens: int) -> UsageInfoBuilder:
|
55
|
+
self._usage_info.completion_tokens = completion_tokens
|
56
|
+
return self
|
57
|
+
|
58
|
+
def completion_unit_price(self, completion_unit_price: str) -> UsageInfoBuilder:
|
59
|
+
self._usage_info.completion_unit_price = completion_unit_price
|
60
|
+
return self
|
61
|
+
|
62
|
+
def completion_price_unit(self, completion_price_unit: str) -> UsageInfoBuilder:
|
63
|
+
self._usage_info.completion_price_unit = completion_price_unit
|
64
|
+
return self
|
65
|
+
|
66
|
+
def completion_price(self, completion_price: str) -> UsageInfoBuilder:
|
67
|
+
self._usage_info.completion_price = completion_price
|
68
|
+
return self
|
69
|
+
|
70
|
+
def total_tokens(self, total_tokens: int) -> UsageInfoBuilder:
|
71
|
+
self._usage_info.total_tokens = total_tokens
|
72
|
+
return self
|
73
|
+
|
74
|
+
def total_price(self, total_price: str) -> UsageInfoBuilder:
|
75
|
+
self._usage_info.total_price = total_price
|
76
|
+
return self
|
77
|
+
|
78
|
+
def currency(self, currency: str) -> UsageInfoBuilder:
|
79
|
+
self._usage_info.currency = currency
|
80
|
+
return self
|
81
|
+
|
82
|
+
def latency(self, latency: float) -> UsageInfoBuilder:
|
83
|
+
self._usage_info.latency = latency
|
84
|
+
return self
|
@@ -0,0 +1,87 @@
|
|
1
|
+
from dify_oapi.core.http.transport import ATransport, Transport
|
2
|
+
from dify_oapi.core.model.config import Config
|
3
|
+
from dify_oapi.core.model.request_option import RequestOption
|
4
|
+
|
5
|
+
from ..model.configure_annotation_reply_request import ConfigureAnnotationReplyRequest
|
6
|
+
from ..model.configure_annotation_reply_response import ConfigureAnnotationReplyResponse
|
7
|
+
from ..model.create_annotation_request import CreateAnnotationRequest
|
8
|
+
from ..model.create_annotation_response import CreateAnnotationResponse
|
9
|
+
from ..model.delete_annotation_request import DeleteAnnotationRequest
|
10
|
+
from ..model.delete_annotation_response import DeleteAnnotationResponse
|
11
|
+
from ..model.get_annotation_reply_status_request import GetAnnotationReplyStatusRequest
|
12
|
+
from ..model.get_annotation_reply_status_response import GetAnnotationReplyStatusResponse
|
13
|
+
from ..model.list_annotations_request import ListAnnotationsRequest
|
14
|
+
from ..model.list_annotations_response import ListAnnotationsResponse
|
15
|
+
from ..model.update_annotation_request import UpdateAnnotationRequest
|
16
|
+
from ..model.update_annotation_response import UpdateAnnotationResponse
|
17
|
+
|
18
|
+
|
19
|
+
class Annotation:
|
20
|
+
def __init__(self, config: Config) -> None:
|
21
|
+
self.config = config
|
22
|
+
|
23
|
+
def list(self, request: ListAnnotationsRequest, request_option: RequestOption) -> ListAnnotationsResponse:
|
24
|
+
return Transport.execute(self.config, request, unmarshal_as=ListAnnotationsResponse, option=request_option)
|
25
|
+
|
26
|
+
async def alist(self, request: ListAnnotationsRequest, request_option: RequestOption) -> ListAnnotationsResponse:
|
27
|
+
return await ATransport.aexecute(
|
28
|
+
self.config, request, unmarshal_as=ListAnnotationsResponse, option=request_option
|
29
|
+
)
|
30
|
+
|
31
|
+
def create(self, request: CreateAnnotationRequest, request_option: RequestOption) -> CreateAnnotationResponse:
|
32
|
+
return Transport.execute(self.config, request, unmarshal_as=CreateAnnotationResponse, option=request_option)
|
33
|
+
|
34
|
+
async def acreate(
|
35
|
+
self, request: CreateAnnotationRequest, request_option: RequestOption
|
36
|
+
) -> CreateAnnotationResponse:
|
37
|
+
return await ATransport.aexecute(
|
38
|
+
self.config, request, unmarshal_as=CreateAnnotationResponse, option=request_option
|
39
|
+
)
|
40
|
+
|
41
|
+
def update(self, request: UpdateAnnotationRequest, request_option: RequestOption) -> UpdateAnnotationResponse:
|
42
|
+
return Transport.execute(self.config, request, unmarshal_as=UpdateAnnotationResponse, option=request_option)
|
43
|
+
|
44
|
+
async def aupdate(
|
45
|
+
self, request: UpdateAnnotationRequest, request_option: RequestOption
|
46
|
+
) -> UpdateAnnotationResponse:
|
47
|
+
return await ATransport.aexecute(
|
48
|
+
self.config, request, unmarshal_as=UpdateAnnotationResponse, option=request_option
|
49
|
+
)
|
50
|
+
|
51
|
+
def delete(self, request: DeleteAnnotationRequest, request_option: RequestOption) -> DeleteAnnotationResponse:
|
52
|
+
return Transport.execute(self.config, request, unmarshal_as=DeleteAnnotationResponse, option=request_option)
|
53
|
+
|
54
|
+
async def adelete(
|
55
|
+
self, request: DeleteAnnotationRequest, request_option: RequestOption
|
56
|
+
) -> DeleteAnnotationResponse:
|
57
|
+
return await ATransport.aexecute(
|
58
|
+
self.config, request, unmarshal_as=DeleteAnnotationResponse, option=request_option
|
59
|
+
)
|
60
|
+
|
61
|
+
def configure(
|
62
|
+
self, request: ConfigureAnnotationReplyRequest, request_option: RequestOption
|
63
|
+
) -> ConfigureAnnotationReplyResponse:
|
64
|
+
return Transport.execute(
|
65
|
+
self.config, request, unmarshal_as=ConfigureAnnotationReplyResponse, option=request_option
|
66
|
+
)
|
67
|
+
|
68
|
+
async def aconfigure(
|
69
|
+
self, request: ConfigureAnnotationReplyRequest, request_option: RequestOption
|
70
|
+
) -> ConfigureAnnotationReplyResponse:
|
71
|
+
return await ATransport.aexecute(
|
72
|
+
self.config, request, unmarshal_as=ConfigureAnnotationReplyResponse, option=request_option
|
73
|
+
)
|
74
|
+
|
75
|
+
def status(
|
76
|
+
self, request: GetAnnotationReplyStatusRequest, request_option: RequestOption
|
77
|
+
) -> GetAnnotationReplyStatusResponse:
|
78
|
+
return Transport.execute(
|
79
|
+
self.config, request, unmarshal_as=GetAnnotationReplyStatusResponse, option=request_option
|
80
|
+
)
|
81
|
+
|
82
|
+
async def astatus(
|
83
|
+
self, request: GetAnnotationReplyStatusRequest, request_option: RequestOption
|
84
|
+
) -> GetAnnotationReplyStatusResponse:
|
85
|
+
return await ATransport.aexecute(
|
86
|
+
self.config, request, unmarshal_as=GetAnnotationReplyStatusResponse, option=request_option
|
87
|
+
)
|
@@ -7,62 +7,84 @@ from dify_oapi.core.model.request_option import RequestOption
|
|
7
7
|
|
8
8
|
from ..model.chat_request import ChatRequest
|
9
9
|
from ..model.chat_response import ChatResponse
|
10
|
+
from ..model.get_suggested_questions_request import GetSuggestedQuestionsRequest
|
11
|
+
from ..model.get_suggested_questions_response import GetSuggestedQuestionsResponse
|
10
12
|
from ..model.stop_chat_request import StopChatRequest
|
11
13
|
from ..model.stop_chat_response import StopChatResponse
|
12
14
|
|
13
15
|
|
14
16
|
class Chat:
|
15
17
|
def __init__(self, config: Config) -> None:
|
16
|
-
self.config
|
18
|
+
self.config = config
|
17
19
|
|
18
20
|
@overload
|
19
21
|
def chat(
|
20
|
-
self,
|
22
|
+
self,
|
23
|
+
request: ChatRequest,
|
24
|
+
request_option: RequestOption,
|
25
|
+
stream: Literal[True],
|
21
26
|
) -> Generator[bytes, None, None]: ...
|
22
27
|
|
23
28
|
@overload
|
24
|
-
def chat(
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
def chat(
|
30
|
+
self,
|
31
|
+
request: ChatRequest,
|
32
|
+
request_option: RequestOption,
|
33
|
+
stream: Literal[False] = False,
|
34
|
+
) -> ChatResponse: ...
|
28
35
|
|
29
36
|
def chat(
|
30
37
|
self,
|
31
38
|
request: ChatRequest,
|
32
|
-
|
39
|
+
request_option: RequestOption,
|
33
40
|
stream: bool = False,
|
34
|
-
):
|
41
|
+
) -> ChatResponse | Generator[bytes, None, None]:
|
35
42
|
if stream:
|
36
|
-
return Transport.execute(self.config, request,
|
37
|
-
|
38
|
-
return Transport.execute(self.config, request, unmarshal_as=ChatResponse, option=option)
|
43
|
+
return Transport.execute(self.config, request, stream=True, option=request_option)
|
44
|
+
return Transport.execute(self.config, request, unmarshal_as=ChatResponse, option=request_option)
|
39
45
|
|
40
46
|
@overload
|
41
47
|
async def achat(
|
42
|
-
self,
|
48
|
+
self,
|
49
|
+
request: ChatRequest,
|
50
|
+
request_option: RequestOption,
|
51
|
+
stream: Literal[True],
|
43
52
|
) -> AsyncGenerator[bytes, None]: ...
|
44
53
|
|
45
54
|
@overload
|
46
55
|
async def achat(
|
47
|
-
self,
|
56
|
+
self,
|
57
|
+
request: ChatRequest,
|
58
|
+
request_option: RequestOption,
|
59
|
+
stream: Literal[False] = False,
|
48
60
|
) -> ChatResponse: ...
|
49
61
|
|
50
|
-
@overload
|
51
|
-
async def achat(self, request: ChatRequest, option: RequestOption | None) -> ChatResponse: ...
|
52
|
-
|
53
62
|
async def achat(
|
54
63
|
self,
|
55
64
|
request: ChatRequest,
|
56
|
-
|
65
|
+
request_option: RequestOption,
|
57
66
|
stream: bool = False,
|
58
|
-
):
|
67
|
+
) -> ChatResponse | AsyncGenerator[bytes, None]:
|
59
68
|
if stream:
|
60
|
-
return await ATransport.aexecute(self.config, request,
|
61
|
-
|
62
|
-
|
69
|
+
return await ATransport.aexecute(self.config, request, stream=True, option=request_option)
|
70
|
+
return await ATransport.aexecute(self.config, request, unmarshal_as=ChatResponse, option=request_option)
|
71
|
+
|
72
|
+
def stop(self, request: StopChatRequest, request_option: RequestOption) -> StopChatResponse:
|
73
|
+
return Transport.execute(self.config, request, unmarshal_as=StopChatResponse, option=request_option)
|
74
|
+
|
75
|
+
async def astop(self, request: StopChatRequest, request_option: RequestOption) -> StopChatResponse:
|
76
|
+
return await ATransport.aexecute(self.config, request, unmarshal_as=StopChatResponse, option=request_option)
|
63
77
|
|
64
|
-
def
|
65
|
-
|
78
|
+
def suggested(
|
79
|
+
self, request: GetSuggestedQuestionsRequest, request_option: RequestOption
|
80
|
+
) -> GetSuggestedQuestionsResponse:
|
81
|
+
return Transport.execute(
|
82
|
+
self.config, request, unmarshal_as=GetSuggestedQuestionsResponse, option=request_option
|
83
|
+
)
|
66
84
|
|
67
|
-
async def
|
68
|
-
|
85
|
+
async def asuggested(
|
86
|
+
self, request: GetSuggestedQuestionsRequest, request_option: RequestOption
|
87
|
+
) -> GetSuggestedQuestionsResponse:
|
88
|
+
return await ATransport.aexecute(
|
89
|
+
self.config, request, unmarshal_as=GetSuggestedQuestionsResponse, option=request_option
|
90
|
+
)
|