分享
Qwen-3本地部署与调用详解(下)
输入“/”快速插入内容
Qwen-3本地部署与调用详解(下)
课程说明:
•
体验课内容节选自
《2025大模型Agent智能体开发实战》(5月班)
完整版付费课程
体验课时间有限,若想深度学习大模型技术,欢迎大家报名由我主讲的
《2025大模型Agent智能体开发实战》(5月班)
68%
32%
此外,公开课全套学习资料,已上传至网盘
(
https://pan.baidu.com/s/1wtLsh6h3RhTfCBFgWa5BYQ
提取码: r8rq )
需要更系统深入学习大模型可扫码⬆️添加助教咨询喔~
部分项目成果演示
代码块
Python
from IPython.display import Video
•
MateGen项目演示
代码块
Python
Video("https://ml2022.oss-cn-hangzhou.aliyuncs.com/4.MateGen%20Pro%20%E9%A1%B9%E7%9B%AE%E5%8A%9F%E8%83%BD%E6%BC%94%E7%A4%BA.mp4", width=800, height=400)
Your browser does not support the
video
element.
•
智能客服项目演示
代码块
Python
Video("https://ml2022.oss-cn-hangzhou.aliyuncs.com/%E6%99%BA%E8%83%BD%E5%AE%A2%E6%9C%8D%E6%A1%88%E4%BE%8B%E6%BC%94%E7%A4%BA.mp4", width=800, height=400)
Your browser does not support the
video
element.
•
Dify项目演示
代码块
Python
Video("https://ml2022.oss-cn-hangzhou.aliyuncs.com/2f1b47f42c65fd59e8d3a83e6cb9f13b_raw.mp4", width=800, height=400)
Your browser does not support the
video
element.
•
LangChain&LangGraph搭建Multi-Agnet
代码块
Python
Video("https://ml2022.oss-cn-hangzhou.aliyuncs.com/%E5%8F%AF%E8%A7%86%E5%8C%96%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90Multi-Agent%E6%95%88%E6%9E%9C%E6%BC%94%E7%A4%BA%E6%95%88%E6%9E%9C.mp4", width=800, height=400)
Your browser does not support the
video
element.
Qwen-3本地部署与调用详解(下)
3. ollama API本地调用Qwen3
在部署完ollama之后,即可借助ollama API(也就是OpenAI风格API)在代码环境中调用模型。
•
导入OpenAI库及实例化OpenAI客户端
代码块
Python
from openai import OpenAI
client = OpenAI(
base_url='http://192.168.110.131:11434/v1/',
api_key='ollama', # 必须传递该参数
)
prompt = "在单词\"strawberry\"中,总共有几个R?"
messages = [
{"role": "user", "content": prompt}
]
•
创建消息并获得回复
代码块
Python
response = client.chat.completions.create(
messages=messages,
model='qwen3:14b',
)
print(response.choices[0].message.content)