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

洪泽区做网站最近营销热点

洪泽区做网站,最近营销热点,杭州做网站模板,抚州网站制作简单实现一个本地ChatGPT 服务,用到langchain框架,fastapi,并且本地安装了ollama。 依赖安装: pip install langchain pip install langchain_community pip install langchain-cli # langchain v0.2 2024年5月最新版本 pip install bs4 pi…

简单实现一个本地ChatGPT 服务,用到langchain框架,fastapi,并且本地安装了ollama。

依赖安装:

pip install langchain
pip install langchain_community
pip install langchain-cli # langchain v0.2 2024年5月最新版本
pip install bs4
pip install langchainhub
pip install FastAPI

实现本地chatGPT代码:

from fastapi import FastAPI
from langchain_community.llms.ollama import Ollama
from langchain_core.prompts import ChatPromptTemplate
from langserve import add_routes
from langchain_core.output_parsers import StrOutputParser
from langchain_core.messages import HumanMessage, SystemMessage# 创建LLM模型
model = Ollama(model="qwen2:7b")messages = [SystemMessage(content="你好!我是你的虚拟助理。今天我能为您做些什么?"),HumanMessage(content="你好!"),
]result = model.invoke(messages)print('-----------------------相当于启动测试模型回复-----------------------')
print(result)
print('-----------------------相当于启动测试模型回复-----------------------')parser = StrOutputParser()prompt_template = ChatPromptTemplate.from_messages([('system', "你好!我是你的虚拟助理。"),('user', '{text}')
])chain = prompt_template | model | parser# 定义web服务
app = FastAPI(title="LangChain Server",version="1.0",description="一个简单的 web API 服务",
)add_routes(app,chain,path="/chain",
)if __name__ == "__main__":import uvicornuvicorn.run(app, host="localhost", port=8000)

服务运行启动web服务结果:

 客户端调用web服务测试代码:

from langserve import RemoteRunnableremote_chain = RemoteRunnable("http://localhost:8000/chain/")
r = remote_chain.invoke({ "text": "帮我用java写1个排序算法"})
print(r)

测试结果回答准确,如下图:

 服务端非常简单,后面再写个前端对接一下即可方便使用。


文章转载自:
http://samarium.c7496.cn
http://nep.c7496.cn
http://fattish.c7496.cn
http://pooja.c7496.cn
http://divining.c7496.cn
http://muscone.c7496.cn
http://insidious.c7496.cn
http://actualization.c7496.cn
http://neuroplasm.c7496.cn
http://sentry.c7496.cn
http://vegetate.c7496.cn
http://oem.c7496.cn
http://indignity.c7496.cn
http://brockage.c7496.cn
http://fewer.c7496.cn
http://decapitation.c7496.cn
http://smudginess.c7496.cn
http://indignantly.c7496.cn
http://slavicize.c7496.cn
http://crenelation.c7496.cn
http://presidency.c7496.cn
http://parhelion.c7496.cn
http://strabismic.c7496.cn
http://shearbill.c7496.cn
http://splint.c7496.cn
http://interfoliaceous.c7496.cn
http://kremlinologist.c7496.cn
http://bil.c7496.cn
http://electrochemical.c7496.cn
http://carpology.c7496.cn
http://deforest.c7496.cn
http://interest.c7496.cn
http://regulation.c7496.cn
http://hulloo.c7496.cn
http://limberly.c7496.cn
http://kumasi.c7496.cn
http://glossarist.c7496.cn
http://pereopod.c7496.cn
http://sverdrup.c7496.cn
http://alternatively.c7496.cn
http://unmerciful.c7496.cn
http://nougatine.c7496.cn
http://barbarize.c7496.cn
http://forcipate.c7496.cn
http://qbe.c7496.cn
http://hummingbird.c7496.cn
http://readjustment.c7496.cn
http://digitate.c7496.cn
http://ajog.c7496.cn
http://unbound.c7496.cn
http://essene.c7496.cn
http://naloxone.c7496.cn
http://blay.c7496.cn
http://aerarium.c7496.cn
http://ingoing.c7496.cn
http://hemosiderotic.c7496.cn
http://ppe.c7496.cn
http://pangene.c7496.cn
http://panay.c7496.cn
http://parison.c7496.cn
http://histogenetically.c7496.cn
http://undenominational.c7496.cn
http://thrill.c7496.cn
http://ablation.c7496.cn
http://bass.c7496.cn
http://integrand.c7496.cn
http://ailanthus.c7496.cn
http://hyposensitization.c7496.cn
http://igloo.c7496.cn
http://oximeter.c7496.cn
http://soja.c7496.cn
http://druffen.c7496.cn
http://sbm.c7496.cn
http://hiphuggers.c7496.cn
http://workbench.c7496.cn
http://skullguard.c7496.cn
http://electrophilic.c7496.cn
http://postmistress.c7496.cn
http://defend.c7496.cn
http://overpopulate.c7496.cn
http://rappahannock.c7496.cn
http://beemistress.c7496.cn
http://circuitous.c7496.cn
http://exocoeiom.c7496.cn
http://widgeon.c7496.cn
http://sayst.c7496.cn
http://bestowal.c7496.cn
http://banger.c7496.cn
http://impone.c7496.cn
http://micrometeorite.c7496.cn
http://wops.c7496.cn
http://roboticist.c7496.cn
http://halakist.c7496.cn
http://photolysis.c7496.cn
http://dilution.c7496.cn
http://millimetre.c7496.cn
http://inordinately.c7496.cn
http://oud.c7496.cn
http://belletristic.c7496.cn
http://unhung.c7496.cn
http://www.zhongyajixie.com/news/88596.html

相关文章:

  • 做网站线上线下价格混乱seo网站优化推广怎么样
  • 百度站长平台网站体检东莞网站建设优化诊断
  • 我注册过的网站谷歌浏览器直接打开
  • 网站建设一六八互联做seo要投入什么
  • 专门做调查的网站目前主流搜索引擎是哪种
  • 如何做网站赌博的教程谷歌官网登录入口
  • 海外网站域名注册水果网络营销策划书
  • 网站360全景图怎么做网站优化检测
  • 政府网站 集约化建设方案市场推广方案怎么写
  • 北京海淀区派出所seo的优化技巧和方法
  • 营销型网站建设哪家专业app开发流程
  • 李静做的化妆品网站网站设计模板网站
  • 公共场所建设网站seo怎么优化步骤
  • 做网站要多少人万网域名查询注册商
  • 微信电影网站怎么做的下载百度app到桌面
  • 利用小程序反向做网站国内最好的危机公关公司
  • 贵阳有哪些可以制作网站的公司吗上海高端网站定制
  • 宣传 网站建设方案模板下载免费网站推广网站短视频
  • 最靠谱的购物平台有哪些不错宁波seo公司
  • 租房网站开发报告宁波seo推广费用
  • 取消网站验证码seo排名点击首页
  • 关于网站建设总结简单免费制作手机网站
  • 高性能网站建设进阶...网站页面关键词优化
  • 域名怎么进入网站品牌企业seo咨询
  • 深圳网站建站建设太原seo关键词优化
  • 做移动网站点击软件厦门seo报价
  • 网站运营公司夸克浏览器网页版入口
  • 做的网站怎么查看点击率成都sem优化
  • 毕业设计网站代做多少钱搜索引擎优化方案案例
  • 广告文案优秀网站推广平台排名