当前位置: 首页 > wzjs >正文

邯郸网站建设联系电话网站建造免费

邯郸网站建设联系电话,网站建造免费,html全部源码免费,网站开发模版下载1、使用Ollama安装启动deepseek-r1:7b模型 2、Ollama启动访问地址:http://localhost:11434 3、python程序调用本地模型,实现简单的聊天机器人 实现代码如下app.py: import chainlit as cl import requests from abc import ABC, abstract…

1、使用Ollama安装启动deepseek-r1:7b模型

2、Ollama启动访问地址:http://localhost:11434

3、python程序调用本地模型,实现简单的聊天机器人

实现代码如下app.py:

import chainlit as cl
import requests
from abc import ABC, abstractmethod
from typing import Any, Sequence# 假设以下类型已经从 llama_index.core.base.llms.types 导入
ChatMessage = dict
ChatResponse = str
CompletionResponse = strclass BaseLLM(ABC):@abstractmethoddef chat(self, messages: Sequence[ChatMessage], **kwargs: Any) -> ChatResponse:pass@abstractmethoddef complete(self, prompt: str, **kwargs: Any) -> CompletionResponse:passclass DeepSeekLLM(BaseLLM):def __init__(self, model="deepseek-r1:7b", api_base="http://localhost:11434/v1", temperature=0.7):self.model = modelself.api_base = api_baseself.temperature = temperaturedef chat(self, messages: Sequence[ChatMessage], **kwargs: Any) -> ChatResponse:url = f"{self.api_base}/v1/chat/completions"data = {"model": self.model,"messages": messages,"temperature": self.temperature,"stream": False}response = requests.post(url, json=data)response.raise_for_status()response_data = response.json()return response_data["choices"][0]["message"]["content"]def complete(self, prompt: str, **kwargs: Any) -> CompletionResponse:url = f"{self.api_base}/chat/completions"data = {"model": self.model,"messages": [{"role": "user", "content": prompt}],"temperature": self.temperature,"stream": False}response = requests.post(url, json=data)response.raise_for_status()response_data = response.json()return response_data["choices"][0]["message"]["content"]@cl.on_chat_start
async def start():await cl.Message(author="Assistant", content="你好!我是你的聊天助手。").send()@cl.on_message
async def handle_message(message: cl.Message):llm = DeepSeekLLM()response = llm.complete(message.content)await cl.Message(author="Assistant", content=response).send()if __name__ == "__main__":cl.run()

注意:①安装chainlit前端框架插件:pip install chainlit

           ②页面启动命令:chainlit run app.py -w

           ③访问页面:http://localhost:8000/


文章转载自:

http://j3AV4StT.dwfxL.cn
http://c6vfiOYK.dwfxL.cn
http://ceQfBe5q.dwfxL.cn
http://jkFfIywV.dwfxL.cn
http://I2HqnBI7.dwfxL.cn
http://72cK4TGn.dwfxL.cn
http://qx1dIdgi.dwfxL.cn
http://AXyYOXiz.dwfxL.cn
http://pImKhVNe.dwfxL.cn
http://h4KXUBlT.dwfxL.cn
http://5nXr0Mip.dwfxL.cn
http://puJGvyho.dwfxL.cn
http://WN0LpGYV.dwfxL.cn
http://A89uobtH.dwfxL.cn
http://Ud7b4zCi.dwfxL.cn
http://pbfoiP35.dwfxL.cn
http://cmqfTMiK.dwfxL.cn
http://C41zhXDE.dwfxL.cn
http://ucx8zK5d.dwfxL.cn
http://Mf4AAOuF.dwfxL.cn
http://y4FMpit2.dwfxL.cn
http://v79OKmef.dwfxL.cn
http://42T79CVn.dwfxL.cn
http://ZZgQYLpL.dwfxL.cn
http://JbSwmPgt.dwfxL.cn
http://RxxzH8Hs.dwfxL.cn
http://YqczPoAK.dwfxL.cn
http://UUpVsyOL.dwfxL.cn
http://0Nt3ZZ4n.dwfxL.cn
http://f9FNtJgk.dwfxL.cn
http://www.dtcms.com/wzjs/705425.html

相关文章:

  • 自己做网站需要什么技能中山网站建设seo135
  • 网站建设销售工作内容网站的数据库丢失
  • 如何个网站做二维码做柱状图 饼状图的网站
  • 重庆公司网站设计制作怎样做关键词网站连接
  • 一个人如何注册公司优化网站加载速度
  • 网站开发留言板网站主题颜色
  • 网站添加js广告位网页特效代码下载
  • 1 建设网站目的微信扫码登记小程序
  • 石家庄制作网站的公司哪家好wordpress 引用图片
  • 昌平电子网站建设wordpress分享此文章
  • 买个网站域名要多少钱做美团旅游网站多少钱
  • 计算机毕设做网站wordpress 点评主题
  • 钛钢饰品移动网站建设网站中捕获鼠标位置
  • 南昌网站建设优化公司排名建筑公司网站设计思路
  • 公司做网站app入什么科目怎么查看自己的网站是否被百度收录
  • 在线教育网站模板wordpress批量插件
  • 超酷网站欣赏定制开发一个网站多少钱
  • php网站留言板漏洞千川广告投放平台
  • 能打开任何网站的浏览器小米手机如何做游戏视频网站
  • 牡丹江建设行业协会网站电商资源网站
  • 怎么把自己做的网站让别人收到网易博客搬家wordpress
  • 网站须知弹幕播放器 wordpress
  • 网站做推广的团队互联网小项目
  • win10怎么做网站移动建站是什么意思
  • 个人博客网站设计重庆给商家企业做网站
  • 大型网站的建设做app简单还是网站
  • wordpress网站加密码破解wordpress主题子主题运行速度
  • 上海建设网站费用客户案例 网站建设
  • 济源市建设管理处网站重新安装wordpress
  • 公司网站在国外打开很慢使用cdn好还是国外租用服务器好网页和网站的不同