dashscope 1.8.0__py3-none-any.whl → 1.25.6__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.
- dashscope/__init__.py +61 -14
- dashscope/aigc/__init__.py +10 -3
- dashscope/aigc/chat_completion.py +282 -0
- dashscope/aigc/code_generation.py +145 -0
- dashscope/aigc/conversation.py +71 -12
- dashscope/aigc/generation.py +288 -16
- dashscope/aigc/image_synthesis.py +473 -31
- dashscope/aigc/multimodal_conversation.py +299 -14
- dashscope/aigc/video_synthesis.py +610 -0
- dashscope/api_entities/aiohttp_request.py +8 -5
- dashscope/api_entities/api_request_data.py +4 -2
- dashscope/api_entities/api_request_factory.py +68 -20
- dashscope/api_entities/base_request.py +20 -3
- dashscope/api_entities/chat_completion_types.py +344 -0
- dashscope/api_entities/dashscope_response.py +243 -15
- dashscope/api_entities/encryption.py +179 -0
- dashscope/api_entities/http_request.py +216 -62
- dashscope/api_entities/websocket_request.py +43 -34
- dashscope/app/__init__.py +5 -0
- dashscope/app/application.py +203 -0
- dashscope/app/application_response.py +246 -0
- dashscope/assistants/__init__.py +16 -0
- dashscope/assistants/assistant_types.py +175 -0
- dashscope/assistants/assistants.py +311 -0
- dashscope/assistants/files.py +197 -0
- dashscope/audio/__init__.py +4 -2
- dashscope/audio/asr/__init__.py +17 -1
- dashscope/audio/asr/asr_phrase_manager.py +203 -0
- dashscope/audio/asr/recognition.py +167 -27
- dashscope/audio/asr/transcription.py +107 -14
- dashscope/audio/asr/translation_recognizer.py +1006 -0
- dashscope/audio/asr/vocabulary.py +177 -0
- dashscope/audio/qwen_asr/__init__.py +7 -0
- dashscope/audio/qwen_asr/qwen_transcription.py +189 -0
- dashscope/audio/qwen_omni/__init__.py +11 -0
- dashscope/audio/qwen_omni/omni_realtime.py +524 -0
- dashscope/audio/qwen_tts/__init__.py +5 -0
- dashscope/audio/qwen_tts/speech_synthesizer.py +77 -0
- dashscope/audio/qwen_tts_realtime/__init__.py +10 -0
- dashscope/audio/qwen_tts_realtime/qwen_tts_realtime.py +355 -0
- dashscope/audio/tts/__init__.py +2 -0
- dashscope/audio/tts/speech_synthesizer.py +5 -0
- dashscope/audio/tts_v2/__init__.py +12 -0
- dashscope/audio/tts_v2/enrollment.py +179 -0
- dashscope/audio/tts_v2/speech_synthesizer.py +886 -0
- dashscope/cli.py +157 -37
- dashscope/client/base_api.py +652 -87
- dashscope/common/api_key.py +2 -0
- dashscope/common/base_type.py +135 -0
- dashscope/common/constants.py +13 -16
- dashscope/common/env.py +2 -0
- dashscope/common/error.py +58 -22
- dashscope/common/logging.py +2 -0
- dashscope/common/message_manager.py +2 -0
- dashscope/common/utils.py +276 -46
- dashscope/customize/__init__.py +0 -0
- dashscope/customize/customize_types.py +192 -0
- dashscope/customize/deployments.py +146 -0
- dashscope/customize/finetunes.py +234 -0
- dashscope/embeddings/__init__.py +5 -1
- dashscope/embeddings/batch_text_embedding.py +208 -0
- dashscope/embeddings/batch_text_embedding_response.py +65 -0
- dashscope/embeddings/multimodal_embedding.py +118 -10
- dashscope/embeddings/text_embedding.py +13 -1
- dashscope/{file.py → files.py} +19 -4
- dashscope/io/input_output.py +2 -0
- dashscope/model.py +11 -2
- dashscope/models.py +43 -0
- dashscope/multimodal/__init__.py +20 -0
- dashscope/multimodal/dialog_state.py +56 -0
- dashscope/multimodal/multimodal_constants.py +28 -0
- dashscope/multimodal/multimodal_dialog.py +648 -0
- dashscope/multimodal/multimodal_request_params.py +313 -0
- dashscope/multimodal/tingwu/__init__.py +10 -0
- dashscope/multimodal/tingwu/tingwu.py +80 -0
- dashscope/multimodal/tingwu/tingwu_realtime.py +579 -0
- dashscope/nlp/__init__.py +0 -0
- dashscope/nlp/understanding.py +64 -0
- dashscope/protocol/websocket.py +3 -0
- dashscope/rerank/__init__.py +0 -0
- dashscope/rerank/text_rerank.py +69 -0
- dashscope/resources/qwen.tiktoken +151643 -0
- dashscope/threads/__init__.py +26 -0
- dashscope/threads/messages/__init__.py +0 -0
- dashscope/threads/messages/files.py +113 -0
- dashscope/threads/messages/messages.py +220 -0
- dashscope/threads/runs/__init__.py +0 -0
- dashscope/threads/runs/runs.py +501 -0
- dashscope/threads/runs/steps.py +112 -0
- dashscope/threads/thread_types.py +665 -0
- dashscope/threads/threads.py +212 -0
- dashscope/tokenizers/__init__.py +7 -0
- dashscope/tokenizers/qwen_tokenizer.py +111 -0
- dashscope/tokenizers/tokenization.py +125 -0
- dashscope/tokenizers/tokenizer.py +45 -0
- dashscope/tokenizers/tokenizer_base.py +32 -0
- dashscope/utils/__init__.py +0 -0
- dashscope/utils/message_utils.py +838 -0
- dashscope/utils/oss_utils.py +243 -0
- dashscope/utils/param_utils.py +29 -0
- dashscope/version.py +3 -1
- {dashscope-1.8.0.dist-info → dashscope-1.25.6.dist-info}/METADATA +53 -50
- dashscope-1.25.6.dist-info/RECORD +112 -0
- {dashscope-1.8.0.dist-info → dashscope-1.25.6.dist-info}/WHEEL +1 -1
- {dashscope-1.8.0.dist-info → dashscope-1.25.6.dist-info}/entry_points.txt +0 -1
- {dashscope-1.8.0.dist-info → dashscope-1.25.6.dist-info/licenses}/LICENSE +2 -4
- dashscope/deployment.py +0 -129
- dashscope/finetune.py +0 -149
- dashscope-1.8.0.dist-info/RECORD +0 -49
- {dashscope-1.8.0.dist-info → dashscope-1.25.6.dist-info}/top_level.txt +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Copyright (c) Alibaba, Inc. and its affiliates.
|
|
2
|
+
|
|
1
3
|
import asyncio
|
|
2
4
|
import time
|
|
3
5
|
from typing import List, Union
|
|
@@ -24,23 +26,54 @@ class Transcription(BaseAsyncApi):
|
|
|
24
26
|
paraformer_mtl_v1 = 'paraformer-mtl-v1'
|
|
25
27
|
|
|
26
28
|
@classmethod
|
|
27
|
-
def call(cls,
|
|
29
|
+
def call(cls,
|
|
30
|
+
model: str,
|
|
31
|
+
file_urls: List[str],
|
|
32
|
+
phrase_id: str = None,
|
|
33
|
+
api_key: str = None,
|
|
34
|
+
workspace: str = None,
|
|
28
35
|
**kwargs) -> TranscriptionResponse:
|
|
29
36
|
"""Transcribe the given files synchronously.
|
|
30
37
|
|
|
31
38
|
Args:
|
|
32
39
|
model (str): The requested model_id.
|
|
33
40
|
file_urls (List[str]): List of stored URLs.
|
|
34
|
-
|
|
41
|
+
phrase_id (str, `optional`): The ID of phrase.
|
|
42
|
+
workspace (str): The dashscope workspace id.
|
|
43
|
+
|
|
44
|
+
**kwargs:
|
|
45
|
+
channel_id (List[int], optional):
|
|
46
|
+
The selected channel_id of audio file.
|
|
47
|
+
disfluency_removal_enabled(bool, `optional`):
|
|
48
|
+
Filter mood words, turned off by default.
|
|
49
|
+
diarization_enabled (bool, `optional`):
|
|
50
|
+
Speech auto diarization, turned off by default.
|
|
51
|
+
speaker_count (int, `optional`): The number of speakers.
|
|
52
|
+
timestamp_alignment_enabled (bool, `optional`):
|
|
53
|
+
Timestamp-alignment calibration, turned off by default.
|
|
54
|
+
special_word_filter(str, `optional`): Sensitive word filter.
|
|
55
|
+
audio_event_detection_enabled(bool, `optional`):
|
|
56
|
+
Audio event detection, turned off by default.
|
|
35
57
|
|
|
36
58
|
Returns:
|
|
37
59
|
TranscriptionResponse: The result of batch transcription.
|
|
38
60
|
"""
|
|
39
|
-
|
|
61
|
+
kwargs.update(cls._fill_resource_id(phrase_id, **kwargs))
|
|
62
|
+
kwargs = cls._tidy_kwargs(**kwargs)
|
|
63
|
+
response = super().call(model,
|
|
64
|
+
file_urls,
|
|
65
|
+
api_key=api_key,
|
|
66
|
+
workspace=workspace,
|
|
67
|
+
**kwargs)
|
|
40
68
|
return TranscriptionResponse.from_api_response(response)
|
|
41
69
|
|
|
42
70
|
@classmethod
|
|
43
|
-
def async_call(cls,
|
|
71
|
+
def async_call(cls,
|
|
72
|
+
model: str,
|
|
73
|
+
file_urls: List[str],
|
|
74
|
+
phrase_id: str = None,
|
|
75
|
+
api_key: str = None,
|
|
76
|
+
workspace: str = None,
|
|
44
77
|
**kwargs) -> TranscriptionResponse:
|
|
45
78
|
"""Transcribe the given files asynchronously,
|
|
46
79
|
return the status of task submission for querying results subsequently.
|
|
@@ -48,23 +81,47 @@ class Transcription(BaseAsyncApi):
|
|
|
48
81
|
Args:
|
|
49
82
|
model (str): The requested model, such as paraformer-16k-1
|
|
50
83
|
file_urls (List[str]): List of stored URLs.
|
|
51
|
-
|
|
84
|
+
phrase_id (str, `optional`): The ID of phrase.
|
|
85
|
+
workspace (str): The dashscope workspace id.
|
|
86
|
+
|
|
87
|
+
**kwargs:
|
|
88
|
+
channel_id (List[int], optional):
|
|
89
|
+
The selected channel_id of audio file.
|
|
90
|
+
disfluency_removal_enabled(bool, `optional`):
|
|
91
|
+
Filter mood words, turned off by default.
|
|
92
|
+
diarization_enabled (bool, `optional`):
|
|
93
|
+
Speech auto diarization, turned off by default.
|
|
94
|
+
speaker_count (int, `optional`): The number of speakers.
|
|
95
|
+
timestamp_alignment_enabled (bool, `optional`):
|
|
96
|
+
Timestamp-alignment calibration, turned off by default.
|
|
97
|
+
special_word_filter(str, `optional`): Sensitive word filter.
|
|
98
|
+
audio_event_detection_enabled(bool, `optional`):
|
|
99
|
+
Audio event detection, turned off by default.
|
|
52
100
|
|
|
53
101
|
Returns:
|
|
54
102
|
TranscriptionResponse: The response including task_id.
|
|
55
103
|
"""
|
|
56
|
-
|
|
104
|
+
kwargs.update(cls._fill_resource_id(phrase_id, **kwargs))
|
|
105
|
+
kwargs = cls._tidy_kwargs(**kwargs)
|
|
106
|
+
response = cls._launch_request(model,
|
|
107
|
+
file_urls,
|
|
108
|
+
api_key=api_key,
|
|
109
|
+
workspace=workspace,
|
|
110
|
+
**kwargs)
|
|
57
111
|
return TranscriptionResponse.from_api_response(response)
|
|
58
112
|
|
|
59
113
|
@classmethod
|
|
60
|
-
def fetch(
|
|
61
|
-
|
|
62
|
-
|
|
114
|
+
def fetch(cls,
|
|
115
|
+
task: Union[str, TranscriptionResponse],
|
|
116
|
+
api_key: str = None,
|
|
117
|
+
workspace: str = None,
|
|
118
|
+
**kwargs) -> TranscriptionResponse:
|
|
63
119
|
"""Fetch the status of task, including results of batch transcription when task_status is SUCCEEDED. # noqa: E501
|
|
64
120
|
|
|
65
121
|
Args:
|
|
66
122
|
task (Union[str, TranscriptionResponse]): The task_id or
|
|
67
123
|
response including task_id returned from async_call().
|
|
124
|
+
workspace (str): The dashscope workspace id.
|
|
68
125
|
|
|
69
126
|
Returns:
|
|
70
127
|
TranscriptionResponse: The status of task_id,
|
|
@@ -73,7 +130,10 @@ class Transcription(BaseAsyncApi):
|
|
|
73
130
|
try_count: int = 0
|
|
74
131
|
while True:
|
|
75
132
|
try:
|
|
76
|
-
response = super().fetch(task
|
|
133
|
+
response = super().fetch(task,
|
|
134
|
+
api_key=api_key,
|
|
135
|
+
workspace=workspace,
|
|
136
|
+
**kwargs)
|
|
77
137
|
except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e:
|
|
78
138
|
logger.error(e)
|
|
79
139
|
try_count += 1
|
|
@@ -87,28 +147,40 @@ class Transcription(BaseAsyncApi):
|
|
|
87
147
|
return TranscriptionResponse.from_api_response(response)
|
|
88
148
|
|
|
89
149
|
@classmethod
|
|
90
|
-
def wait(cls,
|
|
91
|
-
|
|
150
|
+
def wait(cls,
|
|
151
|
+
task: Union[str, TranscriptionResponse],
|
|
152
|
+
api_key: str = None,
|
|
153
|
+
workspace: str = None,
|
|
154
|
+
**kwargs) -> TranscriptionResponse:
|
|
92
155
|
"""Poll task until the final results of transcription is obtained.
|
|
93
156
|
|
|
94
157
|
Args:
|
|
95
158
|
task (Union[str, TranscriptionResponse]): The task_id or
|
|
96
159
|
response including task_id returned from async_call().
|
|
160
|
+
workspace (str): The dashscope workspace id.
|
|
97
161
|
|
|
98
162
|
Returns:
|
|
99
163
|
TranscriptionResponse: The result of batch transcription.
|
|
100
164
|
"""
|
|
101
|
-
response = super().wait(task
|
|
165
|
+
response = super().wait(task,
|
|
166
|
+
api_key=api_key,
|
|
167
|
+
workspace=workspace,
|
|
168
|
+
**kwargs)
|
|
102
169
|
return TranscriptionResponse.from_api_response(response)
|
|
103
170
|
|
|
104
171
|
@classmethod
|
|
105
|
-
def _launch_request(cls,
|
|
172
|
+
def _launch_request(cls,
|
|
173
|
+
model: str,
|
|
174
|
+
files: List[str],
|
|
175
|
+
api_key: str = None,
|
|
176
|
+
workspace: str = None,
|
|
106
177
|
**kwargs) -> DashScopeAPIResponse:
|
|
107
178
|
"""Submit transcribe request.
|
|
108
179
|
|
|
109
180
|
Args:
|
|
110
181
|
model (str): The requested model, such as paraformer-16k-1
|
|
111
182
|
files (List[str]): List of stored URLs.
|
|
183
|
+
workspace (str): The dashscope workspace id.
|
|
112
184
|
|
|
113
185
|
Returns:
|
|
114
186
|
DashScopeAPIResponse: The result of task submission.
|
|
@@ -125,6 +197,8 @@ class Transcription(BaseAsyncApi):
|
|
|
125
197
|
input={'file_urls': files},
|
|
126
198
|
api_protocol=ApiProtocol.HTTP,
|
|
127
199
|
http_method=HTTPMethod.POST,
|
|
200
|
+
api_key=api_key,
|
|
201
|
+
workspace=workspace,
|
|
128
202
|
**kwargs)
|
|
129
203
|
except (asyncio.TimeoutError, aiohttp.ClientConnectorError) as e:
|
|
130
204
|
logger.error(e)
|
|
@@ -136,3 +210,22 @@ class Transcription(BaseAsyncApi):
|
|
|
136
210
|
break
|
|
137
211
|
|
|
138
212
|
return response
|
|
213
|
+
|
|
214
|
+
@classmethod
|
|
215
|
+
def _fill_resource_id(cls, phrase_id: str, **kwargs):
|
|
216
|
+
resources_list: list = []
|
|
217
|
+
if phrase_id is not None and len(phrase_id) > 0:
|
|
218
|
+
item = {'resource_id': phrase_id, 'resource_type': 'asr_phrase'}
|
|
219
|
+
resources_list.append(item)
|
|
220
|
+
|
|
221
|
+
if len(resources_list) > 0:
|
|
222
|
+
kwargs['resources'] = resources_list
|
|
223
|
+
|
|
224
|
+
return kwargs
|
|
225
|
+
|
|
226
|
+
@classmethod
|
|
227
|
+
def _tidy_kwargs(cls, **kwargs):
|
|
228
|
+
for k in kwargs.copy():
|
|
229
|
+
if kwargs[k] is None:
|
|
230
|
+
kwargs.pop(k, None)
|
|
231
|
+
return kwargs
|