revCHATGPT开发示例

需要安装revchatgpt库和flask库,自行安装

直接上代码。

chat.py

from flask import Flask, request, render_template
from revChatGPT.V1 import Chatbot

app = Flask(__name__)
chatbot = Chatbot(config={
  "access_token": "这里是你的access_token"
})

@app.route("/", methods=["GET", "POST"])
def index():
    if request.method == "POST":
        prompt = request.form["prompt"]
        response = ""

        for data in chatbot.ask(prompt):
            response = data["message"]

        return render_template("index.html", response=response)
    return render_template("index.html")

if __name__ == "__main__":
    app.run(host="0.0.0.0")

templates\index.html

<!doctype html>
<html>
<head>
<title>ChatGPT PLUS 开发示例</title>
</head>
<body>
<h1>ChatGPT PLUS 开发示例:关注我获得更多新资讯</h1>
<form method="post">
<input type="text" name="prompt" placeholder="输入问题" required>
<button type="submit">发送</button>
</form>
{% if response %}
<p>{{ response }}</p>
{% endif %}
</body>
</html>

 

给TA打赏
共{{data.count}}人
人已打赏
站长笔记

成功的把机器人加到wordpress中

2023-2-16 14:25:58

站长笔记

关于国内conda安装cuda11.6+pytorch的那些事。

2023-2-20 19:39:26

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索