This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
from openai import OpenAI
# 路径指定对,同时api_key暂时随便给,参数不纠结,主要是跑通
client = OpenAI(base_url="http://localhost:6006/v1",api_key="xxxx")
# 这里采用的是原生的OpenAI的方式
resp = client.chat.completions.create(
model = 'qwen3-8b',
# 传给大模型的提示词, 角色是普通用户,然后问一个问题
messages=[{'role': 'user','content': '请介绍一下什么是深度学习'}],
# 模型的温度?
temperature=0.8,
# 默认最大就是8k,模型部署的时候指定的
# max_tokens=
# 生成文本的参数…………
presence_penalty=1.5,
# qwen3 特有参数 , 表示是否开启深度思考
extra_body={'chat_template_kwargs': {'enable_thinking': True}}
)
print(resp);