dashscope 1.20.7__py3-none-any.whl → 1.20.9__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.

@@ -386,12 +386,6 @@ class Runs(CreateMixin, CancelMixin, ListObjectMixin, GetStatusMixin,
386
386
  thread_id=thread_id,
387
387
  workspace=workspace,
388
388
  api_key=api_key)
389
- import json
390
- print(
391
- json.dumps(run,
392
- default=lambda o: o.__dict__,
393
- sort_keys=True,
394
- indent=4))
395
389
  if run.status_code == HTTPStatus.OK:
396
390
  if hasattr(run, 'status'):
397
391
  if run.status in [
@@ -121,8 +121,51 @@ def upload_file(model: str, upload_path: str, api_key: str):
121
121
  return None
122
122
 
123
123
 
124
+ def check_and_upload_local(model: str, content: str, api_key: str):
125
+ """Check the content is local file path, upload and return the url
126
+
127
+ Args:
128
+ model (str): Which model to upload.
129
+ content (str): The content.
130
+ api_key (_type_): The api key.
131
+
132
+ Raises:
133
+ UploadFileException: Upload failed.
134
+ InvalidInput: The input is invalid
135
+
136
+ Returns:
137
+ _type_: if upload return True and file_url otherwise False, origin content.
138
+ """
139
+ if content.startswith(FILE_PATH_SCHEMA):
140
+ parse_result = urlparse(content)
141
+ if parse_result.netloc:
142
+ file_path = parse_result.netloc + unquote_plus(parse_result.path)
143
+ else:
144
+ file_path = unquote_plus(parse_result.path)
145
+ if os.path.exists(file_path):
146
+ file_url = OssUtils.upload(model=model,
147
+ file_path=file_path,
148
+ api_key=api_key)
149
+ if file_url is None:
150
+ raise UploadFileException('Uploading file: %s failed' %
151
+ content)
152
+ return True, file_url
153
+ else:
154
+ raise InvalidInput('The file: %s is not exists!' % file_path)
155
+ elif not content.startswith('http'):
156
+ if os.path.exists(content):
157
+ file_url = OssUtils.upload(model=model,
158
+ file_path=content,
159
+ api_key=api_key)
160
+ if file_url is None:
161
+ raise UploadFileException('Uploading file: %s failed' %
162
+ content)
163
+ return True, file_url
164
+ return False, content
165
+
166
+
124
167
  def check_and_upload(model, elem: dict, api_key):
125
- is_upload = False
168
+ has_upload = False
126
169
  for key, content in elem.items():
127
170
  # support video:[images] for qwen2-vl
128
171
  is_list = isinstance(content, list)
@@ -130,38 +173,14 @@ def check_and_upload(model, elem: dict, api_key):
130
173
 
131
174
  if key in ['image', 'video', 'audio', 'text']:
132
175
  for i, content in enumerate(contents):
133
- if content.startswith(FILE_PATH_SCHEMA):
134
- parse_result = urlparse(content)
135
- if parse_result.netloc:
136
- file_path = parse_result.netloc + unquote_plus(
137
- parse_result.path)
138
- else:
139
- file_path = unquote_plus(parse_result.path)
140
- if os.path.exists(file_path):
141
- file_url = OssUtils.upload(model=model,
142
- file_path=file_path,
143
- api_key=api_key)
144
- if file_url is None:
145
- raise UploadFileException(
146
- 'Uploading file: %s failed' % content)
147
- contents[i] = file_url
148
- is_upload = True
149
- else:
150
- raise InvalidInput('The file: %s is not exists!' %
151
- file_path)
152
- elif not content.startswith('http'):
153
- if os.path.exists(content):
154
- file_url = OssUtils.upload(model=model,
155
- file_path=content,
156
- api_key=api_key)
157
- if file_url is None:
158
- raise UploadFileException(
159
- 'Uploading file: %s failed' % content)
160
- contents[i] = file_url
161
- is_upload = True
176
+ is_upload, file_url = check_and_upload_local(
177
+ model, content, api_key)
178
+ if is_upload:
179
+ contents[i] = file_url
180
+ has_upload = True
162
181
  elem[key] = contents if is_list else contents[0]
163
182
 
164
- return is_upload
183
+ return has_upload
165
184
 
166
185
 
167
186
  def preprocess_message_element(model: str, elem: List[dict], api_key: str):
dashscope/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '1.20.7'
1
+ __version__ = '1.20.9'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dashscope
3
- Version: 1.20.7
3
+ Version: 1.20.9
4
4
  Summary: dashscope client sdk library
5
5
  Home-page: https://dashscope.aliyun.com/
6
6
  Author: Alibaba Cloud
@@ -18,7 +18,6 @@ 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
22
21
  Requires-Dist: aiohttp
23
22
  Requires-Dist: requests
24
23
  Requires-Dist: websocket-client
@@ -222,3 +221,5 @@ Coming soon.
222
221
 
223
222
  ## License
224
223
  This project is licensed under the Apache License (Version 2.0).
224
+
225
+
@@ -1,14 +1,17 @@
1
1
  dashscope/__init__.py,sha256=lIBZR5fWUiO1L62J_17Gri7Dwk9kCf2xhWl8eRw8bkQ,2933
2
2
  dashscope/cli.py,sha256=amegoTkGOs6TlHMdoo4JVOqBePo3lGs745rc7leEyrE,24020
3
+ dashscope/deployment.py,sha256=ljmVi-ny6SjEs8v4oIGNWIw8UQTorE7dl5QJv7dEPIQ,5728
4
+ dashscope/file.py,sha256=Dv2Fz3DLbcye2uuQxyQwRM7ky27OthouLXIpSQagQy4,3324
3
5
  dashscope/files.py,sha256=QgJjwhtn9F548nCA8jD8OvE6aQEj-20hZqJgYXsUdQU,3930
6
+ dashscope/finetune.py,sha256=_tflDUvu0KagSoCzLaf0hofpG_P8NU6PylL8CPjVhrA,6243
4
7
  dashscope/model.py,sha256=UPOn1qMYFhX-ovXi3BMxZEBk8qOK7WLJOYHMbPZwYBo,1440
5
8
  dashscope/models.py,sha256=1-bc-Ue68zurgu_y6RhfFr9uzeQMF5AZq-C32lJGMGU,1224
6
- dashscope/version.py,sha256=gQu6hE6vB8heRmWsFGU7BDL4DsK0RiBB-W17n8BWDPA,23
9
+ dashscope/version.py,sha256=rW_OBoIurR44z0-gRCL1GiR4KuiexcDQ6XLZw1HMwZs,23
7
10
  dashscope/aigc/__init__.py,sha256=s-MCA87KYiVumYtKtJi5IMN7xelSF6TqEU3s3_7RF-Y,327
8
11
  dashscope/aigc/code_generation.py,sha256=KAJVrGp6tiNFBBg64Ovs9RfcP5SrIhrbW3wdA89NKso,10885
9
12
  dashscope/aigc/conversation.py,sha256=xRoJlCR-IXHjSdkDrK74a9ut1FJg0FZhTNXZAJC18MA,14231
10
13
  dashscope/aigc/generation.py,sha256=53oMCmN5ZbqeqAsKxmdunXlRh-XP8ZtnA7hB2id4Koo,17897
11
- dashscope/aigc/image_synthesis.py,sha256=_TGkh4L_yBNQNmoJUKlfXfljKfxX-SSyxHHQBDm1AC8,10418
14
+ dashscope/aigc/image_synthesis.py,sha256=UWHW-nvf7_aDZKr4uZDusVHjqWr9TSZjCsZI8YSWaek,11052
12
15
  dashscope/aigc/multimodal_conversation.py,sha256=SlNnnsUPV19gdx8fYJAtsMFWPNGY6vhk5IGHZ5ZczpI,5369
13
16
  dashscope/api_entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
17
  dashscope/api_entities/aiohttp_request.py,sha256=aE3AeWba8Ig_xHMYjrAdkq0N61l_L2VFTG6HYh912X0,10229
@@ -29,6 +32,7 @@ dashscope/audio/__init__.py,sha256=-ZRxrK-gV4QsUtlThIT-XwqB6vmyEsnhxIxdLmhCUuc,6
29
32
  dashscope/audio/asr/__init__.py,sha256=-s180qWn_JPSpCo1q0aDJJ5HQ3zTzD4z5yUwsRqH4aU,275
30
33
  dashscope/audio/asr/asr_phrase_manager.py,sha256=EjtbI3zz9UQGS1qv6Yb4zzEMj4OJJVXmwkqZyIrzvEA,7642
31
34
  dashscope/audio/asr/recognition.py,sha256=cEooE3wGf8kKfJIVbaXEytl5X6F0hMsLe8g4Bj9Fn4w,18768
35
+ dashscope/audio/asr/transcribe.py,sha256=HfZYpvpVfvGRAIIIzX65Af33E6vsIFGd_qqhQ8LaNcM,9651
32
36
  dashscope/audio/asr/transcription.py,sha256=1WAg9WH89antVzRYEKXb5LQP9xylZmX4YKp7v5oMYjY,8931
33
37
  dashscope/audio/tts/__init__.py,sha256=fbnieZX9yNFNh5BsxLpLXb63jlxzxrdCJakV3ignjlQ,194
34
38
  dashscope/audio/tts/speech_synthesizer.py,sha256=dnKx9FDDdO_ETHAjhK8zaMVaH6SfoTtN5YxXXqgY1JA,7571
@@ -62,6 +66,7 @@ dashscope/protocol/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
62
66
  dashscope/protocol/websocket.py,sha256=z-v6PGx3L4zYBANuC48s7SWSQSwRCDoh0zcfhv9Bf8U,561
63
67
  dashscope/rerank/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
68
  dashscope/rerank/text_rerank.py,sha256=1L-RLUxMCvNhbMud1FUG6YFWT7ZV979fzhMEuVjJ1oI,2398
69
+ dashscope/resources/qwen.tiktoken,sha256=srG437XMXwJLr8NzEhxquj9m-aWgJp4kNHCh3hajMYY,2561218
65
70
  dashscope/threads/__init__.py,sha256=md5bsHekHHGOg3uQrBCk8f4BCNnA1AuI_-LDf92pNVU,621
66
71
  dashscope/threads/thread_types.py,sha256=SwAJNi-RbqFXlrztDUCt0q0MfgfJLHyYl9qWrQDmQQo,18280
67
72
  dashscope/threads/threads.py,sha256=dD72xklN71KFGBVoBVHEbCbZADwLbi9yGS9LbFpnlAI,7665
@@ -69,7 +74,7 @@ dashscope/threads/messages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
69
74
  dashscope/threads/messages/files.py,sha256=wi0nJ2zsPWOw2Jn-ZkxA3URZBIrkGxqM_uAPfXY1xv0,3820
70
75
  dashscope/threads/messages/messages.py,sha256=Zjmyf3rT1XSdn33hPrqOY6DSWUVL7pDEapG03FREPV8,8419
71
76
  dashscope/threads/runs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
- dashscope/threads/runs/runs.py,sha256=Cvy5FD0x1Z9c5qayYeNpoL_QIqH4yxgqdGplCk3soRw,18762
77
+ dashscope/threads/runs/runs.py,sha256=ux4VH_lxxHCw1XOqngzmsm9kwTR3jS0wX27xoAswHlY,18549
73
78
  dashscope/threads/runs/steps.py,sha256=pLNR-5g7zvYkvC-p4sZGVgYHd1jqxBerM2WFyB358H8,3638
74
79
  dashscope/tokenizers/__init__.py,sha256=Oy5FMT37Non6e1YxdHQ89U93Dy3CG1Ez0gBa771KZo0,200
75
80
  dashscope/tokenizers/qwen_tokenizer.py,sha256=dCnT9-9NrqPS85bEhjlPULUfDADVRhlleYwM_ILgCeI,4111
@@ -77,10 +82,10 @@ dashscope/tokenizers/tokenization.py,sha256=G6cSEmVLr3pjXUC3EOU9ot8MYxNnOQ4wOB2m
77
82
  dashscope/tokenizers/tokenizer.py,sha256=y6P91qTCYo__pEx_0VHAcj9YECfbUdRqZU1fdGTjF4o,1154
78
83
  dashscope/tokenizers/tokenizer_base.py,sha256=REDhzRyDT13iequ61-a6_KcTy0GFKlihQve5HkyoyRs,656
79
84
  dashscope/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
80
- dashscope/utils/oss_utils.py,sha256=TSBh7MJK4ZH40Mxd8wNEsG8nQLNhQjWRjW3itHsvoZ0,7023
81
- dashscope-1.20.7.dist-info/LICENSE,sha256=Izp5L1DF1Mbza6qojkqNNWlE_mYLnr4rmzx2EBF8YFw,11413
82
- dashscope-1.20.7.dist-info/METADATA,sha256=BBs0rgqbL8wqwlTSjnlM8flMtvKrjGOhiOIsjZCT-xM,6661
83
- dashscope-1.20.7.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
84
- dashscope-1.20.7.dist-info/entry_points.txt,sha256=e9C3sOf9zDYL0O5ROEGX6FT8w-QK_kaGRWmPZDHAFys,49
85
- dashscope-1.20.7.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
86
- dashscope-1.20.7.dist-info/RECORD,,
85
+ dashscope/utils/oss_utils.py,sha256=7vZ2Lypxwiit8VcAqAvr3cCyhVfaLapDiNuF-H3ZCD4,7332
86
+ dashscope-1.20.9.dist-info/LICENSE,sha256=Izp5L1DF1Mbza6qojkqNNWlE_mYLnr4rmzx2EBF8YFw,11413
87
+ dashscope-1.20.9.dist-info/METADATA,sha256=n0YxcRTLCxVG5CnYICYV2ysSWYQMCYeG65bc7xsdYig,6641
88
+ dashscope-1.20.9.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
89
+ dashscope-1.20.9.dist-info/entry_points.txt,sha256=raEp5dOuj8whJ7yqZlDM8WQ5p2RfnGrGNo0QLQEnatY,50
90
+ dashscope-1.20.9.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
91
+ dashscope-1.20.9.dist-info/RECORD,,
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
2
  dashscope = dashscope.cli:main
3
+