dashscope 1.24.0__py3-none-any.whl → 1.24.2__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/cli.py +54 -14
- dashscope/multimodal/multimodal_request_params.py +1 -0
- dashscope/multimodal/tingwu/__init__.py +0 -0
- dashscope/multimodal/tingwu/tingwu.py +80 -0
- dashscope/utils/oss_utils.py +1 -1
- dashscope/version.py +1 -1
- {dashscope-1.24.0.dist-info → dashscope-1.24.2.dist-info}/METADATA +1 -1
- {dashscope-1.24.0.dist-info → dashscope-1.24.2.dist-info}/RECORD +12 -10
- {dashscope-1.24.0.dist-info → dashscope-1.24.2.dist-info}/WHEEL +0 -0
- {dashscope-1.24.0.dist-info → dashscope-1.24.2.dist-info}/entry_points.txt +0 -0
- {dashscope-1.24.0.dist-info → dashscope-1.24.2.dist-info}/licenses/LICENSE +0 -0
- {dashscope-1.24.0.dist-info → dashscope-1.24.2.dist-info}/top_level.txt +0 -0
dashscope/cli.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
import argparse
|
|
3
|
+
import json
|
|
3
4
|
import sys
|
|
4
5
|
import time
|
|
5
6
|
import os
|
|
@@ -216,7 +217,8 @@ class Oss:
|
|
|
216
217
|
|
|
217
218
|
oss_url = OssUtils.upload(model=args.model,
|
|
218
219
|
file_path=file_path,
|
|
219
|
-
api_key=api_key
|
|
220
|
+
api_key=api_key,
|
|
221
|
+
base_address=args.base_url)
|
|
220
222
|
|
|
221
223
|
if not oss_url:
|
|
222
224
|
print('Failed to upload file: %s' % file_path)
|
|
@@ -229,7 +231,8 @@ class Files:
|
|
|
229
231
|
def upload(cls, args):
|
|
230
232
|
rsp = dashscope.Files.upload(file_path=args.file,
|
|
231
233
|
purpose=args.purpose,
|
|
232
|
-
description=args.description
|
|
234
|
+
description=args.description,
|
|
235
|
+
base_address=args.base_url)
|
|
233
236
|
print(rsp)
|
|
234
237
|
if rsp.status_code == HTTPStatus.OK:
|
|
235
238
|
print('Upload success, file id: %s' %
|
|
@@ -239,32 +242,31 @@ class Files:
|
|
|
239
242
|
|
|
240
243
|
@classmethod
|
|
241
244
|
def get(cls, args):
|
|
242
|
-
rsp = dashscope.Files.get(file_id=args.id)
|
|
245
|
+
rsp = dashscope.Files.get(file_id=args.id, base_address=args.base_url)
|
|
243
246
|
if rsp.status_code == HTTPStatus.OK:
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
+
if rsp.output:
|
|
248
|
+
print('file info:\n%s' % json.dumps(rsp.output, ensure_ascii=False, indent=4))
|
|
249
|
+
else:
|
|
250
|
+
print('There is no uploaded file.')
|
|
247
251
|
else:
|
|
248
252
|
print_failed_message(rsp)
|
|
249
253
|
|
|
250
254
|
@classmethod
|
|
251
255
|
def list(cls, args):
|
|
252
256
|
rsp = dashscope.Files.list(page=args.start_page,
|
|
253
|
-
page_size=args.page_size
|
|
257
|
+
page_size=args.page_size,
|
|
258
|
+
base_address=args.base_url)
|
|
254
259
|
if rsp.status_code == HTTPStatus.OK:
|
|
255
|
-
if rsp.output
|
|
256
|
-
|
|
257
|
-
print('file_id: %s, name: %s, description: %s, time: %s' %
|
|
258
|
-
(f['file_id'], f['name'], f['description'],
|
|
259
|
-
f['gmt_create']))
|
|
260
|
+
if rsp.output:
|
|
261
|
+
print('file list info:\n%s' % json.dumps(rsp.output, ensure_ascii=False, indent=4))
|
|
260
262
|
else:
|
|
261
|
-
print('There is no uploaded
|
|
263
|
+
print('There is no uploaded files.')
|
|
262
264
|
else:
|
|
263
265
|
print_failed_message(rsp)
|
|
264
266
|
|
|
265
267
|
@classmethod
|
|
266
268
|
def delete(cls, args):
|
|
267
|
-
rsp = dashscope.Files.delete(args.id)
|
|
269
|
+
rsp = dashscope.Files.delete(args.id, base_address=args.base_url)
|
|
268
270
|
if rsp.status_code == HTTPStatus.OK:
|
|
269
271
|
print('Delete success')
|
|
270
272
|
else:
|
|
@@ -529,6 +531,13 @@ def main():
|
|
|
529
531
|
required=False,
|
|
530
532
|
help='The dashscope api key',
|
|
531
533
|
)
|
|
534
|
+
oss_upload.add_argument(
|
|
535
|
+
'-u',
|
|
536
|
+
'--base_url',
|
|
537
|
+
type=str,
|
|
538
|
+
help='The base url.',
|
|
539
|
+
required=False,
|
|
540
|
+
)
|
|
532
541
|
oss_upload.set_defaults(func=Oss.upload)
|
|
533
542
|
|
|
534
543
|
file_upload = sub_parsers.add_parser('files.upload')
|
|
@@ -555,21 +564,45 @@ def main():
|
|
|
555
564
|
help='The file description.',
|
|
556
565
|
required=False,
|
|
557
566
|
)
|
|
567
|
+
file_upload.add_argument(
|
|
568
|
+
'-u',
|
|
569
|
+
'--base_url',
|
|
570
|
+
type=str,
|
|
571
|
+
help='The base url.',
|
|
572
|
+
required=False,
|
|
573
|
+
)
|
|
558
574
|
file_upload.set_defaults(func=Files.upload)
|
|
575
|
+
|
|
559
576
|
file_get = sub_parsers.add_parser('files.get')
|
|
560
577
|
file_get.add_argument('-i',
|
|
561
578
|
'--id',
|
|
562
579
|
type=str,
|
|
563
580
|
required=True,
|
|
564
581
|
help='The file ID')
|
|
582
|
+
file_get.add_argument(
|
|
583
|
+
'-u',
|
|
584
|
+
'--base_url',
|
|
585
|
+
type=str,
|
|
586
|
+
help='The base url.',
|
|
587
|
+
required=False,
|
|
588
|
+
)
|
|
565
589
|
file_get.set_defaults(func=Files.get)
|
|
590
|
+
|
|
566
591
|
file_delete = sub_parsers.add_parser('files.delete')
|
|
567
592
|
file_delete.add_argument('-i',
|
|
568
593
|
'--id',
|
|
569
594
|
type=str,
|
|
570
595
|
required=True,
|
|
571
596
|
help='The files ID')
|
|
597
|
+
file_delete.add_argument(
|
|
598
|
+
'-u',
|
|
599
|
+
'--base_url',
|
|
600
|
+
type=str,
|
|
601
|
+
help='The base url.',
|
|
602
|
+
required=False,
|
|
603
|
+
)
|
|
572
604
|
file_delete.set_defaults(func=Files.delete)
|
|
605
|
+
|
|
573
606
|
file_list = sub_parsers.add_parser('files.list')
|
|
574
607
|
file_list.add_argument('-s',
|
|
575
608
|
'--start_page',
|
|
@@ -581,6 +614,13 @@ def main():
|
|
|
581
614
|
type=int,
|
|
582
615
|
default=10,
|
|
583
616
|
help='The page size, default 10')
|
|
617
|
+
file_list.add_argument(
|
|
618
|
+
'-u',
|
|
619
|
+
'--base_url',
|
|
620
|
+
type=str,
|
|
621
|
+
help='The base url.',
|
|
622
|
+
required=False,
|
|
623
|
+
)
|
|
584
624
|
file_list.set_defaults(func=Files.list)
|
|
585
625
|
|
|
586
626
|
deployments_call = sub_parsers.add_parser('deployments.call')
|
|
@@ -81,6 +81,7 @@ class Upstream:
|
|
|
81
81
|
type: str = field(default="AudioOnly") # 上行类型:AudioOnly 仅语音通话; AudioAndVideo 上传视频
|
|
82
82
|
mode: str = field(default="tap2talk") # 客户端交互模式 push2talk/tap2talk/duplex
|
|
83
83
|
# sample_rate: int # 合成音频采样率
|
|
84
|
+
pass_through_params: dict = field(default=None)
|
|
84
85
|
|
|
85
86
|
def to_dict(self):
|
|
86
87
|
upstream: dict = {
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from typing import Dict, Any
|
|
2
|
+
|
|
3
|
+
from dashscope.api_entities.api_request_factory import _build_api_request
|
|
4
|
+
from dashscope.api_entities.dashscope_response import DashScopeAPIResponse
|
|
5
|
+
from dashscope.client.base_api import BaseApi
|
|
6
|
+
from dashscope.common.error import ModelRequired
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TingWu(BaseApi):
|
|
10
|
+
"""API for TingWu APP.
|
|
11
|
+
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
task = None
|
|
15
|
+
task_group = None
|
|
16
|
+
function = None
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def call(
|
|
20
|
+
cls,
|
|
21
|
+
model: str,
|
|
22
|
+
user_defined_input: Dict[str, Any],
|
|
23
|
+
parameters: Dict[str, Any] = None,
|
|
24
|
+
api_key: str = None,
|
|
25
|
+
**kwargs
|
|
26
|
+
) -> DashScopeAPIResponse:
|
|
27
|
+
"""Call generation model service.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
model (str): The requested model, such as qwen-turbo
|
|
31
|
+
api_key (str, optional): The api api_key, can be None,
|
|
32
|
+
if None, will get by default rule(TODO: api key doc).
|
|
33
|
+
user_defined_input: custom input
|
|
34
|
+
parameters: custom parameters
|
|
35
|
+
**kwargs:
|
|
36
|
+
base_address: base address
|
|
37
|
+
additional parameters for request
|
|
38
|
+
|
|
39
|
+
Raises:
|
|
40
|
+
InvalidInput: The history and auto_history are mutually exclusive.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
Union[GenerationResponse,
|
|
44
|
+
Generator[GenerationResponse, None, None]]: If
|
|
45
|
+
stream is True, return Generator, otherwise GenerationResponse.
|
|
46
|
+
"""
|
|
47
|
+
if model is None or not model:
|
|
48
|
+
raise ModelRequired('Model is required!')
|
|
49
|
+
input_config, parameters = cls._build_input_parameters(input_config=user_defined_input,
|
|
50
|
+
params=parameters,
|
|
51
|
+
**kwargs)
|
|
52
|
+
|
|
53
|
+
request = _build_api_request(
|
|
54
|
+
model=model,
|
|
55
|
+
input=input_config,
|
|
56
|
+
api_key=api_key,
|
|
57
|
+
task_group=TingWu.task_group,
|
|
58
|
+
task=TingWu.task,
|
|
59
|
+
function=TingWu.function,
|
|
60
|
+
is_service=False,
|
|
61
|
+
**parameters)
|
|
62
|
+
response = request.call()
|
|
63
|
+
|
|
64
|
+
return response
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def _build_input_parameters(cls,
|
|
68
|
+
input_config,
|
|
69
|
+
params: Dict[str, Any] = None,
|
|
70
|
+
**kwargs):
|
|
71
|
+
parameters = {}
|
|
72
|
+
if params is not None:
|
|
73
|
+
parameters = params
|
|
74
|
+
|
|
75
|
+
input_param = input_config
|
|
76
|
+
|
|
77
|
+
if kwargs.keys() is not None:
|
|
78
|
+
for key in kwargs.keys():
|
|
79
|
+
parameters[key] = kwargs[key]
|
|
80
|
+
return input_param, {**parameters, **kwargs}
|
dashscope/utils/oss_utils.py
CHANGED
|
@@ -47,7 +47,7 @@ class OssUtils(GetMixin):
|
|
|
47
47
|
Returns:
|
|
48
48
|
DashScopeAPIResponse: The upload information
|
|
49
49
|
"""
|
|
50
|
-
upload_info = cls.get_upload_certificate(model=model, api_key=api_key)
|
|
50
|
+
upload_info = cls.get_upload_certificate(model=model, api_key=api_key, **kwargs)
|
|
51
51
|
if upload_info.status_code != HTTPStatus.OK:
|
|
52
52
|
raise UploadFileException(
|
|
53
53
|
'Get upload certificate failed, code: %s, message: %s' %
|
dashscope/version.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
dashscope/__init__.py,sha256=__BY0dzgFX5Bt50WL-2PJmI8EYOmnpXhABQntdqDtSM,3062
|
|
2
|
-
dashscope/cli.py,sha256=
|
|
2
|
+
dashscope/cli.py,sha256=64oGkevgX0RHPPmMg0sevXDgaFLQNA_0vdtjQ7Z2pHM,26492
|
|
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=tFrHRbI2SJLqcZ_I7s27rempXOnJ1PnfN0UpyIemTGE,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
|
|
@@ -73,7 +73,9 @@ dashscope/multimodal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
|
73
73
|
dashscope/multimodal/dialog_state.py,sha256=CtOdfGWhq0ePG3bc8-7inhespETtPD4QDli1513hd1A,1522
|
|
74
74
|
dashscope/multimodal/multimodal_constants.py,sha256=z_QVq01E43FAqKQnDu9vdf89d1zuYlWyANewWTEXVJM,1282
|
|
75
75
|
dashscope/multimodal/multimodal_dialog.py,sha256=HymlaQYp7SgJdoKbT27SNiviyRRoM91zklNBwTHmm1Q,23939
|
|
76
|
-
dashscope/multimodal/multimodal_request_params.py,sha256=
|
|
76
|
+
dashscope/multimodal/multimodal_request_params.py,sha256=Lbxf_kLnFUkhty8AU9wL7ws9tYbmhHPVmsiXLdynlJg,8402
|
|
77
|
+
dashscope/multimodal/tingwu/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
78
|
+
dashscope/multimodal/tingwu/tingwu.py,sha256=01d-QOeuB1QmRhiZqbXJ8pHoGqT0C-xZTjIs_ZBXOyw,2613
|
|
77
79
|
dashscope/nlp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
78
80
|
dashscope/nlp/understanding.py,sha256=00ado-ibYEzBRT0DgKGd3bohQDNW73xnFhJ_1aa87lw,2880
|
|
79
81
|
dashscope/protocol/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -96,10 +98,10 @@ dashscope/tokenizers/tokenization.py,sha256=ubQBJ_yw_MoHuHxZcK9NarZSSbyExloeSOLI
|
|
|
96
98
|
dashscope/tokenizers/tokenizer.py,sha256=3FQVDvMNkCW9ccYeJdjrd_PIMMD3Xv7aNZkaYOE4XX4,1205
|
|
97
99
|
dashscope/tokenizers/tokenizer_base.py,sha256=5EJIFuizMWESEmLmbd38yJnfeHmPnzZPwsO4aOGjpl4,707
|
|
98
100
|
dashscope/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
99
|
-
dashscope/utils/oss_utils.py,sha256=
|
|
100
|
-
dashscope-1.24.
|
|
101
|
-
dashscope-1.24.
|
|
102
|
-
dashscope-1.24.
|
|
103
|
-
dashscope-1.24.
|
|
104
|
-
dashscope-1.24.
|
|
105
|
-
dashscope-1.24.
|
|
101
|
+
dashscope/utils/oss_utils.py,sha256=0BrMogT1PgNAWLYx947akgw_lcLsaVIIMAL1KUtaB88,7507
|
|
102
|
+
dashscope-1.24.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
103
|
+
dashscope-1.24.2.dist-info/METADATA,sha256=W7cXJ-appClSQXDftF5s2agUBHZHKaqrfPZ_oKZ35N4,7123
|
|
104
|
+
dashscope-1.24.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
105
|
+
dashscope-1.24.2.dist-info/entry_points.txt,sha256=e9C3sOf9zDYL0O5ROEGX6FT8w-QK_kaGRWmPZDHAFys,49
|
|
106
|
+
dashscope-1.24.2.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
|
|
107
|
+
dashscope-1.24.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|