liangyang666 / chatgpt-web Goto Github PK
View Code? Open in Web Editor NEW使用GPT-3.5 API创建的ChatGPT聊天页面,支持云部署,多用户使用,多对话管理,公式显示,流式动态显示,windows和linux均可极简部署,网页版 html python flask
License: MIT License
使用GPT-3.5 API创建的ChatGPT聊天页面,支持云部署,多用户使用,多对话管理,公式显示,流式动态显示,windows和linux均可极简部署,网页版 html python flask
License: MIT License
您好,请问一下如果我在我自己的AWS ec2或者在香港的阿里云服务器部署(香港阿里云服务器可以直接访问chatgpt api并返回结果)
应该需要在那里进行修改?实在抱歉我对于服务器的一些概念不是很清楚
有时候我们只需要复制gpt给我们回复的代码段内容,而不是所有内容。
希望能实现这个功能,谢谢
大佬,首先十分感谢技术分享,真的很好用,给大佬点赞👍🏻👍🏻👍🏻
使用时在代码互动上会有以下几个问题:
大佬有空看看能否优化下
显示如下
Verify your identity
Railway is a platform for good actors to build great products. We're sorry for this safety-check inconvenience; we aim to keep things cool for everybody. Thank you.
Due to unusual activity on your account, your GitHub account cannot be used for verification.
不知道啥问题
Seen below error sometime, not found the way to fix...
[2023-04-11 16:57:05,799] ERROR in app: Exception on /loadHistory [GET]
Traceback (most recent call last):
File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1615, in full_dispatch_request
return self.finalize_request(rv)
File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1630, in finalize_request
response = self.make_response(rv)
File "/home/user/.local/lib/python3.8/site-packages/flask/app.py", line 1740, in make_response
rv = self.response_class.force_type(rv, request.environ)
File "/home/user/.local/lib/python3.8/site-packages/werkzeug/wrappers/base_response.py", line 269, in force_type
response = BaseResponse(*_run_wsgi_app(response, environ))
File "/home/user/.local/lib/python3.8/site-packages/werkzeug/test.py", line 1119, in run_wsgi_app
app_rv = app(environ, start_response)
TypeError: 'dict' object is not callable
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
您好,这样报错是什么情况
首先感谢作者共享此项目,在非docker环境是最方便的部署方式了
另外请教下
谢谢
Hi Leo,
我发现可以通过在聊天框输入任意一个已知的用户id而登录到该用户的聊天界面,且无需访问密码,请问这个流程是否考虑单独给每个用户id设置一个访问密码呢?
谢谢!
这个如何解决
代码是类似这样的
import pickle
file_path = 'test.pkl'
with open(file_path, 'rb') as f:
data = pickle.load(f)
print(data)
报错是这样的
Traceback (most recent call last):
File "D:\pythonProject\PKL.py", line 7, in
data = pickle.load(f)
ModuleNotFoundError: No module named 'LRU_cache'
大佬,可以加一个vercel部署方式嘛
您好,打包成单独exe后,报错。
Traceback (most recent call last):
File "main.py", line 681, in
File "flask\app.py", line 884, in run
File "flask\cli.py", line 723, in show_server_banner
File "click\utils.py", line 299, in echo
AttributeError: 'NoneType' object has no attribute 'write'
request error: ('Connection aborted.', OSError(0, 'Error'))
你好LiangYang,
首先非常感谢你的这个作品,部署简易且很好用,谢谢!
我最近碰到了一个问题,我想试着把你默认用的gpt-3-turbo切换成gpt-4的模型,但是我试着在代码里直接改发现没有效果,他还是会显示用的是gpt-3-turbo。
我测试我用的模型的方法:
因为我现在的账号的rate limit是每分钟只能发3条消息,我通过超过这个限制让openai返回一个报错信息,里面会显示我正在使用的模型,也就是gpt-3.5-turbo。
想问下切换模型该如何操作呢?谢谢!
改完80出现
以一种访问权限不允许的方式做了一个访问套接字的尝试。
持久化存储文件路径为: D:\同步空间\demo笔记\style_transfer\ChatGPT-Web-main\all_user_dict_v2.pkl
已加载上次存储的用户上下文,共有1用户, 分别是
0 用户id:2462366256 对话统计: 默认对话[13]
程序很不错~虽然界面需要改进,但是基本该有的功能都有了
我这边想在代码基础上加入个逻辑,用户id得来自于数据库,
尝试加了个user_exist方法,并给new_user_dict添加了个逻辑,但达不到需求
`def user_exists(user_id):
# 连接数据库,查询用户id是否存在
conn = pymysql.connect(host=host, user=user, password=password, database=database)
sql_select_wechatnumber = f"SELECT *FROM table WHERE wechatnumber = '{user_id}'"
with conn.cursor() as cursor:
cursor.execute(sql_select_wechatnumber)
sql_select_number_result = cursor.fetchall()
return bool(sql_select_number_result)
def new_user_dict(user_id, send_time):
if not user_exists(user_id):
return "用户 ID 不存在于数据库,请重新输入或选择已有用户 ID"
chat_id = str(uuid.uuid1())
user_dict = {"chats": {chat_id: new_chat_dict(user_id, "默认对话", send_time)},
"selected_chat_id": chat_id,
"default_chat_id": chat_id}
user_dict['chats'][chat_id]['messages_history'].insert(1, {"role": "assistant",
"content": "- 创建新的用户id成功,请牢记该id \n"
})
return user_dict`
能提供下修改思路吗,比如涉及哪些函数等
request error:
HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc23c23f1c0>: Failed to establish a new connection: [Errno 111] Connection refused')))
填了自己的API-key。科学上网使用PAC连线,不管发什么,都是报这个错误。
首次运行时,输入new: user后,一直报错:NameError: name 'all_user_dict' is not defined
我详细查看了源代码,愣是没发现all_user_dict在哪里定义的,帮忙给些指导,多谢
希望开发具有保存历史记录到本地😄
在zhile-io大佬的pandora项目中,提供了一种免消耗免翻墙调用的方法,可以参考这个科普帖子. 我主页的项目都是用它实现的,认为不错,所以推荐给大家
各位可以先尝试一下这个程序, 但是请勿过多使用我的api, 毕竟不能同时服务2个客户端
import openai
import time
def fake_api(query,max,a,tem): #用户输入,最大token,是否流式输出,温度
openai.api_key = "fk-yU3UOSY13E9WsAkKBTrkq1KiiqIsAXBs_J6OTh_yvJM" # 使用假的 API 密钥
openai.api_base = "https://ai.fakeopen.com/v1/"
start_time = time.time() # 记录开始时间
response = openai.ChatCompletion.create(
model='gpt-3.5-turbo',
messages=[
{'role': 'user', 'content': query}
],
temperature=tem,
max_tokens=max,
stream=True # 开启流式输出
)
result = "" # 创建一个空字符串来保存流式输出的结果
for chunk in response:
# 确保字段存在
if 'choices' in chunk and 'delta' in chunk['choices'][0]:
chunk_msg = chunk['choices'][0]['delta'].get('content', '')
result += chunk_msg # 将输出内容附加到结果字符串上
if a:
print(chunk_msg, end='', flush=True)
time.sleep(0.05)
return result # 返回流式输出的完整结果
if __name__ == '__main__':
while True:
query = input("You: ")
full_result = fake_api(query,1500,True,1) # 将结果保存到 full_result 变量中
望采纳!
我不需要代理上网,如何跳过代理?屏蔽了flask_main.py里的两行代理没用
是否可以针对每个用户限制使用次数
高手您好 請問您
1.出現以圖片上的錯誤 .請問我需要做什麼
request error: SOCKSHTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError('<urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x7f1008623df0>: Failed to establish a new connection: [Errno 111] Connection refused'))
2.關於http://192.168.66.243:5000/ 5000我可以從哪裡修改80
3.請問您.本LiangYang666版本 只能用ChatGPT Plus USD $20/mo.免費的一般版本Free Plan也可以用嗎?
4.請問您 關於 flask_main.py 設定
os.environ['HTTP_PROXY'] = 'socks5://127.0.0.1:7890' # 請問您此處需要設定嗎? 目前這樣在我區網可以開啟LiangYang666服務網頁.但會出現圖上錯誤
os.environ['HTTPS_PROXY'] = 'socks5://127.0.0.1:7890' # 同理
API_KEY = "sk-fiet05cS6Kyc1o0jCs1ET3BlbkFJg0edU8crvcHpoXXXXXX" #此處是我KEY設定
请教方法,谢谢
app = Flask(name)
app.config['SECRET_KEY'] = os.urandom(24)
os.environ['HTTP_PROXY'] = 'socks5://127.0.0.1:7890'
os.environ['HTTPS_PROXY'] = 'socks5://127.0.0.1:7890'
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") # 从环境变量中获取api_key,或直接设置api_key
openai.api_key = OPENAI_API_KEY
STREAM_FLAG = True # 是否开启流式推送
USER_SAVE_MAX = 12 # 设置最多存储12个用户,当用户过多时可适当调大
chat_context_number_max = 5 # 连续对话模式下的上下文最大数量
lock = threading.Lock() # 用于线程锁
请问是否会考虑加入Prompt Store这种预存储的对话提示词呢?类似https://github.com/Chanzhaoyu/chatgpt-web 项目中的这种
我把项目部署到了Zeabur上 ,但还是有部分cdnjs.cloudflare.com的资源,比如https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js这种需要代理才能获取到
以及,我用chrome浏览器的时候会一直卡在‘正在回复’,然后后端终止程序的时候后端会显示回复。换成edge浏览器就没有这个问题了?这又是什么情况?
非常感谢!
通过railway部署项目,每次重新部署会导致之前的聊天记录消失,想问下有办法做聊天记录的备份迁移吗
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.