深度揭秘(赓续怎么读)赓续精神血脉,传承红色基因,(续)chatgpt怎么构建web页面聊天,
是不是把chatgpt加装到他们笔记本电脑上一则该文早已听完,没想的好友能先看完,第一集接著讲把chatgpt加装好了,不该在旧版本框闲聊,我做了两个单纯的网页web闲聊操作方式如下表所示:
1) 具体来说你要在却是别的产品目录的配置文档里头增建两个重新命名为templates配置文档,和两个app.txt文档格式,
关上app.txt黏贴下列标识符留存:
from flask import Flask, render_template, request, jsonify
from generate_response import generate_response
app = Flask(__name__)
@app.route(/, methods=[GET, POST])
def index():
if request.method == POST:
user_input = request.form[user_input]
generated_response = generate_response(user_input)
# 将聚合的积极响应传达给后端
return jsonify(response=generated_response)
return render_template(index.html)
if __name__ == __main__:
app.run(debug=True)
接着把app.txt文档前缀换成.py,变为app.py
2)再在app.py同产品目录下增建两个generate_response.py文档,老规矩,先建成文档格式txt格式,黏贴下列标识符后,前缀再换成 .py
import openai
openai.api_key = "用你的OpenAI API密钥替换这里"
def generate_response(user_input):
prompt = f"与用户闲聊: {user_input}"
response = openai.Completion.create(
engine="text-davinci-002",
prompt=prompt,
max_tokens=3000,
n=1,
stop=None,
temperature=0.3,
top_p=0.5, # 采样概率阈值
)
message = response.choices[0].text.strip()
return message
3) 关上templates配置文档,接着增建两个index.txt文档格式文档,关上后黏贴下列标识符留存:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Chatbot</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f8f9fa;
}
#chat-container {
flex: 1;
padding: 20px;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
#chat-history {
border: 1px solid #ced4da;
border-radius: 5px;
padding: 15px;
background-color: #ffffff;
max-height: 400px;
overflow-y: auto;
margin-bottom: 20px;
}
#chat-form {
display: flex;
flex-direction: row;
}
#user_input {
flex: 1;
border-radius: 5px;
border: 1px solid #ced4da;
padding: 5px;
margin-right: 10px;
}
</style>
</head>
<body>
<div class="container">
<div id="chat-container">
<div id="chat-history"></div>
<form id="chat-form">
<input id="user_input" type="text" name="user_input" placeholder="Type your message here" autocomplete="off">
<button class="btn btn-primary" type="submit">Send</button>
</form>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$("#chat-form").on("submit", function(event) {
event.preventDefault();
const user_input = $("#user_input").val();
// 将用户提问添加到闲聊记录中
const userMessage = `<p>You: ${user_input}</p>`;
$("#chat-history").append(userMessage);
$.ajax({
type: "POST",
url: "/",
data: {user_input: user_input},
success: function(response) {
// 将聚合的积极响应添加到闲聊记录中
const newMessage = `<p>AI: ${response.response}</p>`;
$("#chat-history").append(newMessage);
}
});
$("#user_input").val(""); // 清空输入框
});
});
</script>
</body>
</html>
接着把index.txt文档格式文档前缀换成 .py 变为index.html
接着运行先用旧版本关上根产品目录,命令:cd C:\Users\777\AppData\Roaming\Python\Python37(划线部分换成你他们的相应路径),回车;
之后再输入命令:Python app.py, 出现下面图片的情况就说明你又成功了,
接着在浏览器关上:http://127.0.0.1:5000 看看浏览去是不是出来了的闲聊框,我只是做了两个单纯闲聊网页,当然你也能他们再设计两个他们喜欢的风格,好!我看看效果:
恭喜你!你又成功了!!!!!!就是这个单纯粗暴!!!
上一篇:学到了吗(今年投资啥)今年投资怎么样,投资者提问:今年chatgpt AI 火爆,给AI+游戏产业也带来了巨大变...,
栏 目:chatgpt安装
下一篇:真没想到(利用ChatGPT写代码)利用ChatGPT写小说,利用chatgpt处理Excel,
本文标题:深度揭秘(赓续怎么读)赓续精神血脉,传承红色基因,(续)chatgpt怎么构建web页面聊天,
本文地址:http://www.shopify123.cn/chatgptanzhuang/4120.html
您可能感兴趣的文章
- 05-17居然可以这样(chatGPT中文网)ChatGPT中文免费破解版,chatgpt时代来了丨介绍丨小智AI,
- 05-16全程干货(wordpress 商品展示插件)wordpress做产品展示,wordpress网站对接chatgpt自动发布安装教程,
- 05-15居然可以这样(chatgpt国内能用吗)chatgpt怎么读,chatgpt如何搭建,
- 05-13太疯狂了(gpt3的文章生成器)gpt3中文自动生成小说,gpt3中文生成教程-chatgpt中文批量生成,
- 05-13难以置信(tracy 抖音)check it out check it out 抖音,chatgpt3中文生成模型原理-chatgpt中文生成教程,
- 05-11怎么可以错过(mongodb4.4.2安装教程)mongodb4.0安装教程,问chatgpt:在windows和ubuntu20.04上安装mongodb和进
- 05-11奔走相告(chatgpt中文)chatgpt app,chatgpt的计费方式和收费标准,一篇文章搞清楚,
- 05-10硬核推荐(如何制作一个爱)一图读懂如何制作,跟着chatgpt学习——如何制作出一个属于自己的AI,
- 05-06难以置信(如何训练自己的内心变得强大呢)怎样训练自己内心强大,如何训练自己的chatgpt模型,
- 05-06原创(ai人工智能英语翻译)关于ai智能的英语词汇有哪些,智能AI的时代已来临,号称中文版的chatgpt,试试?,
阅读排行
- 1居然可以这样(chatGPT中文网)ChatGPT中文免费破解版,chatgpt时代来了丨
- 2全程干货(wordpress 商品展示插件)wordpress做产品展示,wordpres
- 3居然可以这样(chatgpt国内能用吗)chatgpt怎么读,chatgpt如何搭建,
- 4太疯狂了(gpt3的文章生成器)gpt3中文自动生成小说,gpt3中文生成教程-chatg
- 5难以置信(tracy 抖音)check it out check it out 抖音,ch
- 6怎么可以错过(mongodb4.4.2安装教程)mongodb4.0安装教程,问chatg
- 7奔走相告(chatgpt中文)chatgpt app,chatgpt的计费方式和收费标准,
- 8硬核推荐(如何制作一个爱)一图读懂如何制作,跟着chatgpt学习——如何制作出一个属于自
- 9难以置信(如何训练自己的内心变得强大呢)怎样训练自己内心强大,如何训练自己的chatgpt
- 10原创(ai人工智能英语翻译)关于ai智能的英语词汇有哪些,智能AI的时代已来临,号称中文版
推荐教程
- 05-11奔走相告(chatgpt中文)chatgpt app,chatgpt的计费方式和收费标准,
- 05-17居然可以这样(chatGPT中文网)ChatGPT中文免费破解版,chatgpt时代来了丨
- 05-13太疯狂了(gpt3的文章生成器)gpt3中文自动生成小说,gpt3中文生成教程-chatg
- 04-23一篇读懂(qq怎么设置优雅的访问了别人的空间)怎么在qq引起他注意,如何优雅地在你的QQ中
- 04-23真没想到(中国为何没驻美大军)为什么中国没有美国驻军,为什么中国没有chatgpt #ai
- 04-21满满干货(怎么玩自己小豆视频)苹果手机怎么玩安卓游戏,国内怎么玩chatGPT?国产cha
- 04-22不看后悔(chatty app)chat tips,chatgpt推荐的装机方案,
- 04-23燃爆了(为什么中国没有参加世界杯)为什么中国没有健怡可乐,为什么中国没有chatgpt?,
- 04-21看完 chatgpt 写的声明,mini 公关真可下岗了 IBM 回应格芯起诉:这场诉讼毫
- 04-23不要告诉别人(chatbot和ChatGPT的区别)chatbot谁开发的,投资者提问:c