dashscope 1.0.3__tar.gz → 1.26.2__tar.gz
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-1.0.3 → dashscope-1.26.2}/LICENSE +2 -4
- dashscope-1.26.2/MANIFEST.in +1 -0
- dashscope-1.26.2/PKG-INFO +545 -0
- dashscope-1.26.2/README.md +520 -0
- dashscope-1.26.2/dashscope/__init__.py +142 -0
- dashscope-1.26.2/dashscope/agentstudio/__init__.py +118 -0
- dashscope-1.26.2/dashscope/agentstudio/client.py +208 -0
- dashscope-1.26.2/dashscope/agentstudio/constants.py +95 -0
- dashscope-1.26.2/dashscope/agentstudio/exceptions.py +244 -0
- dashscope-1.26.2/dashscope/agentstudio/pagination.py +139 -0
- dashscope-1.26.2/dashscope/agentstudio/resources/__init__.py +65 -0
- dashscope-1.26.2/dashscope/agentstudio/resources/_helpers.py +79 -0
- dashscope-1.26.2/dashscope/agentstudio/resources/agents.py +338 -0
- dashscope-1.26.2/dashscope/agentstudio/resources/environments.py +242 -0
- dashscope-1.26.2/dashscope/agentstudio/resources/files.py +303 -0
- dashscope-1.26.2/dashscope/agentstudio/resources/session_events.py +332 -0
- dashscope-1.26.2/dashscope/agentstudio/resources/sessions.py +276 -0
- dashscope-1.26.2/dashscope/agentstudio/resources/skills.py +376 -0
- dashscope-1.26.2/dashscope/agentstudio/resources/vaults.py +476 -0
- dashscope-1.26.2/dashscope/agentstudio/streaming.py +226 -0
- dashscope-1.26.2/dashscope/agentstudio/transport.py +696 -0
- dashscope-1.26.2/dashscope/agentstudio/types/__init__.py +97 -0
- dashscope-1.26.2/dashscope/agentstudio/types/models.py +870 -0
- dashscope-1.26.2/dashscope/agentstudio/types/params.py +551 -0
- dashscope-1.26.2/dashscope/aigc/__init__.py +24 -0
- dashscope-1.26.2/dashscope/aigc/chat_completion.py +301 -0
- dashscope-1.26.2/dashscope/aigc/code_generation.py +178 -0
- dashscope-1.26.2/dashscope/aigc/conversation.py +410 -0
- dashscope-1.26.2/dashscope/aigc/generation.py +568 -0
- dashscope-1.26.2/dashscope/aigc/image_generation.py +669 -0
- dashscope-1.26.2/dashscope/aigc/image_synthesis.py +1093 -0
- dashscope-1.26.2/dashscope/aigc/multimodal_conversation.py +554 -0
- dashscope-1.26.2/dashscope/aigc/video_synthesis.py +1022 -0
- dashscope-1.26.2/dashscope/api_entities/aio_session.py +95 -0
- dashscope-1.26.2/dashscope/api_entities/aiohttp_request.py +322 -0
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope/api_entities/api_request_data.py +54 -30
- dashscope-1.26.2/dashscope/api_entities/api_request_factory.py +189 -0
- dashscope-1.26.2/dashscope/api_entities/base_request.py +36 -0
- dashscope-1.26.2/dashscope/api_entities/chat_completion_types.py +395 -0
- dashscope-1.26.2/dashscope/api_entities/dashscope_response.py +943 -0
- dashscope-1.26.2/dashscope/api_entities/encryption.py +194 -0
- dashscope-1.26.2/dashscope/api_entities/http_request.py +521 -0
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope/api_entities/websocket_request.py +205 -129
- dashscope-1.26.2/dashscope/app/__init__.py +6 -0
- dashscope-1.26.2/dashscope/app/application.py +293 -0
- dashscope-1.26.2/dashscope/app/application_response.py +272 -0
- dashscope-1.26.2/dashscope/assistants/__init__.py +19 -0
- dashscope-1.26.2/dashscope/assistants/assistant_types.py +193 -0
- dashscope-1.26.2/dashscope/assistants/assistants.py +404 -0
- dashscope-1.26.2/dashscope/assistants/files.py +236 -0
- dashscope-1.26.2/dashscope/audio/__init__.py +13 -0
- dashscope-1.26.2/dashscope/audio/asr/__init__.py +33 -0
- dashscope-1.26.2/dashscope/audio/asr/asr_phrase_manager.py +224 -0
- dashscope-1.26.2/dashscope/audio/asr/recognition.py +605 -0
- dashscope-1.26.2/dashscope/audio/asr/transcription.py +261 -0
- dashscope-1.26.2/dashscope/audio/asr/translation_recognizer.py +1092 -0
- dashscope-1.26.2/dashscope/audio/asr/vocabulary.py +236 -0
- dashscope-1.26.2/dashscope/audio/http_tts/__init__.py +12 -0
- dashscope-1.26.2/dashscope/audio/http_tts/http_speech_synthesizer.py +293 -0
- dashscope-1.26.2/dashscope/audio/qwen_asr/__init__.py +8 -0
- dashscope-1.26.2/dashscope/audio/qwen_asr/qwen_transcription.py +216 -0
- dashscope-1.26.2/dashscope/audio/qwen_omni/__init__.py +16 -0
- dashscope-1.26.2/dashscope/audio/qwen_omni/omni_realtime.py +635 -0
- dashscope-1.26.2/dashscope/audio/qwen_tts/__init__.py +6 -0
- dashscope-1.26.2/dashscope/audio/qwen_tts/speech_synthesizer.py +85 -0
- dashscope-1.26.2/dashscope/audio/qwen_tts_realtime/__init__.py +14 -0
- dashscope-1.26.2/dashscope/audio/qwen_tts_realtime/qwen_tts_realtime.py +432 -0
- dashscope-1.26.2/dashscope/audio/tts/__init__.py +10 -0
- dashscope-1.26.2/dashscope/audio/tts/speech_synthesizer.py +229 -0
- dashscope-1.26.2/dashscope/audio/tts_v2/__init__.py +19 -0
- dashscope-1.26.2/dashscope/audio/tts_v2/enrollment.py +246 -0
- dashscope-1.26.2/dashscope/audio/tts_v2/speech_synthesizer.py +1074 -0
- dashscope-1.26.2/dashscope/cli/__init__.py +342 -0
- dashscope-1.26.2/dashscope/cli/__main__.py +17 -0
- dashscope-1.26.2/dashscope/cli/agentic_rl.py +720 -0
- dashscope-1.26.2/dashscope/cli/application.py +87 -0
- dashscope-1.26.2/dashscope/cli/code_generation.py +81 -0
- dashscope-1.26.2/dashscope/cli/common.py +100 -0
- dashscope-1.26.2/dashscope/cli/deployments.py +205 -0
- dashscope-1.26.2/dashscope/cli/embeddings.py +79 -0
- dashscope-1.26.2/dashscope/cli/files.py +136 -0
- dashscope-1.26.2/dashscope/cli/fine_tunes.py +345 -0
- dashscope-1.26.2/dashscope/cli/generation.py +215 -0
- dashscope-1.26.2/dashscope/cli/image_generation.py +88 -0
- dashscope-1.26.2/dashscope/cli/image_synthesis.py +67 -0
- dashscope-1.26.2/dashscope/cli/models.py +54 -0
- dashscope-1.26.2/dashscope/cli/multimodal_conversation.py +98 -0
- dashscope-1.26.2/dashscope/cli/multimodal_embedding.py +126 -0
- dashscope-1.26.2/dashscope/cli/oss.py +83 -0
- dashscope-1.26.2/dashscope/cli/rerank.py +71 -0
- dashscope-1.26.2/dashscope/cli/speech_synthesis.py +84 -0
- dashscope-1.26.2/dashscope/cli/tokenization.py +54 -0
- dashscope-1.26.2/dashscope/cli/transcription.py +100 -0
- dashscope-1.26.2/dashscope/cli/understanding.py +60 -0
- dashscope-1.26.2/dashscope/cli/video_synthesis.py +215 -0
- dashscope-1.26.2/dashscope/client/base_api.py +1629 -0
- dashscope-1.26.2/dashscope/common/api_key.py +55 -0
- dashscope-1.26.2/dashscope/common/base_type.py +139 -0
- dashscope-1.26.2/dashscope/common/constants.py +98 -0
- dashscope-1.26.2/dashscope/common/env.py +31 -0
- dashscope-1.26.2/dashscope/common/error.py +146 -0
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope/common/logging.py +8 -5
- dashscope-1.26.2/dashscope/common/message_manager.py +38 -0
- dashscope-1.26.2/dashscope/common/utils.py +535 -0
- dashscope-1.26.2/dashscope/embeddings/__init__.py +12 -0
- dashscope-1.26.2/dashscope/embeddings/batch_text_embedding.py +235 -0
- dashscope-1.26.2/dashscope/embeddings/batch_text_embedding_response.py +74 -0
- dashscope-1.26.2/dashscope/embeddings/multimodal_embedding.py +302 -0
- dashscope-1.26.2/dashscope/embeddings/text_embedding.py +82 -0
- dashscope-1.26.2/dashscope/files.py +136 -0
- dashscope-1.26.2/dashscope/finetune/agentic_rl.py +462 -0
- dashscope-1.26.2/dashscope/finetune/customize_types.py +193 -0
- dashscope-1.26.2/dashscope/finetune/deployments.py +185 -0
- dashscope-1.26.2/dashscope/finetune/finetunes.py +291 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/__init__.py +253 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/common/constants.py +136 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/common/errors.py +313 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/common/log.py +34 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/common/model.py +1602 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/common/model_types.py +111 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/common/utils.py +1049 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/__init__.py +116 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/data/__init__.py +64 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/data/base_data_model.py +221 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/data/group_reward_input.py +53 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/data/group_reward_output.py +57 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/data/reward_input.py +53 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/data/reward_output.py +60 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/data/rollout_input.py +78 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/data/rollout_output.py +45 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/demo/__init__.py +19 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/demo/group_reward_processor_demo.py +113 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/demo/reward_processor_demo.py +97 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/demo/rollout_processor_demo.py +96 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/func_decorator.py +226 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/func_manager.py +338 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/__init__.py +122 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/genai/__init__.py +146 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/genai/_core.py +498 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/genai/llm_dashscope.py +190 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/genai/llm_openai.py +620 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/genai/llm_span.py +237 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/genai/messages.py +587 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/genai/tools.py +1026 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/processor_span.py +326 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/observability/tracing.py +823 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/parser/__init__.py +20 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/parser/base_parser.py +35 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/parser/group_reward_parser.py +41 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/parser/reward_parser.py +41 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/parser/rollout_parser.py +41 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/processor/__init__.py +20 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/processor/abstract_group_reward_processor.py +83 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/processor/abstract_processor.py +54 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/processor/abstract_reward_processor.py +201 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/processor/abstract_rollout_processor.py +78 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/server/__init__.py +0 -0
- dashscope-1.26.2/dashscope/finetune/reinforcement/component/server/server.py +631 -0
- dashscope-1.26.2/dashscope/io/__init__.py +0 -0
- dashscope-1.26.2/dashscope/io/input_output.py +132 -0
- dashscope-1.26.2/dashscope/model.py +62 -0
- dashscope-1.26.2/dashscope/models.py +77 -0
- dashscope-1.26.2/dashscope/multimodal/__init__.py +95 -0
- dashscope-1.26.2/dashscope/multimodal/dialog_state.py +59 -0
- dashscope-1.26.2/dashscope/multimodal/multimodal_constants.py +36 -0
- dashscope-1.26.2/dashscope/multimodal/multimodal_dialog.py +798 -0
- dashscope-1.26.2/dashscope/multimodal/multimodal_request_params.py +336 -0
- dashscope-1.26.2/dashscope/multimodal/tingwu/__init__.py +11 -0
- dashscope-1.26.2/dashscope/multimodal/tingwu/tingwu.py +84 -0
- dashscope-1.26.2/dashscope/multimodal/tingwu/tingwu_realtime.py +637 -0
- dashscope-1.26.2/dashscope/nlp/__init__.py +0 -0
- dashscope-1.26.2/dashscope/nlp/understanding.py +90 -0
- dashscope-1.26.2/dashscope/protocol/__init__.py +0 -0
- dashscope-1.26.2/dashscope/protocol/websocket.py +31 -0
- dashscope-1.26.2/dashscope/rerank/__init__.py +6 -0
- dashscope-1.26.2/dashscope/rerank/text_rerank.py +177 -0
- dashscope-1.26.2/dashscope/resources/qwen.tiktoken +151643 -0
- dashscope-1.26.2/dashscope/threads/__init__.py +29 -0
- dashscope-1.26.2/dashscope/threads/messages/__init__.py +0 -0
- dashscope-1.26.2/dashscope/threads/messages/files.py +127 -0
- dashscope-1.26.2/dashscope/threads/messages/messages.py +260 -0
- dashscope-1.26.2/dashscope/threads/runs/__init__.py +0 -0
- dashscope-1.26.2/dashscope/threads/runs/runs.py +582 -0
- dashscope-1.26.2/dashscope/threads/runs/steps.py +126 -0
- dashscope-1.26.2/dashscope/threads/thread_types.py +708 -0
- dashscope-1.26.2/dashscope/threads/threads.py +258 -0
- dashscope-1.26.2/dashscope/tokenizers/__init__.py +13 -0
- dashscope-1.26.2/dashscope/tokenizers/qwen_tokenizer.py +167 -0
- dashscope-1.26.2/dashscope/tokenizers/tokenization.py +147 -0
- dashscope-1.26.2/dashscope/tokenizers/tokenizer.py +49 -0
- dashscope-1.26.2/dashscope/tokenizers/tokenizer_base.py +31 -0
- dashscope-1.26.2/dashscope/utils/__init__.py +0 -0
- dashscope-1.26.2/dashscope/utils/message_utils.py +1235 -0
- dashscope-1.26.2/dashscope/utils/oss_utils.py +305 -0
- dashscope-1.26.2/dashscope/utils/param_utils.py +31 -0
- dashscope-1.26.2/dashscope/version.py +4 -0
- dashscope-1.26.2/dashscope.egg-info/PKG-INFO +545 -0
- dashscope-1.26.2/dashscope.egg-info/SOURCES.txt +209 -0
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope.egg-info/entry_points.txt +1 -0
- dashscope-1.26.2/dashscope.egg-info/requires.txt +12 -0
- dashscope-1.26.2/setup.cfg +11 -0
- dashscope-1.26.2/setup.py +73 -0
- dashscope-1.0.3/PKG-INFO +0 -233
- dashscope-1.0.3/README.md +0 -210
- dashscope-1.0.3/dashscope/__init__.py +0 -21
- dashscope-1.0.3/dashscope/aigc/__init__.py +0 -5
- dashscope-1.0.3/dashscope/aigc/conversation.py +0 -220
- dashscope-1.0.3/dashscope/aigc/generation.py +0 -91
- dashscope-1.0.3/dashscope/api_entities/aiohttp_request.py +0 -242
- dashscope-1.0.3/dashscope/api_entities/api_request_factory.py +0 -87
- dashscope-1.0.3/dashscope/api_entities/base_request.py +0 -25
- dashscope-1.0.3/dashscope/api_entities/dashscope_response.py +0 -187
- dashscope-1.0.3/dashscope/api_entities/http_request.py +0 -216
- dashscope-1.0.3/dashscope/audio/__init__.py +0 -3
- dashscope-1.0.3/dashscope/audio/asr/__init__.py +0 -5
- dashscope-1.0.3/dashscope/audio/asr/transcription.py +0 -138
- dashscope-1.0.3/dashscope/cli.py +0 -335
- dashscope-1.0.3/dashscope/client/base_api.py +0 -541
- dashscope-1.0.3/dashscope/common/api_key.py +0 -43
- dashscope-1.0.3/dashscope/common/constants.py +0 -86
- dashscope-1.0.3/dashscope/common/env.py +0 -20
- dashscope-1.0.3/dashscope/common/error.py +0 -100
- dashscope-1.0.3/dashscope/common/utils.py +0 -107
- dashscope-1.0.3/dashscope/deployment.py +0 -98
- dashscope-1.0.3/dashscope/file.py +0 -103
- dashscope-1.0.3/dashscope/finetune.py +0 -136
- dashscope-1.0.3/dashscope/io/input_output.py +0 -82
- dashscope-1.0.3/dashscope/model.py +0 -52
- dashscope-1.0.3/dashscope/protocol/websocket.py +0 -27
- dashscope-1.0.3/dashscope/version.py +0 -1
- dashscope-1.0.3/dashscope.egg-info/PKG-INFO +0 -233
- dashscope-1.0.3/dashscope.egg-info/SOURCES.txt +0 -45
- dashscope-1.0.3/dashscope.egg-info/requires.txt +0 -2
- dashscope-1.0.3/setup.cfg +0 -6
- dashscope-1.0.3/setup.py +0 -76
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope/api_entities/__init__.py +0 -0
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope/client/__init__.py +0 -0
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope/common/__init__.py +0 -0
- {dashscope-1.0.3/dashscope/io → dashscope-1.26.2/dashscope/finetune}/__init__.py +0 -0
- {dashscope-1.0.3/dashscope/protocol → dashscope-1.26.2/dashscope/finetune/reinforcement/common}/__init__.py +0 -0
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope.egg-info/dependency_links.txt +0 -0
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope.egg-info/not-zip-safe +0 -0
- {dashscope-1.0.3 → dashscope-1.26.2}/dashscope.egg-info/top_level.txt +0 -0
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
Copyright 2023-2024 Alibaba DashScope. All rights reserved.
|
|
2
|
-
|
|
3
1
|
Apache License
|
|
4
2
|
Version 2.0, January 2004
|
|
5
3
|
http://www.apache.org/licenses/
|
|
@@ -188,7 +186,7 @@ Copyright 2023-2024 Alibaba DashScope. All rights reserved.
|
|
|
188
186
|
same "printed page" as the copyright notice for easier
|
|
189
187
|
identification within third-party archives.
|
|
190
188
|
|
|
191
|
-
Copyright
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
192
190
|
|
|
193
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
192
|
you may not use this file except in compliance with the License.
|
|
@@ -200,4 +198,4 @@ Copyright 2023-2024 Alibaba DashScope. All rights reserved.
|
|
|
200
198
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
199
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
200
|
See the License for the specific language governing permissions and
|
|
203
|
-
limitations under the License.
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include dashscope/resources/qwen.tiktoken
|
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: dashscope
|
|
3
|
+
Version: 1.26.2
|
|
4
|
+
Summary: dashscope client sdk library
|
|
5
|
+
Home-page: https://dashscope.aliyun.com/
|
|
6
|
+
Author: Alibaba Cloud
|
|
7
|
+
Author-email: dashscope@alibabacloud.com
|
|
8
|
+
License: Apache 2.0
|
|
9
|
+
Platform: Posix; MacOS X; Windows
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Requires-Python: >=3.8.0
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Provides-Extra: tokenizer
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
|
|
24
|
+
# DashScope Python SDK
|
|
25
|
+
|
|
26
|
+
The DashScope Python SDK provides a comprehensive interface to [Alibaba Cloud Model Studio (Bailian)](https://www.alibabacloud.com/help/en/model-studio/) APIs, covering text generation, multi-modal understanding, embeddings, reranking, image/video generation, speech synthesis & recognition, and more.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
To install the DashScope Python SDK, simply run:
|
|
30
|
+
```shell
|
|
31
|
+
pip install dashscope
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If you clone the code from github, you can install from source by running:
|
|
35
|
+
```shell
|
|
36
|
+
pip install -e .
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To use tokenizer in local mode without downloading any files, run:
|
|
40
|
+
```shell
|
|
41
|
+
pip install dashscope[tokenizer]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from http import HTTPStatus
|
|
49
|
+
from dashscope import Generation
|
|
50
|
+
|
|
51
|
+
responses = Generation.call(
|
|
52
|
+
model="qwen-plus",
|
|
53
|
+
messages=[
|
|
54
|
+
{"role": "system", "content": "You are a helpful assistant."},
|
|
55
|
+
{"role": "user", "content": "Who are you?"},
|
|
56
|
+
],
|
|
57
|
+
result_format="message",
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if responses.status_code == HTTPStatus.OK:
|
|
61
|
+
print(responses.output.choices[0].message.content)
|
|
62
|
+
else:
|
|
63
|
+
print(f"Error: {responses.code} - {responses.message}")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## API Key Authentication
|
|
67
|
+
|
|
68
|
+
The SDK uses API key for authentication. Please refer to [official documentation for alibabacloud china](https://www.alibabacloud.com/help/en/model-studio/) and [official documentation for alibabacloud international](https://www.alibabacloud.com/help/en/model-studio/) regarding how to obtain your api-key.
|
|
69
|
+
|
|
70
|
+
### Using the API Key
|
|
71
|
+
|
|
72
|
+
1. Set the API key via code
|
|
73
|
+
```python
|
|
74
|
+
import dashscope
|
|
75
|
+
|
|
76
|
+
dashscope.api_key = 'YOUR-DASHSCOPE-API-KEY'
|
|
77
|
+
# Or specify the API key file path via code
|
|
78
|
+
# dashscope.api_key_file_path='~/.dashscope/api_key'
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. Set the API key via environment variables
|
|
83
|
+
|
|
84
|
+
a. Set the API key directly using the environment variable below
|
|
85
|
+
|
|
86
|
+
```shell
|
|
87
|
+
export DASHSCOPE_API_KEY='YOUR-DASHSCOPE-API-KEY'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
b. Specify the API key file path via an environment variable
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
export DASHSCOPE_API_KEY_FILE_PATH='~/.dashscope/api_key'
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
3. Save the API key to a file
|
|
97
|
+
```python
|
|
98
|
+
from dashscope import save_api_key
|
|
99
|
+
|
|
100
|
+
save_api_key(api_key='YOUR-DASHSCOPE-API-KEY',
|
|
101
|
+
api_key_file_path='api_key_file_location or (None, will save to default location "~/.dashscope/api_key"')
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Supported Models
|
|
106
|
+
|
|
107
|
+
| Category | Recommended Models | SDK Class |
|
|
108
|
+
|----------|-------------------|-----------|
|
|
109
|
+
| Text Generation | qwen3.7-max, qwen3.7-plus, qwen3.6-flash | `Generation` |
|
|
110
|
+
| Multi-Modal Understanding | qwen3.5-omni-plus, qwen3.7-plus (vision) | `MultiModalConversation` |
|
|
111
|
+
| Text Embedding | text-embedding-v4, text-embedding-v3 | `TextEmbedding` |
|
|
112
|
+
| Multi-Modal Embedding | tongyi-embedding-vision-plus, qwen3-vl-embedding | `MultiModalEmbedding` |
|
|
113
|
+
| Text ReRank | qwen3-rerank, gte-rerank-v2 | `TextReRank` |
|
|
114
|
+
| Image Generation | wan2.7-image-pro, qwen-image-2.0-pro | `ImageSynthesis` |
|
|
115
|
+
| Video Generation | wan2.7-t2v, wan2.7-i2v, happyhorse-1.0-t2v/i2v | `VideoSynthesis` |
|
|
116
|
+
| Speech Synthesis (TTS) | cosyvoice-v3.5-plus, cosyvoice-v1 | `SpeechSynthesizer`, `HttpSpeechSynthesizer` |
|
|
117
|
+
| Speech Recognition (ASR) | fun-asr-realtime, fun-asr, paraformer-v1 | `Transcription` |
|
|
118
|
+
| Omni (Real-time) | qwen3.5-omni-plus-realtime | `MultiModalConversation` |
|
|
119
|
+
|
|
120
|
+
For the latest model list, visit [Bailian Model Plaza](https://bailian.console.aliyun.com/).
|
|
121
|
+
|
|
122
|
+
## SDK Features
|
|
123
|
+
|
|
124
|
+
### Text Generation
|
|
125
|
+
|
|
126
|
+
Synchronous call with messages:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from http import HTTPStatus
|
|
130
|
+
from dashscope import Generation
|
|
131
|
+
|
|
132
|
+
response = Generation.call(
|
|
133
|
+
model="qwen-plus",
|
|
134
|
+
messages=[{"role": "user", "content": "Tell me a joke"}],
|
|
135
|
+
result_format="message",
|
|
136
|
+
)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Streaming:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
responses = Generation.call(
|
|
143
|
+
model="qwen-plus",
|
|
144
|
+
messages=[{"role": "user", "content": "Write a short poem"}],
|
|
145
|
+
result_format="message",
|
|
146
|
+
stream=True,
|
|
147
|
+
)
|
|
148
|
+
for response in responses:
|
|
149
|
+
if response.status_code == HTTPStatus.OK:
|
|
150
|
+
print(response.output.choices[0].message.content, end="")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Async (non-blocking):
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
from dashscope import AioGeneration
|
|
157
|
+
|
|
158
|
+
response = await AioGeneration.call(
|
|
159
|
+
model="qwen-plus",
|
|
160
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
161
|
+
result_format="message",
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Key parameters: `stream`, `temperature`, `top_p`, `top_k`, `max_tokens`, `seed`, `stop`, `repetition_penalty`, `tools`, `tool_choice`, `enable_thinking`.
|
|
166
|
+
|
|
167
|
+
### Multi-Modal Conversation
|
|
168
|
+
|
|
169
|
+
Vision (image + text), video, and audio understanding:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from dashscope import MultiModalConversation
|
|
173
|
+
|
|
174
|
+
response = MultiModalConversation.call(
|
|
175
|
+
model="qwen-vl-max",
|
|
176
|
+
messages=[{
|
|
177
|
+
"role": "user",
|
|
178
|
+
"content": [
|
|
179
|
+
{"image": "https://example.com/image.jpg"},
|
|
180
|
+
{"text": "What is in this image?"},
|
|
181
|
+
],
|
|
182
|
+
}],
|
|
183
|
+
)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Text Embedding
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from dashscope import TextEmbedding
|
|
190
|
+
|
|
191
|
+
response = TextEmbedding.call(
|
|
192
|
+
model="text-embedding-v3",
|
|
193
|
+
input="Hello world",
|
|
194
|
+
dimension=1024,
|
|
195
|
+
text_type="document",
|
|
196
|
+
)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Parameters: `text_type` ("query" / "document"), `dimension`, `output_type` ("dense" / "sparse" / "dense&sparse"), `instruct`.
|
|
200
|
+
|
|
201
|
+
### Multi-Modal Embedding
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from dashscope import (
|
|
205
|
+
MultiModalEmbedding,
|
|
206
|
+
MultiModalEmbeddingItemImage,
|
|
207
|
+
MultiModalEmbeddingItemText,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
response = MultiModalEmbedding.call(
|
|
211
|
+
model="multimodal-embedding-v1",
|
|
212
|
+
input=[
|
|
213
|
+
MultiModalEmbeddingItemImage("https://example.com/image.jpg", factor=1),
|
|
214
|
+
MultiModalEmbeddingItemText("a cat", factor=1),
|
|
215
|
+
],
|
|
216
|
+
)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Batch Text Embedding
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
from dashscope import BatchTextEmbedding
|
|
223
|
+
|
|
224
|
+
# Sync: submit and wait for result
|
|
225
|
+
result = BatchTextEmbedding.call(
|
|
226
|
+
model="text-embedding-async-v2",
|
|
227
|
+
url="https://your-file-url/texts.txt",
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
# Or async: submit task, then poll
|
|
231
|
+
task = BatchTextEmbedding.async_call(
|
|
232
|
+
model="text-embedding-async-v2",
|
|
233
|
+
url="https://your-file-url/texts.txt",
|
|
234
|
+
)
|
|
235
|
+
result = BatchTextEmbedding.wait(task)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Text ReRank
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
from dashscope import TextReRank
|
|
242
|
+
|
|
243
|
+
response = TextReRank.call(
|
|
244
|
+
model="gte-rerank-v2",
|
|
245
|
+
query="What is deep learning?",
|
|
246
|
+
documents=[
|
|
247
|
+
"Deep learning is a subset of machine learning.",
|
|
248
|
+
"The weather is nice today.",
|
|
249
|
+
"Neural networks are the foundation of deep learning.",
|
|
250
|
+
],
|
|
251
|
+
top_n=2,
|
|
252
|
+
return_documents=True,
|
|
253
|
+
)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Image Generation
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
from dashscope import ImageSynthesis
|
|
260
|
+
|
|
261
|
+
# Async task pattern
|
|
262
|
+
response = ImageSynthesis.async_call(
|
|
263
|
+
model="wanx-v1",
|
|
264
|
+
prompt="A serene mountain landscape at sunset",
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
# Wait for result
|
|
268
|
+
result = ImageSynthesis.wait(response)
|
|
269
|
+
|
|
270
|
+
# Sync call (for wan2.2-t2i-flash/plus)
|
|
271
|
+
result = ImageSynthesis.sync_call(
|
|
272
|
+
model="wan2.2-t2i-flash",
|
|
273
|
+
prompt="A serene mountain landscape at sunset",
|
|
274
|
+
)
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Video Generation
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
from dashscope import VideoSynthesis
|
|
281
|
+
|
|
282
|
+
# Text-to-video
|
|
283
|
+
response = VideoSynthesis.async_call(
|
|
284
|
+
model="wan2.7-t2v",
|
|
285
|
+
prompt="A cat playing with a ball of yarn",
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
result = VideoSynthesis.wait(response)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Speech Synthesis (TTS)
|
|
292
|
+
|
|
293
|
+
WebSocket streaming (real-time):
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
from dashscope.audio.tts_v2 import SpeechSynthesizer
|
|
297
|
+
|
|
298
|
+
synthesizer = SpeechSynthesizer(model="cosyvoice-v1", voice="longxiaochun")
|
|
299
|
+
audio = synthesizer.call("Hello, welcome to DashScope!")
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
HTTP (one-shot):
|
|
303
|
+
|
|
304
|
+
```python
|
|
305
|
+
from dashscope import HttpSpeechSynthesizer
|
|
306
|
+
|
|
307
|
+
result = HttpSpeechSynthesizer.call(
|
|
308
|
+
model="cosyvoice-v3-flash",
|
|
309
|
+
text="Hello, welcome to DashScope!",
|
|
310
|
+
voice="longxiaochun",
|
|
311
|
+
)
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Speech Recognition (ASR)
|
|
315
|
+
|
|
316
|
+
File transcription:
|
|
317
|
+
|
|
318
|
+
```python
|
|
319
|
+
from dashscope.audio.asr import Transcription
|
|
320
|
+
|
|
321
|
+
# Submit transcription task
|
|
322
|
+
response = Transcription.async_call(
|
|
323
|
+
model="paraformer-v1",
|
|
324
|
+
file_urls=["https://example.com/audio.wav"],
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
# Wait for result
|
|
328
|
+
result = Transcription.wait(response)
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Tokenization
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
from dashscope import Tokenization
|
|
335
|
+
|
|
336
|
+
response = Tokenization.call(model="qwen-turbo", prompt="Hello world")
|
|
337
|
+
print(response.usage)
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Local tokenizer (requires `pip install dashscope[tokenizer]`):
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
from dashscope import get_tokenizer
|
|
344
|
+
|
|
345
|
+
tokenizer = get_tokenizer("qwen-turbo")
|
|
346
|
+
tokens = tokenizer.encode("Hello world")
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Application
|
|
350
|
+
|
|
351
|
+
Call a Bailian application:
|
|
352
|
+
|
|
353
|
+
```python
|
|
354
|
+
from dashscope import Application
|
|
355
|
+
|
|
356
|
+
response = Application.call(app_id="YOUR_APP_ID", prompt="Hello")
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Fine-tuning
|
|
360
|
+
|
|
361
|
+
```python
|
|
362
|
+
from dashscope import FineTunes
|
|
363
|
+
|
|
364
|
+
# Create a fine-tuning job
|
|
365
|
+
response = FineTunes.call(
|
|
366
|
+
model="qwen-turbo",
|
|
367
|
+
training_file_ids=["file-xxx"],
|
|
368
|
+
hyper_parameters={"n_epochs": 3},
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
# Check status
|
|
372
|
+
status = FineTunes.get("ft-xxx")
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Deployments
|
|
376
|
+
|
|
377
|
+
```python
|
|
378
|
+
from dashscope import Deployments
|
|
379
|
+
|
|
380
|
+
# Deploy a fine-tuned model
|
|
381
|
+
response = Deployments.call(model="your-finetuned-model", capacity=1)
|
|
382
|
+
|
|
383
|
+
# List / get / scale / delete
|
|
384
|
+
deployments = Deployments.list()
|
|
385
|
+
info = Deployments.get("deployed-model-name")
|
|
386
|
+
Deployments.scale("deployed-model-name", capacity=2)
|
|
387
|
+
Deployments.delete("deployed-model-name")
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Assistants & Threads (Beta)
|
|
391
|
+
|
|
392
|
+
```python
|
|
393
|
+
from dashscope import Assistants, Threads, Messages, Runs
|
|
394
|
+
|
|
395
|
+
# Create an assistant
|
|
396
|
+
assistant = Assistants.create(
|
|
397
|
+
model="qwen-max",
|
|
398
|
+
name="Math Tutor",
|
|
399
|
+
instructions="You are a math tutor.",
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
# Create a thread and send a message
|
|
403
|
+
thread = Threads.create()
|
|
404
|
+
Messages.create(thread.id, content="What is 2+2?")
|
|
405
|
+
|
|
406
|
+
# Run the assistant and wait for completion
|
|
407
|
+
run = Runs.create(thread.id, assistant_id=assistant.id)
|
|
408
|
+
result = Runs.wait(run.id, thread_id=thread.id)
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### OpenAI-Compatible Interface
|
|
412
|
+
|
|
413
|
+
```python
|
|
414
|
+
from dashscope.aigc.chat_completion import Completions
|
|
415
|
+
|
|
416
|
+
response = Completions.create(
|
|
417
|
+
model="qwen-plus",
|
|
418
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
419
|
+
max_tokens=100,
|
|
420
|
+
)
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## CLI Reference
|
|
424
|
+
|
|
425
|
+
The DashScope CLI is installed automatically with the SDK. All commands support `-k / --api-key` for authentication (or use the `DASHSCOPE_API_KEY` environment variable).
|
|
426
|
+
|
|
427
|
+
### Text Generation
|
|
428
|
+
|
|
429
|
+
```shell
|
|
430
|
+
dashscope generation create -m qwen-plus -p "Hello, who are you?"
|
|
431
|
+
dashscope generation create -m qwen-plus -p "Tell me a story" --stream
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### File Management
|
|
435
|
+
|
|
436
|
+
```shell
|
|
437
|
+
dashscope files upload --file training_data.jsonl --purpose fine-tune
|
|
438
|
+
dashscope files list
|
|
439
|
+
dashscope files get file-xxx
|
|
440
|
+
dashscope files delete file-xxx
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Fine-tuning
|
|
444
|
+
|
|
445
|
+
```shell
|
|
446
|
+
# Create a fine-tuning job
|
|
447
|
+
dashscope ft create -m qwen-turbo -t file-xxx
|
|
448
|
+
|
|
449
|
+
# List jobs
|
|
450
|
+
dashscope ft list
|
|
451
|
+
|
|
452
|
+
# Get job status
|
|
453
|
+
dashscope ft get ft-xxx
|
|
454
|
+
|
|
455
|
+
# Stream training events
|
|
456
|
+
dashscope ft stream ft-xxx
|
|
457
|
+
|
|
458
|
+
# Cancel / delete a job
|
|
459
|
+
dashscope ft cancel ft-xxx
|
|
460
|
+
dashscope ft delete ft-xxx
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### Deployments
|
|
464
|
+
|
|
465
|
+
```shell
|
|
466
|
+
dashscope deployments create -m your-finetuned-model --capacity 1
|
|
467
|
+
dashscope deployments list
|
|
468
|
+
dashscope deployments get dm-xxx
|
|
469
|
+
dashscope deployments scale dm-xxx --capacity 2
|
|
470
|
+
dashscope deployments delete dm-xxx
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### OSS Upload
|
|
474
|
+
|
|
475
|
+
```shell
|
|
476
|
+
dashscope oss upload -m qwen-plus --file data.jsonl
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Agentic RL (Reinforcement Learning)
|
|
480
|
+
|
|
481
|
+
```shell
|
|
482
|
+
# Register reward/rollout functions
|
|
483
|
+
dashscope rl register_functions \
|
|
484
|
+
--rollout-classpaths rollout.py:MyRollout \
|
|
485
|
+
--reward-classpaths reward.py:MyReward
|
|
486
|
+
|
|
487
|
+
# Test registered functions
|
|
488
|
+
dashscope rl test_functions instance-xxx --type reward --input '{"key": "value"}'
|
|
489
|
+
|
|
490
|
+
# Upload training data
|
|
491
|
+
dashscope rl upload_data --training-files train.jsonl
|
|
492
|
+
|
|
493
|
+
# Run RL training workflow
|
|
494
|
+
dashscope rl run -c config.yaml
|
|
495
|
+
|
|
496
|
+
# Monitor jobs
|
|
497
|
+
dashscope rl list
|
|
498
|
+
dashscope rl get job-xxx
|
|
499
|
+
dashscope rl logs job-xxx
|
|
500
|
+
dashscope rl cancel job-xxx
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### Legacy Command Support
|
|
504
|
+
|
|
505
|
+
The CLI supports legacy argparse-style commands for backward compatibility:
|
|
506
|
+
|
|
507
|
+
```shell
|
|
508
|
+
# Legacy format (still works)
|
|
509
|
+
dashscope fine_tunes.call --training_file_ids file-xxx
|
|
510
|
+
|
|
511
|
+
# New format (recommended)
|
|
512
|
+
dashscope ft create --training-file-ids file-xxx
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
## Logging
|
|
516
|
+
To output Dashscope logs, you need to configure the logger.
|
|
517
|
+
```shell
|
|
518
|
+
export DASHSCOPE_LOGGING_LEVEL='info'
|
|
519
|
+
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
## Output
|
|
523
|
+
The output contains the following fields:
|
|
524
|
+
```
|
|
525
|
+
request_id (str): The request id.
|
|
526
|
+
status_code (int): HTTP status code, 200 indicates that the
|
|
527
|
+
request was successful, others indicate an error.
|
|
528
|
+
code (str): Error code if error occurs, otherwise empty str.
|
|
529
|
+
message (str): Set to error message on error.
|
|
530
|
+
output (Any): The request output.
|
|
531
|
+
usage (Any): The request usage information.
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## Error Handling
|
|
535
|
+
Currently, errors are thrown as exceptions.
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
## Contributing
|
|
539
|
+
Coming soon.
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
## License
|
|
543
|
+
This project is licensed under the Apache License (Version 2.0).
|
|
544
|
+
|
|
545
|
+
|