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

@@ -11,10 +11,7 @@ import requests
11
11
 
12
12
  from dashscope.api_entities.dashscope_response import DashScopeAPIResponse
13
13
  from dashscope.client.base_api import GetMixin
14
- from dashscope.common.constants import (FILE_PATH_SCHEMA,
15
- REQUEST_CONTENT_AUDIO,
16
- REQUEST_CONTENT_IMAGE,
17
- REQUEST_CONTENT_TEXT)
14
+ from dashscope.common.constants import FILE_PATH_SCHEMA
18
15
  from dashscope.common.error import InvalidInput, UploadFileException
19
16
  from dashscope.common.logging import logger
20
17
  from dashscope.common.utils import get_user_agent
@@ -124,49 +121,41 @@ def upload_file(model: str, upload_path: str, api_key: str):
124
121
  return None
125
122
 
126
123
 
127
- def check_and_upload(model, elem: dict, key: str, api_key):
124
+ def check_and_upload(model, elem: dict, api_key):
128
125
  is_upload = False
129
- content = elem[key]
130
- if content.startswith(FILE_PATH_SCHEMA):
131
- parse_result = urlparse(content)
132
- if parse_result.netloc:
133
- file_path = parse_result.netloc + unquote_plus(parse_result.path)
134
- else:
135
- file_path = unquote_plus(parse_result.path)
136
- if os.path.exists(file_path):
137
- file_url = OssUtils.upload(model=model,
138
- file_path=file_path,
139
- api_key=api_key)
140
- if file_url is None:
141
- raise UploadFileException('Uploading file: %s failed' %
142
- content)
143
- elem[key] = file_url
144
- is_upload = True
145
- else:
146
- raise InvalidInput('The file: %s is not exists!' % file_path)
147
- elif not content.startswith('http'):
148
- if os.path.exists(content):
149
- file_url = OssUtils.upload(model=model,
150
- file_path=content,
151
- api_key=api_key)
152
- if file_url is None:
153
- raise UploadFileException('Uploading file: %s failed' %
154
- content)
155
- elem[key] = file_url
156
- is_upload = True
126
+ for key, content in elem.items():
127
+ if content.startswith(FILE_PATH_SCHEMA):
128
+ parse_result = urlparse(content)
129
+ if parse_result.netloc:
130
+ file_path = parse_result.netloc + unquote_plus(
131
+ parse_result.path)
132
+ else:
133
+ file_path = unquote_plus(parse_result.path)
134
+ if os.path.exists(file_path):
135
+ file_url = OssUtils.upload(model=model,
136
+ file_path=file_path,
137
+ api_key=api_key)
138
+ if file_url is None:
139
+ raise UploadFileException('Uploading file: %s failed' %
140
+ content)
141
+ elem[key] = file_url
142
+ is_upload = True
143
+ else:
144
+ raise InvalidInput('The file: %s is not exists!' % file_path)
145
+ elif not content.startswith('http'):
146
+ if os.path.exists(content):
147
+ file_url = OssUtils.upload(model=model,
148
+ file_path=content,
149
+ api_key=api_key)
150
+ if file_url is None:
151
+ raise UploadFileException('Uploading file: %s failed' %
152
+ content)
153
+ elem[key] = file_url
154
+ is_upload = True
157
155
 
158
156
  return is_upload
159
157
 
160
158
 
161
159
  def preprocess_message_element(model: str, elem: List[dict], api_key: str):
162
- is_upload = False
163
- if REQUEST_CONTENT_TEXT in elem:
164
- is_upload = check_and_upload(model, elem, REQUEST_CONTENT_TEXT,
165
- api_key)
166
- elif REQUEST_CONTENT_IMAGE in elem:
167
- is_upload = check_and_upload(model, elem, REQUEST_CONTENT_IMAGE,
168
- api_key)
169
- elif REQUEST_CONTENT_AUDIO in elem:
170
- is_upload = check_and_upload(model, elem, REQUEST_CONTENT_AUDIO,
171
- api_key)
160
+ is_upload = check_and_upload(model, elem, api_key)
172
161
  return is_upload
dashscope/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '1.20.3'
1
+ __version__ = '1.20.4'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dashscope
3
- Version: 1.20.3
3
+ Version: 1.20.4
4
4
  Summary: dashscope client sdk library
5
5
  Home-page: https://dashscope.aliyun.com/
6
6
  Author: Alibaba Cloud
@@ -6,7 +6,7 @@ dashscope/files.py,sha256=QgJjwhtn9F548nCA8jD8OvE6aQEj-20hZqJgYXsUdQU,3930
6
6
  dashscope/finetune.py,sha256=_tflDUvu0KagSoCzLaf0hofpG_P8NU6PylL8CPjVhrA,6243
7
7
  dashscope/model.py,sha256=UPOn1qMYFhX-ovXi3BMxZEBk8qOK7WLJOYHMbPZwYBo,1440
8
8
  dashscope/models.py,sha256=1-bc-Ue68zurgu_y6RhfFr9uzeQMF5AZq-C32lJGMGU,1224
9
- dashscope/version.py,sha256=axe7tbDmiC_ViryS2MD_XVQpBGZsB2RQ0ksPIJnHWeo,23
9
+ dashscope/version.py,sha256=F9uXsS9G7U6denIIAr8vp6GOvDWEm4lYN6mAx36-rZE,23
10
10
  dashscope/aigc/__init__.py,sha256=s-MCA87KYiVumYtKtJi5IMN7xelSF6TqEU3s3_7RF-Y,327
11
11
  dashscope/aigc/code_generation.py,sha256=KAJVrGp6tiNFBBg64Ovs9RfcP5SrIhrbW3wdA89NKso,10885
12
12
  dashscope/aigc/conversation.py,sha256=xRoJlCR-IXHjSdkDrK74a9ut1FJg0FZhTNXZAJC18MA,14231
@@ -81,10 +81,10 @@ dashscope/tokenizers/tokenization.py,sha256=G6cSEmVLr3pjXUC3EOU9ot8MYxNnOQ4wOB2m
81
81
  dashscope/tokenizers/tokenizer.py,sha256=y6P91qTCYo__pEx_0VHAcj9YECfbUdRqZU1fdGTjF4o,1154
82
82
  dashscope/tokenizers/tokenizer_base.py,sha256=REDhzRyDT13iequ61-a6_KcTy0GFKlihQve5HkyoyRs,656
83
83
  dashscope/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
84
- dashscope/utils/oss_utils.py,sha256=fi8-PPsN-iR-iv5k2NS5Z8nlWkpgUhr56FRWm4BDh4A,6984
85
- dashscope-1.20.3.dist-info/LICENSE,sha256=Izp5L1DF1Mbza6qojkqNNWlE_mYLnr4rmzx2EBF8YFw,11413
86
- dashscope-1.20.3.dist-info/METADATA,sha256=JUS8qY6hiQtwyE2f65w3JBnaqUsyhAV3kfwE-4KkSoM,6641
87
- dashscope-1.20.3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
88
- dashscope-1.20.3.dist-info/entry_points.txt,sha256=raEp5dOuj8whJ7yqZlDM8WQ5p2RfnGrGNo0QLQEnatY,50
89
- dashscope-1.20.3.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
90
- dashscope-1.20.3.dist-info/RECORD,,
84
+ dashscope/utils/oss_utils.py,sha256=Ha4VdeO5D4lHa-xE3-iUdZFOsHS5pe_Oz1Tg5P605bY,6487
85
+ dashscope-1.20.4.dist-info/LICENSE,sha256=Izp5L1DF1Mbza6qojkqNNWlE_mYLnr4rmzx2EBF8YFw,11413
86
+ dashscope-1.20.4.dist-info/METADATA,sha256=2r20We1APpu60VMdSe6UXLYXuHXywQZC-hkGyF-RYRc,6641
87
+ dashscope-1.20.4.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
88
+ dashscope-1.20.4.dist-info/entry_points.txt,sha256=raEp5dOuj8whJ7yqZlDM8WQ5p2RfnGrGNo0QLQEnatY,50
89
+ dashscope-1.20.4.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
90
+ dashscope-1.20.4.dist-info/RECORD,,