dashscope 1.13.0__py3-none-any.whl → 1.13.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/aigc/conversation.py +27 -4
- dashscope/aigc/generation.py +22 -3
- dashscope/aigc/image_synthesis.py +25 -7
- dashscope/aigc/multimodal_conversation.py +4 -2
- dashscope/utils/oss_utils.py +5 -1
- dashscope/version.py +1 -1
- {dashscope-1.13.0.dist-info → dashscope-1.13.2.dist-info}/METADATA +1 -1
- {dashscope-1.13.0.dist-info → dashscope-1.13.2.dist-info}/RECORD +12 -12
- {dashscope-1.13.0.dist-info → dashscope-1.13.2.dist-info}/LICENSE +0 -0
- {dashscope-1.13.0.dist-info → dashscope-1.13.2.dist-info}/WHEEL +0 -0
- {dashscope-1.13.0.dist-info → dashscope-1.13.2.dist-info}/entry_points.txt +0 -0
- {dashscope-1.13.0.dist-info → dashscope-1.13.2.dist-info}/top_level.txt +0 -0
dashscope/aigc/conversation.py
CHANGED
|
@@ -100,6 +100,7 @@ class Conversation(BaseApi):
|
|
|
100
100
|
|
|
101
101
|
qwen_turbo = 'qwen-turbo'
|
|
102
102
|
qwen_plus = 'qwen-plus'
|
|
103
|
+
qen_max = 'qwen-max'
|
|
103
104
|
|
|
104
105
|
def __init__(self, history: History = None) -> None:
|
|
105
106
|
"""Init a chat.
|
|
@@ -171,15 +172,37 @@ class Conversation(BaseApi):
|
|
|
171
172
|
tokens with top_p probability mass. So 0.1 means only
|
|
172
173
|
the tokens comprising the top 10% probability mass are
|
|
173
174
|
considered.
|
|
175
|
+
top_k(int, `optional`): The size of the sample candidate set when generated. # noqa E501
|
|
176
|
+
For example, when the value is 50, only the 50 highest-scoring tokens # noqa E501
|
|
177
|
+
in a single generation form a randomly sampled candidate set. # noqa E501
|
|
178
|
+
The larger the value, the higher the randomness generated; # noqa E501
|
|
179
|
+
the smaller the value, the higher the certainty generated. # noqa E501
|
|
180
|
+
The default value is 0, which means the top_k policy is # noqa E501
|
|
181
|
+
not enabled. At this time, only the top_p policy takes effect. # noqa E501
|
|
174
182
|
enable_search(bool, `optional`): Whether to enable web search(quark). # noqa E501
|
|
175
183
|
Currently works best only on the first round of conversation.
|
|
176
|
-
Default to False.
|
|
184
|
+
Default to False, support model: [qwen-turbo].
|
|
185
|
+
customized_model_id(str, required) The enterprise-specific
|
|
186
|
+
large model id, which needs to be generated from the
|
|
187
|
+
operation background of the enterprise-specific
|
|
188
|
+
large model product, support model: [bailian-v1].
|
|
177
189
|
result_format(str, `optional`): [message|text] Set result result format. # noqa E501
|
|
178
190
|
Default result is text
|
|
179
|
-
|
|
191
|
+
incremental_output(bool, `optional`): Used to control the streaming output mode. # noqa E501
|
|
180
192
|
If true, the subsequent output will include the previously input content. # noqa E501
|
|
181
|
-
Otherwise, the subsequent output will not include the previously output
|
|
182
|
-
content. Default
|
|
193
|
+
Otherwise, the subsequent output will not include the previously output # noqa E501
|
|
194
|
+
content. Default false.
|
|
195
|
+
stop(list[str] or list[list[int]], `optional`): Used to control the generation to stop # noqa E501
|
|
196
|
+
when encountering setting str or token ids, the result will not include # noqa E501
|
|
197
|
+
stop words or tokens.
|
|
198
|
+
max_tokens(int, `optional`): The maximum token num expected to be output. It should be # noqa E501
|
|
199
|
+
noted that the length generated by the model will only be less than max_tokens, # noqa E501
|
|
200
|
+
not necessarily equal to it. If max_tokens is set too large, the service will # noqa E501
|
|
201
|
+
directly prompt that the length exceeds the limit. It is generally # noqa E501
|
|
202
|
+
not recommended to set this value.
|
|
203
|
+
repetition_penalty(float, `optional`): Used to control the repeatability when generating models. # noqa E501
|
|
204
|
+
Increasing repetition_penalty can reduce the duplication of model generation. # noqa E501
|
|
205
|
+
1.0 means no punishment.
|
|
183
206
|
Raises:
|
|
184
207
|
InputRequired: The prompt cannot be empty.
|
|
185
208
|
InvalidInput: The history and auto_history are mutually exclusive.
|
dashscope/aigc/generation.py
CHANGED
|
@@ -28,6 +28,7 @@ class Generation(BaseApi):
|
|
|
28
28
|
dolly_12b_v2 = 'dolly-12b-v2'
|
|
29
29
|
qwen_turbo = 'qwen-turbo'
|
|
30
30
|
qwen_plus = 'qwen-plus'
|
|
31
|
+
qen_max = 'qwen-max'
|
|
31
32
|
|
|
32
33
|
@classmethod
|
|
33
34
|
def call(
|
|
@@ -78,6 +79,13 @@ class Generation(BaseApi):
|
|
|
78
79
|
tokens with top_p probability mass. So 0.1 means only
|
|
79
80
|
the tokens comprising the top 10% probability mass are
|
|
80
81
|
considered[qwen-turbo,bailian-v1].
|
|
82
|
+
top_k(int, `optional`): The size of the sample candidate set when generated. # noqa E501
|
|
83
|
+
For example, when the value is 50, only the 50 highest-scoring tokens # noqa E501
|
|
84
|
+
in a single generation form a randomly sampled candidate set. # noqa E501
|
|
85
|
+
The larger the value, the higher the randomness generated; # noqa E501
|
|
86
|
+
the smaller the value, the higher the certainty generated. # noqa E501
|
|
87
|
+
The default value is 0, which means the top_k policy is # noqa E501
|
|
88
|
+
not enabled. At this time, only the top_p policy takes effect. # noqa E501
|
|
81
89
|
enable_search(bool, `optional`): Whether to enable web search(quark). # noqa E501
|
|
82
90
|
Currently works best only on the first round of conversation.
|
|
83
91
|
Default to False, support model: [qwen-turbo].
|
|
@@ -87,10 +95,21 @@ class Generation(BaseApi):
|
|
|
87
95
|
large model product, support model: [bailian-v1].
|
|
88
96
|
result_format(str, `optional`): [message|text] Set result result format. # noqa E501
|
|
89
97
|
Default result is text
|
|
90
|
-
|
|
98
|
+
incremental_output(bool, `optional`): Used to control the streaming output mode. # noqa E501
|
|
91
99
|
If true, the subsequent output will include the previously input content. # noqa E501
|
|
92
|
-
Otherwise, the subsequent output will not include the previously output
|
|
93
|
-
content. Default
|
|
100
|
+
Otherwise, the subsequent output will not include the previously output # noqa E501
|
|
101
|
+
content. Default false.
|
|
102
|
+
stop(list[str] or list[list[int]], `optional`): Used to control the generation to stop # noqa E501
|
|
103
|
+
when encountering setting str or token ids, the result will not include # noqa E501
|
|
104
|
+
stop words or tokens.
|
|
105
|
+
max_tokens(int, `optional`): The maximum token num expected to be output. It should be # noqa E501
|
|
106
|
+
noted that the length generated by the model will only be less than max_tokens, # noqa E501
|
|
107
|
+
not necessarily equal to it. If max_tokens is set too large, the service will # noqa E501
|
|
108
|
+
directly prompt that the length exceeds the limit. It is generally # noqa E501
|
|
109
|
+
not recommended to set this value.
|
|
110
|
+
repetition_penalty(float, `optional`): Used to control the repeatability when generating models. # noqa E501
|
|
111
|
+
Increasing repetition_penalty can reduce the duplication of model generation. # noqa E501
|
|
112
|
+
1.0 means no punishment.
|
|
94
113
|
Raises:
|
|
95
114
|
InvalidInput: The history and auto_history are mutually exclusive.
|
|
96
115
|
|
|
@@ -14,6 +14,7 @@ class ImageSynthesis(BaseAsyncApi):
|
|
|
14
14
|
"""
|
|
15
15
|
class Models:
|
|
16
16
|
wanx_v1 = 'wanx-v1'
|
|
17
|
+
wanx_sketch_to_image_v1 = 'wanx-sketch-to-image-v1'
|
|
17
18
|
|
|
18
19
|
@classmethod
|
|
19
20
|
def call(cls,
|
|
@@ -22,6 +23,7 @@ class ImageSynthesis(BaseAsyncApi):
|
|
|
22
23
|
negative_prompt: Any = None,
|
|
23
24
|
images: List[str] = None,
|
|
24
25
|
api_key: str = None,
|
|
26
|
+
sketch_image_url: str = None,
|
|
25
27
|
**kwargs) -> ImageSynthesisResponse:
|
|
26
28
|
"""Call image(s) synthesis service and get result.
|
|
27
29
|
|
|
@@ -29,16 +31,21 @@ class ImageSynthesis(BaseAsyncApi):
|
|
|
29
31
|
model (str): The model, reference ``Models``.
|
|
30
32
|
prompt (Any): The prompt for image(s) synthesis.
|
|
31
33
|
negative_prompt (Any): The negative_prompt. Defaults to None.
|
|
32
|
-
images (List[str]): The input list of images url
|
|
34
|
+
images (List[str]): The input list of images url,
|
|
35
|
+
currently not supported.
|
|
33
36
|
api_key (str, optional): The api api_key. Defaults to None.
|
|
37
|
+
sketch_image_url (str, optional): Only for wanx-sketch-to-image-v1.
|
|
38
|
+
Defaults to None.
|
|
34
39
|
**kwargs:
|
|
35
|
-
n(int, `optional`): Number of images to synthesis
|
|
36
|
-
|
|
37
|
-
size(str, `optional`): The output image(s) size(width*height),
|
|
38
|
-
Currently fixed at 1024*1024. Default 1024*1024
|
|
40
|
+
n(int, `optional`): Number of images to synthesis.
|
|
41
|
+
size(str, `optional`): The output image(s) size(width*height).
|
|
39
42
|
similarity(float, `optional`): The similarity between the
|
|
40
43
|
output image and the input image
|
|
41
|
-
|
|
44
|
+
sketch_weight(int, optional): How much the input sketch
|
|
45
|
+
affects the output image[0-10], only for wanx-sketch-to-image-v1. # noqa E501
|
|
46
|
+
Default 10.
|
|
47
|
+
realisticness(int, optional): The realisticness of the output
|
|
48
|
+
image[0-10], only for wanx-sketch-to-image-v1. Default 5
|
|
42
49
|
|
|
43
50
|
Raises:
|
|
44
51
|
InputRequired: The prompt cannot be empty.
|
|
@@ -51,6 +58,7 @@ class ImageSynthesis(BaseAsyncApi):
|
|
|
51
58
|
negative_prompt,
|
|
52
59
|
images,
|
|
53
60
|
api_key=api_key,
|
|
61
|
+
sketch_image_url=sketch_image_url,
|
|
54
62
|
**kwargs)
|
|
55
63
|
|
|
56
64
|
@classmethod
|
|
@@ -60,6 +68,7 @@ class ImageSynthesis(BaseAsyncApi):
|
|
|
60
68
|
negative_prompt: Any = None,
|
|
61
69
|
images: List[str] = None,
|
|
62
70
|
api_key: str = None,
|
|
71
|
+
sketch_image_url: str = None,
|
|
63
72
|
**kwargs) -> ImageSynthesisResponse:
|
|
64
73
|
"""Create a image(s) synthesis task, and return task information.
|
|
65
74
|
|
|
@@ -69,11 +78,18 @@ class ImageSynthesis(BaseAsyncApi):
|
|
|
69
78
|
negative_prompt (Any): The negative_prompt. Defaults to None.
|
|
70
79
|
images (List[str]): The input list of images url.
|
|
71
80
|
api_key (str, optional): The api api_key. Defaults to None.
|
|
81
|
+
sketch_image_url (str, optional): Only for wanx-sketch-to-image-v1.
|
|
82
|
+
Defaults to None.
|
|
72
83
|
**kwargs(wanx-v1):
|
|
73
84
|
n(int, `optional`): Number of images to synthesis.
|
|
74
85
|
size: The output image(s) size, Default 1024*1024
|
|
75
86
|
similarity(float, `optional`): The similarity between the
|
|
76
|
-
output image and the input image
|
|
87
|
+
output image and the input image.
|
|
88
|
+
sketch_weight(int, optional): How much the input sketch
|
|
89
|
+
affects the output image[0-10], only for wanx-sketch-to-image-v1. # noqa E501
|
|
90
|
+
Default 10.
|
|
91
|
+
realisticness(int, optional): The realisticness of the output
|
|
92
|
+
image[0-10], only for wanx-sketch-to-image-v1. Default 5
|
|
77
93
|
|
|
78
94
|
Raises:
|
|
79
95
|
InputRequired: The prompt cannot be empty.
|
|
@@ -90,6 +106,8 @@ class ImageSynthesis(BaseAsyncApi):
|
|
|
90
106
|
input[NEGATIVE_PROMPT] = negative_prompt
|
|
91
107
|
if images is not None:
|
|
92
108
|
input[IMAGES] = images
|
|
109
|
+
if sketch_image_url is not None and sketch_image_url:
|
|
110
|
+
input['sketch_image_url'] = sketch_image_url
|
|
93
111
|
response = super().async_call(model=model,
|
|
94
112
|
task_group=task_group,
|
|
95
113
|
task=ImageSynthesis.task,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import copy
|
|
1
2
|
from typing import Generator, List, Union
|
|
2
3
|
|
|
3
4
|
from dashscope.api_entities.dashscope_response import \
|
|
@@ -78,12 +79,13 @@ class MultiModalConversation(BaseApi):
|
|
|
78
79
|
if model is None or not model:
|
|
79
80
|
raise ModelRequired('Model is required!')
|
|
80
81
|
task_group, _ = _get_task_group_and_task(__name__)
|
|
81
|
-
|
|
82
|
+
msg_copy = copy.deepcopy(messages)
|
|
83
|
+
has_upload = cls._preprocess_messages(model, msg_copy, api_key)
|
|
82
84
|
if has_upload:
|
|
83
85
|
headers = kwargs.pop('headers', {})
|
|
84
86
|
headers['X-DashScope-OssResourceResolve'] = 'enable'
|
|
85
87
|
kwargs['headers'] = headers
|
|
86
|
-
input = {'messages':
|
|
88
|
+
input = {'messages': msg_copy}
|
|
87
89
|
response = super().call(model=model,
|
|
88
90
|
task_group=task_group,
|
|
89
91
|
task=MultiModalConversation.task,
|
dashscope/utils/oss_utils.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import mimetypes
|
|
1
2
|
import os
|
|
2
3
|
from datetime import datetime
|
|
3
4
|
from http import HTTPStatus
|
|
@@ -13,7 +14,7 @@ from dashscope.common.constants import (FILE_PATH_SCHEMA,
|
|
|
13
14
|
REQUEST_CONTENT_AUDIO,
|
|
14
15
|
REQUEST_CONTENT_IMAGE,
|
|
15
16
|
REQUEST_CONTENT_TEXT)
|
|
16
|
-
from dashscope.common.error import UploadFileException
|
|
17
|
+
from dashscope.common.error import InvalidInput, UploadFileException
|
|
17
18
|
from dashscope.common.logging import logger
|
|
18
19
|
from dashscope.common.utils import get_user_agent
|
|
19
20
|
|
|
@@ -64,6 +65,7 @@ class OssUtils(GetMixin):
|
|
|
64
65
|
form_data['x-oss-forbid-overwrite'] = upload_info[
|
|
65
66
|
'x_oss_forbid_overwrite']
|
|
66
67
|
form_data['success_action_status'] = '200'
|
|
68
|
+
form_data['x-oss-content-type'] = mimetypes.guess_type(file_path)[0]
|
|
67
69
|
url = upload_info['upload_host']
|
|
68
70
|
files = {'file': open(file_path, 'rb')}
|
|
69
71
|
with requests.Session() as session:
|
|
@@ -112,6 +114,8 @@ def check_and_upload(model, elem: dict, key: str, api_key):
|
|
|
112
114
|
content)
|
|
113
115
|
elem[key] = file_url
|
|
114
116
|
is_upload = True
|
|
117
|
+
else:
|
|
118
|
+
raise InvalidInput('The file: %s is not exists!' % file_path)
|
|
115
119
|
return is_upload
|
|
116
120
|
|
|
117
121
|
|
dashscope/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '1.13.
|
|
1
|
+
__version__ = '1.13.2'
|
|
@@ -4,13 +4,13 @@ dashscope/deployment.py,sha256=uhlQYOiu1baMQxQnFmRwI6ces0I-_DKp8uej_L0v1eY,4400
|
|
|
4
4
|
dashscope/file.py,sha256=Dv2Fz3DLbcye2uuQxyQwRM7ky27OthouLXIpSQagQy4,3324
|
|
5
5
|
dashscope/finetune.py,sha256=5QlIcnFCfSjN3gn9A2FO0kLUDa9Rx_jSc44ezT3aBEo,5118
|
|
6
6
|
dashscope/model.py,sha256=iuIfal-vOo0yav0HXPdA7f93vd5JNTGIAdCG_WIYkW8,1158
|
|
7
|
-
dashscope/version.py,sha256=
|
|
7
|
+
dashscope/version.py,sha256=VBBsQLpPZXlY1ESE6pAXYNUQLhcteUIvGwOsPHrTOs4,23
|
|
8
8
|
dashscope/aigc/__init__.py,sha256=s-MCA87KYiVumYtKtJi5IMN7xelSF6TqEU3s3_7RF-Y,327
|
|
9
9
|
dashscope/aigc/code_generation.py,sha256=bizJb3zGZx3pB74FKMIcnOi_6jkxpKgx__6urzqhQ_E,10627
|
|
10
|
-
dashscope/aigc/conversation.py,sha256=
|
|
11
|
-
dashscope/aigc/generation.py,sha256=
|
|
12
|
-
dashscope/aigc/image_synthesis.py,sha256=
|
|
13
|
-
dashscope/aigc/multimodal_conversation.py,sha256=
|
|
10
|
+
dashscope/aigc/conversation.py,sha256=_-LcNzeSG82Gjo1HzyI3eQxmgLVKSC7llUnjRjvYC_4,14089
|
|
11
|
+
dashscope/aigc/generation.py,sha256=4nOaejsgyK3Qh_orcbWbao1NCNtklBa7OdqnAczysgU,9909
|
|
12
|
+
dashscope/aigc/image_synthesis.py,sha256=Y20B_hpCe-uLKR661hvFpjQVk9jFfNtiPpiBkYiHAA0,8996
|
|
13
|
+
dashscope/aigc/multimodal_conversation.py,sha256=D5JYLLxwdGsgCrYeF0gNvE1kR5Vbmq1g0MiRU-4hlZQ,5228
|
|
14
14
|
dashscope/api_entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
dashscope/api_entities/aiohttp_request.py,sha256=1WuvODWcm-merZnAFpxV2Y9QohcB3hSGS_YkwK18O7g,10359
|
|
16
16
|
dashscope/api_entities/api_request_data.py,sha256=JUMcfpJjKXEZLCBSFIDpgoaeQYk5uK9-CwhM4OHIHFQ,5463
|
|
@@ -50,10 +50,10 @@ dashscope/protocol/websocket.py,sha256=z-v6PGx3L4zYBANuC48s7SWSQSwRCDoh0zcfhv9Bf
|
|
|
50
50
|
dashscope/tokenizers/__init__.py,sha256=zRNBe3ONNOA3T2gnxhlG3PTjkVOQBUYotMMJAruyk70,71
|
|
51
51
|
dashscope/tokenizers/tokenization.py,sha256=WhSdiH0Bu-pGQCsJfC91LL_y5tVDzCtQ7tTs2Tox-HY,4543
|
|
52
52
|
dashscope/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
|
-
dashscope/utils/oss_utils.py,sha256=
|
|
54
|
-
dashscope-1.13.
|
|
55
|
-
dashscope-1.13.
|
|
56
|
-
dashscope-1.13.
|
|
57
|
-
dashscope-1.13.
|
|
58
|
-
dashscope-1.13.
|
|
59
|
-
dashscope-1.13.
|
|
53
|
+
dashscope/utils/oss_utils.py,sha256=arw_ZbRefOrWwzyE7l1HBz8VQcbwNfmEfJHB2-TCVp8,5330
|
|
54
|
+
dashscope-1.13.2.dist-info/LICENSE,sha256=Izp5L1DF1Mbza6qojkqNNWlE_mYLnr4rmzx2EBF8YFw,11413
|
|
55
|
+
dashscope-1.13.2.dist-info/METADATA,sha256=kQwr3xgT8vpMECyTf_bHaUMtAJZ1go4pPsvxFktrN-s,7220
|
|
56
|
+
dashscope-1.13.2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
57
|
+
dashscope-1.13.2.dist-info/entry_points.txt,sha256=raEp5dOuj8whJ7yqZlDM8WQ5p2RfnGrGNo0QLQEnatY,50
|
|
58
|
+
dashscope-1.13.2.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
|
|
59
|
+
dashscope-1.13.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|