dashscope 1.23.5__py3-none-any.whl → 1.23.6__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.
Potentially problematic release.
This version of dashscope might be problematic. Click here for more details.
- dashscope/multimodal/multimodal_constants.py +1 -0
- dashscope/multimodal/multimodal_dialog.py +42 -7
- dashscope/multimodal/multimodal_request_params.py +5 -2
- dashscope/version.py +1 -1
- {dashscope-1.23.5.dist-info → dashscope-1.23.6.dist-info}/METADATA +17 -5
- {dashscope-1.23.5.dist-info → dashscope-1.23.6.dist-info}/RECORD +10 -10
- {dashscope-1.23.5.dist-info → dashscope-1.23.6.dist-info}/WHEEL +1 -1
- {dashscope-1.23.5.dist-info → dashscope-1.23.6.dist-info}/entry_points.txt +0 -1
- {dashscope-1.23.5.dist-info → dashscope-1.23.6.dist-info/licenses}/LICENSE +0 -0
- {dashscope-1.23.5.dist-info → dashscope-1.23.6.dist-info}/top_level.txt +0 -0
|
@@ -25,3 +25,4 @@ RESPONSE_NAME_RESPONDING_ENDED = "RespondingEnded" # AI语音应答结束
|
|
|
25
25
|
RESPONSE_NAME_SPEECH_CONTENT = "SpeechContent" # 用户语音识别出的文本,流式全量输出
|
|
26
26
|
RESPONSE_NAME_RESPONDING_CONTENT = "RespondingContent" # 统对外输出的文本,流式全量输出
|
|
27
27
|
RESPONSE_NAME_ERROR = "Error" # 服务端对话中报错
|
|
28
|
+
RESPONSE_NAME_HEART_BEAT = "HeartBeat" # 心跳消息
|
|
@@ -127,10 +127,10 @@ class MultiModalDialog:
|
|
|
127
127
|
"""
|
|
128
128
|
|
|
129
129
|
def __init__(self,
|
|
130
|
-
workspace_id: str,
|
|
131
130
|
app_id: str,
|
|
132
131
|
request_params: RequestParameters,
|
|
133
132
|
multimodal_callback: MultiModalCallback,
|
|
133
|
+
workspace_id: str = None,
|
|
134
134
|
url: str = None,
|
|
135
135
|
api_key: str = None,
|
|
136
136
|
dialog_id: str = None,
|
|
@@ -140,7 +140,7 @@ class MultiModalDialog:
|
|
|
140
140
|
创建一个语音对话会话。
|
|
141
141
|
|
|
142
142
|
此方法用于初始化一个新的voice_chat会话,设置必要的参数以准备开始与模型的交互。
|
|
143
|
-
:param workspace_id: 客户的workspace_id
|
|
143
|
+
:param workspace_id: 客户的workspace_id 主工作空间id,非必填字段
|
|
144
144
|
:param app_id: 客户在管控台创建的应用id,可以根据值规律确定使用哪个对话系统
|
|
145
145
|
:param request_params: 请求参数集合
|
|
146
146
|
:param url: (str) API的URL地址。
|
|
@@ -185,7 +185,8 @@ class MultiModalDialog:
|
|
|
185
185
|
|
|
186
186
|
def _on_close(self, ws, close_status_code, close_msg):
|
|
187
187
|
try:
|
|
188
|
-
logger.debug(
|
|
188
|
+
logger.debug(
|
|
189
|
+
"WebSocket connection closed with status {} and message {}".format(close_status_code, close_msg))
|
|
189
190
|
if close_status_code is None:
|
|
190
191
|
close_status_code = 1000
|
|
191
192
|
if close_msg is None:
|
|
@@ -257,6 +258,16 @@ class MultiModalDialog:
|
|
|
257
258
|
_send_speech_json = self.request.generate_common_direction_request("LocalRespondingEnded", self.dialog_id)
|
|
258
259
|
self._send_text_frame(_send_speech_json)
|
|
259
260
|
|
|
261
|
+
def send_heart_beat(self):
|
|
262
|
+
"""发送心跳"""
|
|
263
|
+
_send_speech_json = self.request.generate_common_direction_request("HeartBeat", self.dialog_id)
|
|
264
|
+
self._send_text_frame(_send_speech_json)
|
|
265
|
+
|
|
266
|
+
def update_info(self, parameters: RequestToRespondParameters = None):
|
|
267
|
+
"""更新信息"""
|
|
268
|
+
_send_speech_json = self.request.generate_update_info_json(direction_name="UpdateInfo", dialog_id=self.dialog_id, parameters=parameters)
|
|
269
|
+
self._send_text_frame(_send_speech_json)
|
|
270
|
+
|
|
260
271
|
def stop(self):
|
|
261
272
|
if self.ws is None or not self.ws.sock or not self.ws.sock.connected:
|
|
262
273
|
self._callback.on_close(1001, "websocket is not connected")
|
|
@@ -372,10 +383,10 @@ class _Request:
|
|
|
372
383
|
|
|
373
384
|
def generate_start_request(self, direction_name: str,
|
|
374
385
|
dialog_id: str,
|
|
375
|
-
workspace_id: str,
|
|
376
386
|
app_id: str,
|
|
377
387
|
request_params: RequestParameters,
|
|
378
|
-
model: str = None
|
|
388
|
+
model: str = None,
|
|
389
|
+
workspace_id: str = None
|
|
379
390
|
) -> str:
|
|
380
391
|
"""
|
|
381
392
|
构建语音聊天服务的启动请求数据.
|
|
@@ -383,7 +394,7 @@ class _Request:
|
|
|
383
394
|
:param request_params: start请求body中的parameters
|
|
384
395
|
:param direction_name:
|
|
385
396
|
:param dialog_id: 对话ID.
|
|
386
|
-
:param workspace_id:
|
|
397
|
+
:param workspace_id: 管控台工作空间id, 非必填字段。
|
|
387
398
|
:param model: 模型
|
|
388
399
|
:return: 启动请求字典.
|
|
389
400
|
"""
|
|
@@ -428,7 +439,6 @@ class _Request:
|
|
|
428
439
|
}
|
|
429
440
|
return json.dumps(cmd)
|
|
430
441
|
|
|
431
|
-
@abstractmethod
|
|
432
442
|
def generate_request_to_response_json(self, direction_name: str, dialog_id: str, request_type: str, text: str,
|
|
433
443
|
parameters: RequestToRespondParameters = None) -> str:
|
|
434
444
|
"""
|
|
@@ -458,6 +468,29 @@ class _Request:
|
|
|
458
468
|
}
|
|
459
469
|
return json.dumps(cmd)
|
|
460
470
|
|
|
471
|
+
def generate_update_info_json(self, direction_name: str, dialog_id: str,parameters: RequestToRespondParameters = None) -> str:
|
|
472
|
+
"""
|
|
473
|
+
构建语音聊天服务的命令请求数据.
|
|
474
|
+
:param direction_name: 命令.
|
|
475
|
+
:param parameters: 命令请求body中的parameters
|
|
476
|
+
:return: 命令请求字典.
|
|
477
|
+
"""
|
|
478
|
+
self._get_dash_request_header(ActionType.CONTINUE)
|
|
479
|
+
|
|
480
|
+
custom_input = RequestToRespondBodyInput(
|
|
481
|
+
app_id=self.app_id,
|
|
482
|
+
directive=direction_name,
|
|
483
|
+
dialog_id=dialog_id,
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
self._get_dash_request_payload(direction_name, dialog_id, self.app_id, request_params=parameters,
|
|
487
|
+
custom_input=custom_input)
|
|
488
|
+
cmd = {
|
|
489
|
+
"header": self.header,
|
|
490
|
+
"payload": self.payload
|
|
491
|
+
}
|
|
492
|
+
return json.dumps(cmd)
|
|
493
|
+
|
|
461
494
|
def _get_dash_request_header(self, action: str):
|
|
462
495
|
"""
|
|
463
496
|
构建多模对话请求的请求协议Header
|
|
@@ -560,6 +593,8 @@ class _Response:
|
|
|
560
593
|
self._handle_responding_content(payload)
|
|
561
594
|
elif response_event == RESPONSE_NAME_ERROR:
|
|
562
595
|
self._callback.on_error(json.dumps(response_json))
|
|
596
|
+
elif response_event == RESPONSE_NAME_HEART_BEAT:
|
|
597
|
+
logger.debug("Server response heart beat")
|
|
563
598
|
else:
|
|
564
599
|
logger.error("Unknown response name: {}", response_event)
|
|
565
600
|
except json.JSONDecodeError:
|
|
@@ -198,6 +198,7 @@ class BizParams:
|
|
|
198
198
|
tool_prompts: dict = field(default=None)
|
|
199
199
|
user_prompt_params: dict = field(default=None)
|
|
200
200
|
user_query_params: dict = field(default=None)
|
|
201
|
+
videos: list = field(default=None)
|
|
201
202
|
|
|
202
203
|
def to_dict(self):
|
|
203
204
|
params = {}
|
|
@@ -211,6 +212,8 @@ class BizParams:
|
|
|
211
212
|
params["user_prompt_params"] = self.user_prompt_params
|
|
212
213
|
if self.user_query_params is not None:
|
|
213
214
|
params["user_query_params"] = self.user_query_params
|
|
215
|
+
if self.videos is not None:
|
|
216
|
+
params["videos"] = self.videos
|
|
214
217
|
return params
|
|
215
218
|
|
|
216
219
|
|
|
@@ -256,7 +259,7 @@ class RequestToRespondBodyInput(DashPayloadInput):
|
|
|
256
259
|
app_id: str
|
|
257
260
|
directive: str
|
|
258
261
|
dialog_id: str
|
|
259
|
-
type_: str = field(metadata={"alias": "type"})
|
|
262
|
+
type_: str = field(metadata={"alias": "type"}, default= None)
|
|
260
263
|
text: str = field(default="")
|
|
261
264
|
|
|
262
265
|
def to_dict(self):
|
|
@@ -266,4 +269,4 @@ class RequestToRespondBodyInput(DashPayloadInput):
|
|
|
266
269
|
"dialog_id": self.dialog_id,
|
|
267
270
|
"type": self.type_,
|
|
268
271
|
"text": self.text
|
|
269
|
-
}
|
|
272
|
+
}
|
dashscope/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: dashscope
|
|
3
|
-
Version: 1.23.
|
|
3
|
+
Version: 1.23.6
|
|
4
4
|
Summary: dashscope client sdk library
|
|
5
5
|
Home-page: https://dashscope.aliyun.com/
|
|
6
6
|
Author: Alibaba Cloud
|
|
@@ -18,11 +18,25 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Requires-Python: >=3.8.0
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
21
22
|
Requires-Dist: aiohttp
|
|
22
23
|
Requires-Dist: requests
|
|
23
24
|
Requires-Dist: websocket-client
|
|
24
25
|
Provides-Extra: tokenizer
|
|
25
|
-
Requires-Dist: tiktoken
|
|
26
|
+
Requires-Dist: tiktoken; extra == "tokenizer"
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: author-email
|
|
29
|
+
Dynamic: classifier
|
|
30
|
+
Dynamic: description
|
|
31
|
+
Dynamic: description-content-type
|
|
32
|
+
Dynamic: home-page
|
|
33
|
+
Dynamic: license
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
Dynamic: platform
|
|
36
|
+
Dynamic: provides-extra
|
|
37
|
+
Dynamic: requires-dist
|
|
38
|
+
Dynamic: requires-python
|
|
39
|
+
Dynamic: summary
|
|
26
40
|
|
|
27
41
|
<h4 align="center">
|
|
28
42
|
<p>
|
|
@@ -221,5 +235,3 @@ Coming soon.
|
|
|
221
235
|
|
|
222
236
|
## License
|
|
223
237
|
This project is licensed under the Apache License (Version 2.0).
|
|
224
|
-
|
|
225
|
-
|
|
@@ -3,7 +3,7 @@ dashscope/cli.py,sha256=amegoTkGOs6TlHMdoo4JVOqBePo3lGs745rc7leEyrE,24020
|
|
|
3
3
|
dashscope/files.py,sha256=vRDQygm3lOqBZR73o7KNHs1iTBVuvLncuwJNxIYjzAU,3981
|
|
4
4
|
dashscope/model.py,sha256=B5v_BtYLPqj6raClejBgdKg6WTGwhH_f-20pvsQqmsk,1491
|
|
5
5
|
dashscope/models.py,sha256=dE4mzXkl85G343qVylSGpURPRdA5pZSqXlx6PcxqC_Q,1275
|
|
6
|
-
dashscope/version.py,sha256=
|
|
6
|
+
dashscope/version.py,sha256=VtJV154d4VNke5BkkccDtVlsLdOM6gdSce36vOpcfbU,74
|
|
7
7
|
dashscope/aigc/__init__.py,sha256=AuRhu_vA1K0tbs_C6DgcZYhTvxMuzDgpwHJNHzEPIHg,442
|
|
8
8
|
dashscope/aigc/chat_completion.py,sha256=ONlyyssIbfaKKcFo7cEKhHx5OCF2XX810HFzIExW1ho,14813
|
|
9
9
|
dashscope/aigc/code_generation.py,sha256=p_mxDKJLQMW0IjFD46JRlZuEZCRESSVKEfLlAevBtqw,10936
|
|
@@ -66,9 +66,9 @@ dashscope/io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
66
66
|
dashscope/io/input_output.py,sha256=0aXrRJFo1ZqYm_AJWR_w88O4-Btn9np2zUhrrUdBdfw,3992
|
|
67
67
|
dashscope/multimodal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
68
|
dashscope/multimodal/dialog_state.py,sha256=CtOdfGWhq0ePG3bc8-7inhespETtPD4QDli1513hd1A,1522
|
|
69
|
-
dashscope/multimodal/multimodal_constants.py,sha256=
|
|
70
|
-
dashscope/multimodal/multimodal_dialog.py,sha256=
|
|
71
|
-
dashscope/multimodal/multimodal_request_params.py,sha256=
|
|
69
|
+
dashscope/multimodal/multimodal_constants.py,sha256=z_QVq01E43FAqKQnDu9vdf89d1zuYlWyANewWTEXVJM,1282
|
|
70
|
+
dashscope/multimodal/multimodal_dialog.py,sha256=HymlaQYp7SgJdoKbT27SNiviyRRoM91zklNBwTHmm1Q,23939
|
|
71
|
+
dashscope/multimodal/multimodal_request_params.py,sha256=7A4UhsbYjcX7aAJwWI1xZEt0e1bSgPcu5pJAinaZyx0,7907
|
|
72
72
|
dashscope/nlp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
73
|
dashscope/nlp/understanding.py,sha256=00ado-ibYEzBRT0DgKGd3bohQDNW73xnFhJ_1aa87lw,2880
|
|
74
74
|
dashscope/protocol/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -92,9 +92,9 @@ dashscope/tokenizers/tokenizer.py,sha256=3FQVDvMNkCW9ccYeJdjrd_PIMMD3Xv7aNZkaYOE
|
|
|
92
92
|
dashscope/tokenizers/tokenizer_base.py,sha256=5EJIFuizMWESEmLmbd38yJnfeHmPnzZPwsO4aOGjpl4,707
|
|
93
93
|
dashscope/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
94
94
|
dashscope/utils/oss_utils.py,sha256=L5LN3lN8etVxSL_jkZydstvEKpnTG9CY0zcvPGQ5LBo,7383
|
|
95
|
-
dashscope-1.23.
|
|
96
|
-
dashscope-1.23.
|
|
97
|
-
dashscope-1.23.
|
|
98
|
-
dashscope-1.23.
|
|
99
|
-
dashscope-1.23.
|
|
100
|
-
dashscope-1.23.
|
|
95
|
+
dashscope-1.23.6.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
96
|
+
dashscope-1.23.6.dist-info/METADATA,sha256=l1m0KB4CgXdVltrY8r0NwntIgRE3-a5MKApSuhy8pks,7095
|
|
97
|
+
dashscope-1.23.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
98
|
+
dashscope-1.23.6.dist-info/entry_points.txt,sha256=e9C3sOf9zDYL0O5ROEGX6FT8w-QK_kaGRWmPZDHAFys,49
|
|
99
|
+
dashscope-1.23.6.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
|
|
100
|
+
dashscope-1.23.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|