主页 > 电脑硬件  > 

通过API调用本地部署deepseek-r1模型

通过API调用本地部署deepseek-r1模型

如何本地部署 deepseek 请参考(windows 部署安装 大模型 DeepSeek-R1)

那么实际使用中需要开启API模式,这样可以无拘无束地通过API集成的方式,集成到各种第三方系统和应用当中。

上遍文章是基于Ollama框架运行了deepSeek R1模型,ollama相当于一个代理,我们直接调用ollama的API即可实现大模型接口的调用。

OpenAI的接口调用 from openai import OpenAI client = OpenAI( base_url='http://localhost:11434/v1/', api_key='ollama', ) chat_completion = client.chat pletions.create( messages=[ { 'role': 'user', 'content': '土拨鼠原产地', } ], model='deepseek-r1:1.5b', # stream=True, temperature=0.0, ) print(chat_completion)

输出:

使用ollama简易API调用 from ollama import chat from ollama import ChatResponse response: ChatResponse = chat(model='deepseek-r1:1.5b', messages=[ { 'role': 'user', 'content': '土拨鼠原产地', }, ]) print(response['message']['content']) # or access fields directly from the response object print(response.message.content)

输出:

标签:

通过API调用本地部署deepseek-r1模型由讯客互联电脑硬件栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“通过API调用本地部署deepseek-r1模型