DeepSeek
复制成功!
立即体验加入对比
文本生成
概述
文本生成
DeepSeek-R1-Distill-Qwen-1.5B是一个基于Qwen2.5-Math-1.5B的蒸馏大型语言模型,使用了 DeepSeek R1 的输出。
输入
文本
输出
文本
功能
前缀补全
函数调用
缓存
结构化输出
批量任务
联网搜索
微调
上下文
上下文
32.76K
最大输入
32.76K
最大输出
16.38K
速率限制
- RPM每分钟请求数60
- TPM每分钟 Token 数100K
API 参考
获取 API Key复制成功!
12345678910111213141516171819202122232425262728293031323334353637
import os
from dashscope import Generation
import dashscope
dashscope.base_http_api_url = "https://dashscope.aliyuncs.com/api/v1/"
messages = [{"role": "user", "content": "你是谁?"}]
completion = Generation.call(
api_key=os.getenv("DASHSCOPE_API_KEY"),
model="deepseek-r1-distill-qwen-1.5b",
messages=messages,
result_format="message",
stream=True,
incremental_output=True,
)
is_answering = False
print("=" * 20 + "思考过程" + "=" * 20)
for chunk in completion:
if (
chunk.output.choices[0].message.content == ""
and chunk.output.choices[0].message.reasoning_content == ""
):
pass
else:
if (
chunk.output.choices[0].message.reasoning_content != ""
and chunk.output.choices[0].message.content == ""
):
print(chunk.output.choices[0].message.reasoning_content, end="", flush=True)
elif chunk.output.choices[0].message.content != "":
if not is_answering:
print("\n" + "=" * 20 + "完整回复" + "=" * 20)
is_answering = True
print(chunk.output.choices[0].message.content, end="", flush=True)