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

@@ -19,6 +19,8 @@ class ImageSynthesis(BaseAsyncApi):
19
19
  wanx_v1 = 'wanx-v1'
20
20
  wanx_sketch_to_image_v1 = 'wanx-sketch-to-image-v1'
21
21
 
22
+ wanx_2_1_imageedit = 'wanx2.1-imageedit'
23
+
22
24
  @classmethod
23
25
  def call(cls,
24
26
  model: str,
@@ -31,6 +33,9 @@ class ImageSynthesis(BaseAsyncApi):
31
33
  workspace: str = None,
32
34
  extra_input: Dict = None,
33
35
  task: str = None,
36
+ function: str = None,
37
+ mask_image_url: str = None,
38
+ base_image_url: str = None,
34
39
  **kwargs) -> ImageSynthesisResponse:
35
40
  """Call image(s) synthesis service and get result.
36
41
 
@@ -47,6 +52,11 @@ class ImageSynthesis(BaseAsyncApi):
47
52
  workspace (str): The dashscope workspace id.
48
53
  extra_input (Dict): The extra input parameters.
49
54
  task (str): The task of api, ref doc.
55
+ function (str): The specific functions to be achieved. like:
56
+ colorization,super_resolution,expand,remove_watermaker,doodle,
57
+ description_edit_with_mask,description_edit,stylization_local,stylization_all
58
+ base_image_url (str): Enter the URL address of the target edited image.
59
+ mask_image_url (str): Provide the URL address of the image of the marked area by the user. It should be consistent with the image resolution of the base_image_url.
50
60
  **kwargs:
51
61
  n(int, `optional`): Number of images to synthesis.
52
62
  size(str, `optional`): The output image(s) size(width*height).
@@ -74,6 +84,9 @@ class ImageSynthesis(BaseAsyncApi):
74
84
  workspace=workspace,
75
85
  extra_input=extra_input,
76
86
  task=task,
87
+ function=function,
88
+ mask_image_url=mask_image_url,
89
+ base_image_url=base_image_url,
77
90
  **kwargs)
78
91
 
79
92
  @classmethod
@@ -88,6 +101,9 @@ class ImageSynthesis(BaseAsyncApi):
88
101
  workspace: str = None,
89
102
  extra_input: Dict = None,
90
103
  task: str = None,
104
+ function: str = None,
105
+ mask_image_url: str = None,
106
+ base_image_url: str = None,
91
107
  **kwargs) -> ImageSynthesisResponse:
92
108
  """Create a image(s) synthesis task, and return task information.
93
109
 
@@ -102,6 +118,11 @@ class ImageSynthesis(BaseAsyncApi):
102
118
  workspace (str): The dashscope workspace id.
103
119
  extra_input (Dict): The extra input parameters.
104
120
  task (str): The task of api, ref doc.
121
+ function (str): The specific functions to be achieved. like:
122
+ colorization,super_resolution,expand,remove_watermaker,doodle,
123
+ description_edit_with_mask,description_edit,stylization_local,stylization_all
124
+ base_image_url (str): Enter the URL address of the target edited image.
125
+ mask_image_url (str): Provide the URL address of the image of the marked area by the user. It should be consistent with the image resolution of the base_image_url.
105
126
  **kwargs(wanx-v1):
106
127
  n(int, `optional`): Number of images to synthesis.
107
128
  size: The output image(s) size, Default 1024*1024
@@ -122,7 +143,7 @@ class ImageSynthesis(BaseAsyncApi):
122
143
  """
123
144
  if prompt is None or not prompt:
124
145
  raise InputRequired('prompt is required!')
125
- task_group, function = _get_task_group_and_task(__name__)
146
+ task_group, f = _get_task_group_and_task(__name__)
126
147
  input = {PROMPT: prompt}
127
148
  has_upload = False
128
149
  if negative_prompt is not None:
@@ -141,6 +162,24 @@ class ImageSynthesis(BaseAsyncApi):
141
162
  if is_upload:
142
163
  has_upload = True
143
164
  input['ref_img'] = ref_img
165
+
166
+ if function is not None and function:
167
+ input['function'] = function
168
+
169
+ if mask_image_url is not None and mask_image_url:
170
+ is_upload, res_mask_image_url = check_and_upload_local(
171
+ model, mask_image_url, api_key)
172
+ if is_upload:
173
+ has_upload = True
174
+ input['mask_image_url'] = mask_image_url
175
+
176
+ if base_image_url is not None and base_image_url:
177
+ is_upload, res_base_image_url = check_and_upload_local(
178
+ model, base_image_url, api_key)
179
+ if is_upload:
180
+ has_upload = True
181
+ input['base_image_url'] = res_base_image_url
182
+
144
183
  if extra_input is not None and extra_input:
145
184
  input = {**input, **extra_input}
146
185
 
@@ -149,11 +188,16 @@ class ImageSynthesis(BaseAsyncApi):
149
188
  headers['X-DashScope-OssResourceResolve'] = 'enable'
150
189
  kwargs['headers'] = headers
151
190
 
191
+ if task is None:
192
+ task = ImageSynthesis.task
193
+ if model is not None and model and 'imageedit' in model:
194
+ task = 'image2image'
195
+
152
196
  response = super().async_call(
153
197
  model=model,
154
198
  task_group=task_group,
155
- task=ImageSynthesis.task if task is None else task,
156
- function=function,
199
+ task=task,
200
+ function=f,
157
201
  api_key=api_key,
158
202
  input=input,
159
203
  workspace=workspace,
@@ -16,15 +16,25 @@ class VideoSynthesis(BaseAsyncApi):
16
16
  """API for video synthesis.
17
17
  """
18
18
  class Models:
19
+ """@deprecated, use wanx2.1-t2v-plus instead"""
19
20
  wanx_txt2video_pro = 'wanx-txt2video-pro'
21
+ """@deprecated, use wanx2.1-i2v-plus instead"""
20
22
  wanx_img2video_pro = 'wanx-img2video-pro'
23
+
21
24
  wanx_2_1_t2v_turbo = 'wanx2.1-t2v-turbo'
22
25
  wanx_2_1_t2v_plus = 'wanx2.1-t2v-plus'
23
26
 
27
+ wanx_2_1_i2v_plus = 'wanx2.1-i2v-plus'
28
+ wanx_2_1_i2v_turbo = 'wanx2.1-i2v-turbo'
29
+
30
+ wanx_2_1_kf2v_plus = 'wanx2.1-kf2v-plus'
31
+ wanx_kf2v = 'wanx-kf2v'
32
+
24
33
  @classmethod
25
34
  def call(cls,
26
35
  model: str,
27
- prompt: Any,
36
+ prompt: Any = None,
37
+ # """@deprecated, use prompt_extend in parameters """
28
38
  extend_prompt: bool = True,
29
39
  negative_prompt: str = None,
30
40
  template: str = None,
@@ -33,13 +43,17 @@ class VideoSynthesis(BaseAsyncApi):
33
43
  extra_input: Dict = None,
34
44
  workspace: str = None,
35
45
  task: str = None,
46
+ head_frame: str = None,
47
+ tail_frame: str = None,
48
+ first_frame_url: str = None,
49
+ last_frame_url: str = None,
36
50
  **kwargs) -> VideoSynthesisResponse:
37
51
  """Call video synthesis service and get result.
38
52
 
39
53
  Args:
40
54
  model (str): The model, reference ``Models``.
41
55
  prompt (Any): The prompt for video synthesis.
42
- extend_prompt (bool): The extend_prompt. Whether to enable write expansion. The default value is True.
56
+ extend_prompt (bool): @deprecated, use prompt_extend in parameters
43
57
  negative_prompt (str): The negative prompt is the opposite of the prompt meaning.
44
58
  template (str): LoRa input, such as gufeng, katong, etc.
45
59
  img_url (str): The input image url, Generate the URL of the image referenced by the video.
@@ -47,6 +61,8 @@ class VideoSynthesis(BaseAsyncApi):
47
61
  workspace (str): The dashscope workspace id.
48
62
  extra_input (Dict): The extra input parameters.
49
63
  task (str): The task of api, ref doc.
64
+ first_frame_url (str): The URL of the first frame image for generating the video.
65
+ last_frame_url (str): The URL of the last frame image for generating the video.
50
66
  **kwargs:
51
67
  size(str, `optional`): The output video size(width*height).
52
68
  duration(int, optional): The duration. Duration of video generation. The default value is 5, in seconds.
@@ -68,13 +84,18 @@ class VideoSynthesis(BaseAsyncApi):
68
84
  workspace=workspace,
69
85
  extra_input=extra_input,
70
86
  task=task,
87
+ head_frame=head_frame,
88
+ tail_frame=tail_frame,
89
+ first_frame_url=first_frame_url,
90
+ last_frame_url=last_frame_url,
71
91
  **kwargs)
72
92
 
73
93
  @classmethod
74
94
  def async_call(cls,
75
95
  model: str,
76
- prompt: Any,
96
+ prompt: Any = None,
77
97
  img_url: str = None,
98
+ # """@deprecated, use prompt_extend in parameters """
78
99
  extend_prompt: bool = True,
79
100
  negative_prompt: str = None,
80
101
  template: str = None,
@@ -82,13 +103,17 @@ class VideoSynthesis(BaseAsyncApi):
82
103
  extra_input: Dict = None,
83
104
  workspace: str = None,
84
105
  task: str = None,
106
+ head_frame: str = None,
107
+ tail_frame: str = None,
108
+ first_frame_url: str = None,
109
+ last_frame_url: str = None,
85
110
  **kwargs) -> VideoSynthesisResponse:
86
111
  """Create a video synthesis task, and return task information.
87
112
 
88
113
  Args:
89
114
  model (str): The model, reference ``Models``.
90
115
  prompt (Any): The prompt for video synthesis.
91
- extend_prompt (bool): The extend_prompt. Whether to enable write expansion. The default value is True.
116
+ extend_prompt (bool): @deprecated, use prompt_extend in parameters
92
117
  negative_prompt (str): The negative prompt is the opposite of the prompt meaning.
93
118
  template (str): LoRa input, such as gufeng, katong, etc.
94
119
  img_url (str): The input image url, Generate the URL of the image referenced by the video.
@@ -96,6 +121,8 @@ class VideoSynthesis(BaseAsyncApi):
96
121
  workspace (str): The dashscope workspace id.
97
122
  extra_input (Dict): The extra input parameters.
98
123
  task (str): The task of api, ref doc.
124
+ first_frame_url (str): The URL of the first frame image for generating the video.
125
+ last_frame_url (str): The URL of the last frame image for generating the video.
99
126
  **kwargs:
100
127
  size(str, `optional`): The output video size(width*height).
101
128
  duration(int, optional): The duration. Duration of video generation. The default value is 5, in seconds.
@@ -108,27 +135,63 @@ class VideoSynthesis(BaseAsyncApi):
108
135
  DashScopeAPIResponse: The video synthesis
109
136
  task id in the response.
110
137
  """
111
- if prompt is None or not prompt:
112
- raise InputRequired('prompt is required!')
113
138
  task_group, function = _get_task_group_and_task(__name__)
114
139
  inputs = {PROMPT: prompt, 'extend_prompt': extend_prompt}
115
140
  if negative_prompt:
116
141
  inputs['negative_prompt'] = negative_prompt
117
142
  if template:
118
143
  inputs['template'] = template
144
+ if function:
145
+ inputs['function'] = function
146
+
119
147
  has_upload = False
148
+
120
149
  if img_url is not None and img_url:
121
150
  is_upload, res_img_url = check_and_upload_local(
122
151
  model, img_url, api_key)
123
152
  if is_upload:
124
153
  has_upload = True
125
154
  inputs['img_url'] = res_img_url
155
+
156
+ if head_frame is not None and head_frame:
157
+ is_upload, res_head_frame = check_and_upload_local(
158
+ model, head_frame, api_key)
159
+ if is_upload:
160
+ has_upload = True
161
+ inputs['head_frame'] = res_head_frame
162
+
163
+ if tail_frame is not None and tail_frame:
164
+ is_upload, res_tail_frame = check_and_upload_local(
165
+ model, tail_frame, api_key)
166
+ if is_upload:
167
+ has_upload = True
168
+ inputs['tail_frame'] = res_tail_frame
169
+
170
+ if first_frame_url is not None and first_frame_url:
171
+ is_upload, res_first_frame_url = check_and_upload_local(
172
+ model, first_frame_url, api_key)
173
+ if is_upload:
174
+ has_upload = True
175
+ inputs['first_frame_url'] = res_first_frame_url
176
+
177
+ if last_frame_url is not None and last_frame_url:
178
+ is_upload, res_last_frame_url = check_and_upload_local(
179
+ model, last_frame_url, api_key)
180
+ if is_upload:
181
+ has_upload = True
182
+ inputs['last_frame_url'] = res_last_frame_url
183
+
126
184
  if extra_input is not None and extra_input:
127
185
  inputs = {**inputs, **extra_input}
128
186
  if has_upload:
129
187
  headers = kwargs.pop('headers', {})
130
188
  headers['X-DashScope-OssResourceResolve'] = 'enable'
131
189
  kwargs['headers'] = headers
190
+
191
+ if task is None:
192
+ task = VideoSynthesis.task
193
+ if model is not None and model and 'kf2v' in model:
194
+ task = 'image2video'
132
195
  response = super().async_call(
133
196
  model=model,
134
197
  task_group=task_group,
dashscope/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  # Copyright (c) Alibaba, Inc. and its affiliates.
2
2
 
3
- __version__ = '1.23.2'
3
+ __version__ = '1.23.3'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dashscope
3
- Version: 1.23.2
3
+ Version: 1.23.3
4
4
  Summary: dashscope client sdk library
5
5
  Home-page: https://dashscope.aliyun.com/
6
6
  Author: Alibaba Cloud
@@ -3,15 +3,15 @@ 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=YDam49_qwmBkRWD73B92gu3W0y8bXTa_nlWVVLFu0-Y,74
6
+ dashscope/version.py,sha256=KoL2HDS3KUg-imtukZreW80cuyVG_B6Uy4FbPH7nZe4,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
10
10
  dashscope/aigc/conversation.py,sha256=95xEEY4ThZJysj5zy3aMw7ql9KLJVfD_1iHv9QZ17Ew,14282
11
11
  dashscope/aigc/generation.py,sha256=xMcMu16rICTdjZiD_sPqYV_Ltdp4ewGzzfC7JD9VApY,17948
12
- dashscope/aigc/image_synthesis.py,sha256=v4SzJdKjPhVgRk_pZY9mRz3LHjIzY22larIpXomRMuA,11103
12
+ dashscope/aigc/image_synthesis.py,sha256=RGyjhSl1-5YzaYBtAMaoemh6Ij_Xw0l_z9IGKD5qgWI,13359
13
13
  dashscope/aigc/multimodal_conversation.py,sha256=1rZZRk_1lCdbVs7Rx1kJ5LvwWE1put5p_dQKdCX0ysY,5574
14
- dashscope/aigc/video_synthesis.py,sha256=QO9JXrriT0ZN-GF3AFznNx9G_NEYQr_Wmo4qpXjzVN0,10451
14
+ dashscope/aigc/video_synthesis.py,sha256=XQ3-NKYFmj5cIbUbLTbI0-FyC_fQp8eds6QmD1ZHj_0,13015
15
15
  dashscope/api_entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  dashscope/api_entities/aiohttp_request.py,sha256=1L7XdIJ9L65cQmX8x9JCR4t5hNIMDrbiWADfKKp9yfo,10280
17
17
  dashscope/api_entities/api_request_data.py,sha256=04rpYPNK1HkT3iTPJmZpquH621xcBbe8R8EGrDJSLt0,5514
@@ -87,9 +87,9 @@ dashscope/tokenizers/tokenizer.py,sha256=3FQVDvMNkCW9ccYeJdjrd_PIMMD3Xv7aNZkaYOE
87
87
  dashscope/tokenizers/tokenizer_base.py,sha256=5EJIFuizMWESEmLmbd38yJnfeHmPnzZPwsO4aOGjpl4,707
88
88
  dashscope/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
89
89
  dashscope/utils/oss_utils.py,sha256=L5LN3lN8etVxSL_jkZydstvEKpnTG9CY0zcvPGQ5LBo,7383
90
- dashscope-1.23.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
91
- dashscope-1.23.2.dist-info/METADATA,sha256=m__F7jlB_AiVIUOhHBvweN5P-jIpl170DhyvA5QEleE,6798
92
- dashscope-1.23.2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
93
- dashscope-1.23.2.dist-info/entry_points.txt,sha256=raEp5dOuj8whJ7yqZlDM8WQ5p2RfnGrGNo0QLQEnatY,50
94
- dashscope-1.23.2.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
95
- dashscope-1.23.2.dist-info/RECORD,,
90
+ dashscope-1.23.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
91
+ dashscope-1.23.3.dist-info/METADATA,sha256=lqzVJ_GvC8JbdUYLTDjC2OL0bdp1Vzk5RaMD9aFIkYE,6798
92
+ dashscope-1.23.3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
93
+ dashscope-1.23.3.dist-info/entry_points.txt,sha256=raEp5dOuj8whJ7yqZlDM8WQ5p2RfnGrGNo0QLQEnatY,50
94
+ dashscope-1.23.3.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
95
+ dashscope-1.23.3.dist-info/RECORD,,