Qwen-Embedding
复制成功!
概述
通用文本向量的批处理接口,通过这个接口客户可以以文本方式一次性的提交大批量的向量计算请求,在系统完成所有的计算之后,大模型服务平台会将结果信息存储在结果文件中供客户下载解析。
输入
文本
输出
功能
定价
- 文本输入¥0.7/M tokens
速率限制
API 参考
调用API复制成功!
12345678910111213141516171819202122232425262728293031323334
import time
import dashscope
from http import HTTPStatus
dashscope.base_http_api_url = "https://cn-beijing.maas.qianwenaiapi.com/api/v1"
# 提交异步任务(输入文件要求:UTF-8 .txt,每行一条文本,最大 200MB / 10万行)
resp = dashscope.BatchTextEmbedding.async_call(
model="text-embedding-async-v1",
url="https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241016/nigwvr/text_embedding_file.txt",
text_type="document",
)
if resp.status_code != HTTPStatus.OK:
print(resp)
exit(1)
task_id = resp.output["task_id"]
print(f"task_id: {task_id}")
# 轮询任务状态
while True:
result = dashscope.BatchTextEmbedding.fetch(task=resp)
status = result.output["task_status"]
print(f"status: {status}")
if status == "SUCCEEDED":
print(result)
break
elif status == "FAILED":
print(result)
break
time.sleep(10)