huaweicloudsdkversatile 3.1.184__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.
- huaweicloudsdkversatile/__init__.py +0 -0
- huaweicloudsdkversatile/v1/__init__.py +32 -0
- huaweicloudsdkversatile/v1/model/__init__.py +29 -0
- huaweicloudsdkversatile/v1/model/agent_run_req.py +302 -0
- huaweicloudsdkversatile/v1/model/conversation.py +129 -0
- huaweicloudsdkversatile/v1/model/feedback_reason.py +136 -0
- huaweicloudsdkversatile/v1/model/knowledge_base_retrieval_req.py +251 -0
- huaweicloudsdkversatile/v1/model/message.py +506 -0
- huaweicloudsdkversatile/v1/model/node_message.py +282 -0
- huaweicloudsdkversatile/v1/model/node_run_info.py +709 -0
- huaweicloudsdkversatile/v1/model/node_run_info_inner_error.py +133 -0
- huaweicloudsdkversatile/v1/model/node_run_info_inner_error_error_body.py +137 -0
- huaweicloudsdkversatile/v1/model/plugin_config.py +137 -0
- huaweicloudsdkversatile/v1/model/retrieval_result_info.py +282 -0
- huaweicloudsdkversatile/v1/model/run_agent_request.py +276 -0
- huaweicloudsdkversatile/v1/model/run_agent_response.py +378 -0
- huaweicloudsdkversatile/v1/model/run_workflow_request.py +247 -0
- huaweicloudsdkversatile/v1/model/run_workflow_response.py +378 -0
- huaweicloudsdkversatile/v1/model/search_knowledge_base_request.py +104 -0
- huaweicloudsdkversatile/v1/model/search_knowledge_base_response.py +141 -0
- huaweicloudsdkversatile/v1/model/status.py +135 -0
- huaweicloudsdkversatile/v1/model/upload_agent_file_request.py +190 -0
- huaweicloudsdkversatile/v1/model/upload_agent_file_request_body.py +107 -0
- huaweicloudsdkversatile/v1/model/upload_agent_file_response.py +170 -0
- huaweicloudsdkversatile/v1/model/user_profile.py +137 -0
- huaweicloudsdkversatile/v1/model/workflow_run_req.py +344 -0
- huaweicloudsdkversatile/v1/model/workflow_run_stream_rsp.py +195 -0
- huaweicloudsdkversatile/v1/region/__init__.py +0 -0
- huaweicloudsdkversatile/v1/region/versatile_region.py +31 -0
- huaweicloudsdkversatile/v1/versatile_async_client.py +378 -0
- huaweicloudsdkversatile/v1/versatile_client.py +375 -0
- huaweicloudsdkversatile-3.1.184.dist-info/METADATA +25 -0
- huaweicloudsdkversatile-3.1.184.dist-info/RECORD +35 -0
- huaweicloudsdkversatile-3.1.184.dist-info/WHEEL +4 -0
- huaweicloudsdkversatile-3.1.184.dist-info/licenses/LICENSE +13 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
from huaweicloudsdkcore.utils.http_utils import sanitize_for_serialization
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class WorkflowRunStreamRsp:
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
Attributes:
|
|
10
|
+
openapi_types (dict): The key is attribute name
|
|
11
|
+
and the value is attribute type.
|
|
12
|
+
attribute_map (dict): The key is attribute name
|
|
13
|
+
and the value is json key in definition.
|
|
14
|
+
"""
|
|
15
|
+
sensitive_list = []
|
|
16
|
+
|
|
17
|
+
openapi_types = {
|
|
18
|
+
'event': 'str',
|
|
19
|
+
'conversation_id': 'str',
|
|
20
|
+
'data': 'object',
|
|
21
|
+
'created_time': 'int'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
attribute_map = {
|
|
25
|
+
'event': 'event',
|
|
26
|
+
'conversation_id': 'conversation_id',
|
|
27
|
+
'data': 'data',
|
|
28
|
+
'created_time': 'createdTime'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def __init__(self, event=None, conversation_id=None, data=None, created_time=None):
|
|
32
|
+
r"""WorkflowRunStreamRsp
|
|
33
|
+
|
|
34
|
+
The model defined in huaweicloud sdk
|
|
35
|
+
|
|
36
|
+
:param event: 事件类型:1、workflow_started 2、node_started 3、node_wait 4、node_finished 5、workflow_finished 6、text_chunk :流式输出到对话框的信息
|
|
37
|
+
:type event: str
|
|
38
|
+
:param conversation_id: 执行的conversation_id
|
|
39
|
+
:type conversation_id: str
|
|
40
|
+
:param data: 类型说明:1. node_started,node_finished,node_wait data使用NodeInfo对象 2. workflow_started, workflow_finished data使用 WorkflowInfo对象 3. text_chunk使用对象TextChunk
|
|
41
|
+
:type data: object
|
|
42
|
+
:param created_time: 事件发生时间
|
|
43
|
+
:type created_time: int
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
self._event = None
|
|
49
|
+
self._conversation_id = None
|
|
50
|
+
self._data = None
|
|
51
|
+
self._created_time = None
|
|
52
|
+
self.discriminator = None
|
|
53
|
+
|
|
54
|
+
if event is not None:
|
|
55
|
+
self.event = event
|
|
56
|
+
if conversation_id is not None:
|
|
57
|
+
self.conversation_id = conversation_id
|
|
58
|
+
if data is not None:
|
|
59
|
+
self.data = data
|
|
60
|
+
if created_time is not None:
|
|
61
|
+
self.created_time = created_time
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def event(self):
|
|
65
|
+
r"""Gets the event of this WorkflowRunStreamRsp.
|
|
66
|
+
|
|
67
|
+
事件类型:1、workflow_started 2、node_started 3、node_wait 4、node_finished 5、workflow_finished 6、text_chunk :流式输出到对话框的信息
|
|
68
|
+
|
|
69
|
+
:return: The event of this WorkflowRunStreamRsp.
|
|
70
|
+
:rtype: str
|
|
71
|
+
"""
|
|
72
|
+
return self._event
|
|
73
|
+
|
|
74
|
+
@event.setter
|
|
75
|
+
def event(self, event):
|
|
76
|
+
r"""Sets the event of this WorkflowRunStreamRsp.
|
|
77
|
+
|
|
78
|
+
事件类型:1、workflow_started 2、node_started 3、node_wait 4、node_finished 5、workflow_finished 6、text_chunk :流式输出到对话框的信息
|
|
79
|
+
|
|
80
|
+
:param event: The event of this WorkflowRunStreamRsp.
|
|
81
|
+
:type event: str
|
|
82
|
+
"""
|
|
83
|
+
self._event = event
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def conversation_id(self):
|
|
87
|
+
r"""Gets the conversation_id of this WorkflowRunStreamRsp.
|
|
88
|
+
|
|
89
|
+
执行的conversation_id
|
|
90
|
+
|
|
91
|
+
:return: The conversation_id of this WorkflowRunStreamRsp.
|
|
92
|
+
:rtype: str
|
|
93
|
+
"""
|
|
94
|
+
return self._conversation_id
|
|
95
|
+
|
|
96
|
+
@conversation_id.setter
|
|
97
|
+
def conversation_id(self, conversation_id):
|
|
98
|
+
r"""Sets the conversation_id of this WorkflowRunStreamRsp.
|
|
99
|
+
|
|
100
|
+
执行的conversation_id
|
|
101
|
+
|
|
102
|
+
:param conversation_id: The conversation_id of this WorkflowRunStreamRsp.
|
|
103
|
+
:type conversation_id: str
|
|
104
|
+
"""
|
|
105
|
+
self._conversation_id = conversation_id
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def data(self):
|
|
109
|
+
r"""Gets the data of this WorkflowRunStreamRsp.
|
|
110
|
+
|
|
111
|
+
类型说明:1. node_started,node_finished,node_wait data使用NodeInfo对象 2. workflow_started, workflow_finished data使用 WorkflowInfo对象 3. text_chunk使用对象TextChunk
|
|
112
|
+
|
|
113
|
+
:return: The data of this WorkflowRunStreamRsp.
|
|
114
|
+
:rtype: object
|
|
115
|
+
"""
|
|
116
|
+
return self._data
|
|
117
|
+
|
|
118
|
+
@data.setter
|
|
119
|
+
def data(self, data):
|
|
120
|
+
r"""Sets the data of this WorkflowRunStreamRsp.
|
|
121
|
+
|
|
122
|
+
类型说明:1. node_started,node_finished,node_wait data使用NodeInfo对象 2. workflow_started, workflow_finished data使用 WorkflowInfo对象 3. text_chunk使用对象TextChunk
|
|
123
|
+
|
|
124
|
+
:param data: The data of this WorkflowRunStreamRsp.
|
|
125
|
+
:type data: object
|
|
126
|
+
"""
|
|
127
|
+
self._data = data
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def created_time(self):
|
|
131
|
+
r"""Gets the created_time of this WorkflowRunStreamRsp.
|
|
132
|
+
|
|
133
|
+
事件发生时间
|
|
134
|
+
|
|
135
|
+
:return: The created_time of this WorkflowRunStreamRsp.
|
|
136
|
+
:rtype: int
|
|
137
|
+
"""
|
|
138
|
+
return self._created_time
|
|
139
|
+
|
|
140
|
+
@created_time.setter
|
|
141
|
+
def created_time(self, created_time):
|
|
142
|
+
r"""Sets the created_time of this WorkflowRunStreamRsp.
|
|
143
|
+
|
|
144
|
+
事件发生时间
|
|
145
|
+
|
|
146
|
+
:param created_time: The created_time of this WorkflowRunStreamRsp.
|
|
147
|
+
:type created_time: int
|
|
148
|
+
"""
|
|
149
|
+
self._created_time = created_time
|
|
150
|
+
|
|
151
|
+
def to_dict(self):
|
|
152
|
+
result = {}
|
|
153
|
+
|
|
154
|
+
for attr, _ in self.openapi_types.items():
|
|
155
|
+
value = getattr(self, attr)
|
|
156
|
+
if isinstance(value, list):
|
|
157
|
+
result[attr] = list(map(
|
|
158
|
+
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
|
159
|
+
value
|
|
160
|
+
))
|
|
161
|
+
elif hasattr(value, "to_dict"):
|
|
162
|
+
result[attr] = value.to_dict()
|
|
163
|
+
elif isinstance(value, dict):
|
|
164
|
+
result[attr] = dict(map(
|
|
165
|
+
lambda item: (item[0], item[1].to_dict())
|
|
166
|
+
if hasattr(item[1], "to_dict") else item,
|
|
167
|
+
value.items()
|
|
168
|
+
))
|
|
169
|
+
else:
|
|
170
|
+
if attr in self.sensitive_list:
|
|
171
|
+
result[attr] = "****"
|
|
172
|
+
else:
|
|
173
|
+
result[attr] = value
|
|
174
|
+
|
|
175
|
+
return result
|
|
176
|
+
|
|
177
|
+
def to_str(self):
|
|
178
|
+
"""Returns the string representation of the model"""
|
|
179
|
+
import simplejson as json
|
|
180
|
+
return json.dumps(sanitize_for_serialization(self), ensure_ascii=False)
|
|
181
|
+
|
|
182
|
+
def __repr__(self):
|
|
183
|
+
"""For `print`"""
|
|
184
|
+
return self.to_str()
|
|
185
|
+
|
|
186
|
+
def __eq__(self, other):
|
|
187
|
+
"""Returns true if both objects are equal"""
|
|
188
|
+
if not isinstance(other, WorkflowRunStreamRsp):
|
|
189
|
+
return False
|
|
190
|
+
|
|
191
|
+
return self.__dict__ == other.__dict__
|
|
192
|
+
|
|
193
|
+
def __ne__(self, other):
|
|
194
|
+
"""Returns true if both objects are not equal"""
|
|
195
|
+
return not self == other
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
from huaweicloudsdkcore.region.region import Region
|
|
4
|
+
from huaweicloudsdkcore.region.provider import RegionProviderChain
|
|
5
|
+
|
|
6
|
+
class VersatileRegion:
|
|
7
|
+
_PROVIDER = RegionProviderChain.get_default_region_provider_chain("VERSATILE")
|
|
8
|
+
|
|
9
|
+
CN_NORTH_4 = Region("cn-north-4",
|
|
10
|
+
"https://versatile.cn-north-4.myhuaweicloud.com")
|
|
11
|
+
|
|
12
|
+
static_fields = {
|
|
13
|
+
"cn-north-4": CN_NORTH_4,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def value_of(cls, region_id, static_fields=None):
|
|
18
|
+
if not region_id:
|
|
19
|
+
raise KeyError("Unexpected empty parameter: region_id")
|
|
20
|
+
|
|
21
|
+
fields = static_fields or cls.static_fields
|
|
22
|
+
|
|
23
|
+
region = cls._PROVIDER.get_region(region_id)
|
|
24
|
+
if region:
|
|
25
|
+
return region
|
|
26
|
+
|
|
27
|
+
if region_id in fields:
|
|
28
|
+
return fields.get(region_id)
|
|
29
|
+
|
|
30
|
+
raise KeyError("region_id '%s' is not in the following supported regions of service 'Versatile': [%s]" % (
|
|
31
|
+
region_id, ", ".join(sorted(fields.keys()))))
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
from __future__ import absolute_import
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import warnings
|
|
7
|
+
|
|
8
|
+
from huaweicloudsdkcore.client import Client, ClientBuilder
|
|
9
|
+
from huaweicloudsdkcore.utils import http_utils
|
|
10
|
+
from huaweicloudsdkcore.sdk_stream_request import SdkStreamRequest
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from huaweicloudsdkcore.invoker.invoker import AsyncInvoker
|
|
14
|
+
except ImportError as e:
|
|
15
|
+
warnings.warn(str(e) + ", please check if you are using the same versions of 'huaweicloudsdkcore' and 'huaweicloudsdkversatile'")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class VersatileAsyncClient(Client):
|
|
19
|
+
def __init__(self):
|
|
20
|
+
super().__init__()
|
|
21
|
+
self.model_package = importlib.import_module("huaweicloudsdkversatile.v1.model")
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def new_builder(cls, clazz=None):
|
|
25
|
+
if not clazz:
|
|
26
|
+
client_builder = ClientBuilder(cls)
|
|
27
|
+
else:
|
|
28
|
+
if clazz.__name__ != "VersatileAsyncClient":
|
|
29
|
+
raise TypeError("client type error, support client type is VersatileAsyncClient")
|
|
30
|
+
client_builder = ClientBuilder(clazz)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
return client_builder
|
|
35
|
+
|
|
36
|
+
def search_knowledge_base_async(self, request):
|
|
37
|
+
r"""知识库检索
|
|
38
|
+
|
|
39
|
+
提供多知识库并行检索能力,支持语义、关键词、混合及FAQ四种检索模式,并允许自定义相似度阈值与返回结果数量,实现精准高效的信息匹配。
|
|
40
|
+
|
|
41
|
+
**适用场景**:
|
|
42
|
+
- 同时从多个知识库或文档集合中搜索相关内容。
|
|
43
|
+
- 在预设的问答列表中快速定位最相关的答案(FAQ检索)。
|
|
44
|
+
- 通过混合模式或调整阈值,兼顾搜索结果的准确性和全面性。
|
|
45
|
+
|
|
46
|
+
Please refer to HUAWEI cloud API Explorer for details.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
:param request: Request instance for SearchKnowledgeBase
|
|
50
|
+
:type request: :class:`huaweicloudsdkversatile.v1.SearchKnowledgeBaseRequest`
|
|
51
|
+
:rtype: :class:`huaweicloudsdkversatile.v1.SearchKnowledgeBaseResponse`
|
|
52
|
+
"""
|
|
53
|
+
http_info = self._search_knowledge_base_http_info(request)
|
|
54
|
+
return self._call_api(**http_info)
|
|
55
|
+
|
|
56
|
+
def search_knowledge_base_async_invoker(self, request):
|
|
57
|
+
http_info = self._search_knowledge_base_http_info(request)
|
|
58
|
+
return AsyncInvoker(self, http_info)
|
|
59
|
+
|
|
60
|
+
def _search_knowledge_base_http_info(self, request):
|
|
61
|
+
http_info = {
|
|
62
|
+
"method": "POST",
|
|
63
|
+
"resource_path": "/v2/{project_id}/knowledge-bases/retrieve",
|
|
64
|
+
"request_type": request.__class__.__name__,
|
|
65
|
+
"response_type": "SearchKnowledgeBaseResponse"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
|
69
|
+
|
|
70
|
+
cname = None
|
|
71
|
+
|
|
72
|
+
collection_formats = {}
|
|
73
|
+
|
|
74
|
+
path_params = {}
|
|
75
|
+
|
|
76
|
+
query_params = []
|
|
77
|
+
|
|
78
|
+
header_params = {}
|
|
79
|
+
|
|
80
|
+
form_params = {}
|
|
81
|
+
|
|
82
|
+
body = None
|
|
83
|
+
if 'body' in local_var_params:
|
|
84
|
+
body = local_var_params['body']
|
|
85
|
+
if isinstance(request, SdkStreamRequest):
|
|
86
|
+
body = request.get_file_stream()
|
|
87
|
+
|
|
88
|
+
response_headers = []
|
|
89
|
+
|
|
90
|
+
header_params['Content-Type'] = http_utils.select_header_content_type(
|
|
91
|
+
['application/json'])
|
|
92
|
+
|
|
93
|
+
auth_settings = []
|
|
94
|
+
|
|
95
|
+
http_info["cname"] = cname
|
|
96
|
+
http_info["collection_formats"] = collection_formats
|
|
97
|
+
http_info["path_params"] = path_params
|
|
98
|
+
http_info["query_params"] = query_params
|
|
99
|
+
http_info["header_params"] = header_params
|
|
100
|
+
http_info["post_params"] = form_params
|
|
101
|
+
http_info["body"] = body
|
|
102
|
+
http_info["response_headers"] = response_headers
|
|
103
|
+
|
|
104
|
+
return http_info
|
|
105
|
+
|
|
106
|
+
def run_agent_async(self, request):
|
|
107
|
+
r"""运行一个智能体
|
|
108
|
+
|
|
109
|
+
运行一个智能体,支持流式和非流式
|
|
110
|
+
|
|
111
|
+
Please refer to HUAWEI cloud API Explorer for details.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
:param request: Request instance for RunAgent
|
|
115
|
+
:type request: :class:`huaweicloudsdkversatile.v1.RunAgentRequest`
|
|
116
|
+
:rtype: :class:`huaweicloudsdkversatile.v1.RunAgentResponse`
|
|
117
|
+
"""
|
|
118
|
+
http_info = self._run_agent_http_info(request)
|
|
119
|
+
return self._call_api(**http_info)
|
|
120
|
+
|
|
121
|
+
def run_agent_async_invoker(self, request):
|
|
122
|
+
http_info = self._run_agent_http_info(request)
|
|
123
|
+
return AsyncInvoker(self, http_info)
|
|
124
|
+
|
|
125
|
+
def _run_agent_http_info(self, request):
|
|
126
|
+
http_info = {
|
|
127
|
+
"method": "POST",
|
|
128
|
+
"resource_path": "/v1/{project_id}/agents/{agent_id}/conversations/{conversation_id}",
|
|
129
|
+
"request_type": request.__class__.__name__,
|
|
130
|
+
"response_type": "RunAgentResponse"
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
|
134
|
+
|
|
135
|
+
cname = None
|
|
136
|
+
|
|
137
|
+
collection_formats = {}
|
|
138
|
+
|
|
139
|
+
path_params = {}
|
|
140
|
+
if 'agent_id' in local_var_params:
|
|
141
|
+
path_params['agent_id'] = local_var_params['agent_id']
|
|
142
|
+
if 'conversation_id' in local_var_params:
|
|
143
|
+
path_params['conversation_id'] = local_var_params['conversation_id']
|
|
144
|
+
|
|
145
|
+
query_params = []
|
|
146
|
+
if 'workspace_id' in local_var_params:
|
|
147
|
+
query_params.append(('workspace_id', local_var_params['workspace_id']))
|
|
148
|
+
if 'version' in local_var_params:
|
|
149
|
+
query_params.append(('version', local_var_params['version']))
|
|
150
|
+
if 'type' in local_var_params:
|
|
151
|
+
query_params.append(('type', local_var_params['type']))
|
|
152
|
+
|
|
153
|
+
header_params = {}
|
|
154
|
+
if 'stream' in local_var_params:
|
|
155
|
+
header_params['stream'] = local_var_params['stream']
|
|
156
|
+
|
|
157
|
+
form_params = {}
|
|
158
|
+
|
|
159
|
+
body = None
|
|
160
|
+
if 'body' in local_var_params:
|
|
161
|
+
body = local_var_params['body']
|
|
162
|
+
if isinstance(request, SdkStreamRequest):
|
|
163
|
+
body = request.get_file_stream()
|
|
164
|
+
|
|
165
|
+
response_headers = []
|
|
166
|
+
|
|
167
|
+
header_params['Content-Type'] = http_utils.select_header_content_type(
|
|
168
|
+
['application/json'])
|
|
169
|
+
|
|
170
|
+
auth_settings = []
|
|
171
|
+
|
|
172
|
+
http_info["cname"] = cname
|
|
173
|
+
http_info["collection_formats"] = collection_formats
|
|
174
|
+
http_info["path_params"] = path_params
|
|
175
|
+
http_info["query_params"] = query_params
|
|
176
|
+
http_info["header_params"] = header_params
|
|
177
|
+
http_info["post_params"] = form_params
|
|
178
|
+
http_info["body"] = body
|
|
179
|
+
http_info["response_headers"] = response_headers
|
|
180
|
+
|
|
181
|
+
return http_info
|
|
182
|
+
|
|
183
|
+
def run_workflow_async(self, request):
|
|
184
|
+
r"""运行一个工作流
|
|
185
|
+
|
|
186
|
+
运行一个工作流,支持流式和非流式
|
|
187
|
+
|
|
188
|
+
Please refer to HUAWEI cloud API Explorer for details.
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
:param request: Request instance for RunWorkflow
|
|
192
|
+
:type request: :class:`huaweicloudsdkversatile.v1.RunWorkflowRequest`
|
|
193
|
+
:rtype: :class:`huaweicloudsdkversatile.v1.RunWorkflowResponse`
|
|
194
|
+
"""
|
|
195
|
+
http_info = self._run_workflow_http_info(request)
|
|
196
|
+
return self._call_api(**http_info)
|
|
197
|
+
|
|
198
|
+
def run_workflow_async_invoker(self, request):
|
|
199
|
+
http_info = self._run_workflow_http_info(request)
|
|
200
|
+
return AsyncInvoker(self, http_info)
|
|
201
|
+
|
|
202
|
+
def _run_workflow_http_info(self, request):
|
|
203
|
+
http_info = {
|
|
204
|
+
"method": "POST",
|
|
205
|
+
"resource_path": "/v1/{project_id}/workflows/{workflow_id}/conversations/{conversation_id}",
|
|
206
|
+
"request_type": request.__class__.__name__,
|
|
207
|
+
"response_type": "RunWorkflowResponse"
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
|
211
|
+
|
|
212
|
+
cname = None
|
|
213
|
+
|
|
214
|
+
collection_formats = {}
|
|
215
|
+
|
|
216
|
+
path_params = {}
|
|
217
|
+
if 'workflow_id' in local_var_params:
|
|
218
|
+
path_params['workflow_id'] = local_var_params['workflow_id']
|
|
219
|
+
if 'conversation_id' in local_var_params:
|
|
220
|
+
path_params['conversation_id'] = local_var_params['conversation_id']
|
|
221
|
+
|
|
222
|
+
query_params = []
|
|
223
|
+
if 'workspace_id' in local_var_params:
|
|
224
|
+
query_params.append(('workspace_id', local_var_params['workspace_id']))
|
|
225
|
+
if 'version' in local_var_params:
|
|
226
|
+
query_params.append(('version', local_var_params['version']))
|
|
227
|
+
|
|
228
|
+
header_params = {}
|
|
229
|
+
if 'stream' in local_var_params:
|
|
230
|
+
header_params['stream'] = local_var_params['stream']
|
|
231
|
+
|
|
232
|
+
form_params = {}
|
|
233
|
+
|
|
234
|
+
body = None
|
|
235
|
+
if 'body' in local_var_params:
|
|
236
|
+
body = local_var_params['body']
|
|
237
|
+
if isinstance(request, SdkStreamRequest):
|
|
238
|
+
body = request.get_file_stream()
|
|
239
|
+
|
|
240
|
+
response_headers = []
|
|
241
|
+
|
|
242
|
+
header_params['Content-Type'] = http_utils.select_header_content_type(
|
|
243
|
+
['application/json'])
|
|
244
|
+
|
|
245
|
+
auth_settings = []
|
|
246
|
+
|
|
247
|
+
http_info["cname"] = cname
|
|
248
|
+
http_info["collection_formats"] = collection_formats
|
|
249
|
+
http_info["path_params"] = path_params
|
|
250
|
+
http_info["query_params"] = query_params
|
|
251
|
+
http_info["header_params"] = header_params
|
|
252
|
+
http_info["post_params"] = form_params
|
|
253
|
+
http_info["body"] = body
|
|
254
|
+
http_info["response_headers"] = response_headers
|
|
255
|
+
|
|
256
|
+
return http_info
|
|
257
|
+
|
|
258
|
+
def upload_agent_file_async(self, request):
|
|
259
|
+
r"""上传文件
|
|
260
|
+
|
|
261
|
+
上传文件,以供agent或者工作流使用
|
|
262
|
+
|
|
263
|
+
Please refer to HUAWEI cloud API Explorer for details.
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
:param request: Request instance for UploadAgentFile
|
|
267
|
+
:type request: :class:`huaweicloudsdkversatile.v1.UploadAgentFileRequest`
|
|
268
|
+
:rtype: :class:`huaweicloudsdkversatile.v1.UploadAgentFileResponse`
|
|
269
|
+
"""
|
|
270
|
+
http_info = self._upload_agent_file_http_info(request)
|
|
271
|
+
return self._call_api(**http_info)
|
|
272
|
+
|
|
273
|
+
def upload_agent_file_async_invoker(self, request):
|
|
274
|
+
http_info = self._upload_agent_file_http_info(request)
|
|
275
|
+
return AsyncInvoker(self, http_info)
|
|
276
|
+
|
|
277
|
+
def _upload_agent_file_http_info(self, request):
|
|
278
|
+
http_info = {
|
|
279
|
+
"method": "POST",
|
|
280
|
+
"resource_path": "/v1/{project_id}/agent-runtime/upload-file",
|
|
281
|
+
"request_type": request.__class__.__name__,
|
|
282
|
+
"response_type": "UploadAgentFileResponse"
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
|
286
|
+
|
|
287
|
+
cname = None
|
|
288
|
+
|
|
289
|
+
collection_formats = {}
|
|
290
|
+
|
|
291
|
+
path_params = {}
|
|
292
|
+
|
|
293
|
+
query_params = []
|
|
294
|
+
if 'workspace_id' in local_var_params:
|
|
295
|
+
query_params.append(('workspace_id', local_var_params['workspace_id']))
|
|
296
|
+
if 'expires' in local_var_params:
|
|
297
|
+
query_params.append(('expires', local_var_params['expires']))
|
|
298
|
+
if 'is_image' in local_var_params:
|
|
299
|
+
query_params.append(('is_image', local_var_params['is_image']))
|
|
300
|
+
|
|
301
|
+
header_params = {}
|
|
302
|
+
|
|
303
|
+
form_params = {}
|
|
304
|
+
if 'file' in local_var_params:
|
|
305
|
+
form_params['file'] = local_var_params['file']
|
|
306
|
+
|
|
307
|
+
body = None
|
|
308
|
+
if 'body' in local_var_params:
|
|
309
|
+
body = local_var_params['body']
|
|
310
|
+
if isinstance(request, SdkStreamRequest):
|
|
311
|
+
body = request.get_file_stream()
|
|
312
|
+
|
|
313
|
+
response_headers = []
|
|
314
|
+
|
|
315
|
+
header_params['Content-Type'] = http_utils.select_header_content_type(
|
|
316
|
+
['multipart/form-data'])
|
|
317
|
+
|
|
318
|
+
auth_settings = []
|
|
319
|
+
|
|
320
|
+
http_info["cname"] = cname
|
|
321
|
+
http_info["collection_formats"] = collection_formats
|
|
322
|
+
http_info["path_params"] = path_params
|
|
323
|
+
http_info["query_params"] = query_params
|
|
324
|
+
http_info["header_params"] = header_params
|
|
325
|
+
http_info["post_params"] = form_params
|
|
326
|
+
http_info["body"] = body
|
|
327
|
+
http_info["response_headers"] = response_headers
|
|
328
|
+
|
|
329
|
+
return http_info
|
|
330
|
+
|
|
331
|
+
def _call_api(self, **kwargs):
|
|
332
|
+
try:
|
|
333
|
+
kwargs["async_request"] = True
|
|
334
|
+
return self.do_http_request(**kwargs)
|
|
335
|
+
except TypeError:
|
|
336
|
+
import inspect
|
|
337
|
+
params = inspect.signature(self.do_http_request).parameters
|
|
338
|
+
http_info = {param_name: kwargs.get(param_name) for param_name in params if param_name in kwargs}
|
|
339
|
+
return self.do_http_request(**http_info)
|
|
340
|
+
|
|
341
|
+
def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None,
|
|
342
|
+
post_params=None, cname=None, response_type=None, response_headers=None, auth_settings=None,
|
|
343
|
+
collection_formats=None, request_type=None):
|
|
344
|
+
"""Makes the HTTP request and returns deserialized data.
|
|
345
|
+
|
|
346
|
+
:param resource_path: Path to method endpoint.
|
|
347
|
+
:param method: Method to call.
|
|
348
|
+
:param path_params: Path parameters in the url.
|
|
349
|
+
:param query_params: Query parameters in the url.
|
|
350
|
+
:param header_params: Header parameters to be
|
|
351
|
+
placed in the request header.
|
|
352
|
+
:param body: Request body.
|
|
353
|
+
:param post_params: Request post form parameters,
|
|
354
|
+
for `application/x-www-form-urlencoded`, `multipart/form-data`.
|
|
355
|
+
:param cname: Used for obs endpoint.
|
|
356
|
+
:param auth_settings: Auth Settings names for the request.
|
|
357
|
+
:param response_type: Response data type.
|
|
358
|
+
:param response_headers: Header should be added to response data.
|
|
359
|
+
:param collection_formats: dict of collection formats for path, query,
|
|
360
|
+
header, and post parameters.
|
|
361
|
+
:param request_type: Request data type.
|
|
362
|
+
:return:
|
|
363
|
+
Return the response directly.
|
|
364
|
+
"""
|
|
365
|
+
return self.do_http_request(
|
|
366
|
+
method=method,
|
|
367
|
+
resource_path=resource_path,
|
|
368
|
+
path_params=path_params,
|
|
369
|
+
query_params=query_params,
|
|
370
|
+
header_params=header_params,
|
|
371
|
+
body=body,
|
|
372
|
+
post_params=post_params,
|
|
373
|
+
cname=cname,
|
|
374
|
+
response_type=response_type,
|
|
375
|
+
response_headers=response_headers,
|
|
376
|
+
collection_formats=collection_formats,
|
|
377
|
+
request_type=request_type,
|
|
378
|
+
async_request=True)
|