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

浅蓝色.net企业网站源码带后台上海高端建站网站

浅蓝色.net企业网站源码带后台,上海高端建站网站,中国建盏形象设计大赛获奖名单,wordpress 地图相册网上很多别人写的#xff0c;要用账号也不放心。就自己写了一个基于gradio的聊天界面#xff0c;部署后可以本地运行。 特点#xff1a; 可以用openai的#xff0c;也可以用api2d#xff0c;其他api可以自己测试一下。使用了langchain的库 可以更改模型#xff0c;会的…网上很多别人写的要用账号也不放心。就自己写了一个基于gradio的聊天界面部署后可以本地运行。 特点 可以用openai的也可以用api2d其他api可以自己测试一下。使用了langchain的库 可以更改模型会的可以自己改代码更新模型 支持修改temperature对话轮数 公开代码copy后填了自己的api就能直接运行 import gradio as grfrom langchain.chat_models import ChatOpenAI from langchain.schema import HumanMessage, AIMessageapi_key *** # openai api, api2d api api_base https://oa.api2d.net/v1 # api地址 models [gpt-3.5-turbo-0613, gpt-4-0613] #模型名称可以修改block_css .importantButton {background: linear-gradient(45deg, #7e0570,#5d1c99, #6e00ff) !important;border: none !important; } .importantButton:hover {background: linear-gradient(45deg, #ff00e0,#8500ff, #6e00ff) !important;border: none !important; }default_theme_args dict(font[Source Sans Pro, ui-sans-serif, system-ui, sans-serif],font_mono[IBM Plex Mono, ui-monospace, Consolas, monospace], )init_message f欢迎使用 ChatGPT Gradio UIdef respond(query, model, temperature, history_turns, chat_history):global chat_turnsllm ChatOpenAI(temperaturetemperature,openai_api_keyapi_key,openai_api_baseapi_base,model_namemodel)history[]len_history min(chat_turns, history_turns)if chat_turns 0:for turn in range(len_history):history.append(HumanMessage(contentchat_history[len_history-turn][0]));history.append(AIMessage(contentchat_history[len_history-turn][1]));history.append(HumanMessage(contentquery));#print(history)response llm(history).content;chat_history.append((query, response));chat_turns 1return , chat_historydef clear(chat_history):global chat_turnschat_history [(None, 已清除对话历史)]chat_turns 0return chat_historydef setting_change(model ,temperature, history_turns ,chat_history):global chat_turnschat_history [(None, f设置更新\n 模型名称{model} \n 温度{temperature} \n 记忆历史对话轮数{history_turns}\n)]chat_turns 0return chat_historywith gr.Blocks(cssblock_css, themegr.themes.Default(**default_theme_args)) as demo:gr.Markdown(ChatGPT Gradio)chat_turns 0with gr.Row():with gr.Column(scale10):chatbot gr.Chatbot([[None, init_message]],elem_idchat-box,label聊天历史)query gr.Textbox(label输入问题,placeholder请输入提问内容按回车进行提交)clear_button gr.Button(重新对话, visibleTrue)with gr.Column(scale5):model gr.Radio(models,label请选择使用模型,valuemodels[0], interactiveTrue)temperature gr.Slider(0,1,value0.8,step0.1,labelTemperature,interactiveTrue)history_turns gr.Slider(1, 20,value5,step1,label对话轮数,info记录历史对话轮数,interactiveTrue)settings_button gr.Button(更新设置, visibleTrue)settings_button.click(fnsetting_change, inputs[model, temperature, history_turns, chatbot], outputs[chatbot])query.submit(respond, [query, model, temperature, history_turns, chatbot], [query, chatbot])clear_button.click(fnclear,inputs[chatbot],outputs[chatbot])demo.launch()需要的库requirement.txt 文件 langchain openai gradio
http://www.hkea.cn/news/14268282/

相关文章:

  • 中元建设网站深圳H5网站开发
  • 创建公司网站教程如何选择网站托管公司
  • 青海西宁制作网站企业做网站需要前置审批
  • 东莞外贸网站建设策划方案永久免费自助建站平台
  • 可以免费进入的网站正能量域名洛阳建站
  • 网站建设推广的10种方法阳江房产网站
  • 做美工的网站大连百度网站快速优化
  • 重庆推广网站排名价格网站备案流程
  • 莱芜网站优化公司wordpress wpautop
  • 建设银行e路通网站wordpress用户注册插件汉化
  • 安阳网站制作优化手机上免费制作ppt的软件
  • 东莞网站建设纸品包装前端网页代码模板
  • 青岛有没有做网站的监利县建设局网站
  • 电影网站源码系统免费一天赚500元游戏
  • 部门网站的开发 意义做框架模板的网站
  • 便捷网站建设价格怎么建立一个公司的网站
  • 陕西省住房和城乡建设厅网站安康市建设局网站
  • 国际时事新闻最新消息阳江网站推广优化公司
  • 选择网站建设免备案空间什么意思
  • 网站开发培训要多少钱长沙网络推广代理
  • 广东 网站建设 公司排名安徽网站排名优化公司
  • 做网站甘特图 内容龙岗住房和建设局网站官网
  • 网站建设小程序开发报价seo机构
  • 网站切换城市代码深圳四站合一网站建设电话
  • 网站未来发展规划培训心得体会800字
  • 伊利网站建设安徽企业建站系统平台
  • 网站建设人才有哪些ps软件免费下载破解中文版
  • 临沂市建设局的网站网站建设公司新报价
  • 陕西建设部网站诸城做网站的公司
  • 成都网站搭建公司哪家便宜品牌策划公司怎么样