Git Product home page Git Product logo

gaizhenbiao / chuanhuchatgpt Goto Github PK

View Code? Open in Web Editor NEW
14.7K 14.7K 2.2K 2.68 MB

GUI for ChatGPT API and many LLMs. Supports agents, file-based QA, GPT finetuning and query with web search. All with a neat UI.

Home Page: https://huggingface.co/spaces/JohnSmith9982/ChuanhuChatGPT

License: GNU General Public License v3.0

Python 67.00% Dockerfile 0.10% Batchfile 0.08% CSS 9.92% Shell 0.22% JavaScript 14.46% HTML 8.22%
chatbot chatglm chatgpt-api claude dalle3 ernie gemini gemma inspurai llama midjourney minimax moss ollama qwen spark stablelm

chuanhuchatgpt's People

Contributors

2p990i9hpral avatar binary-husky avatar chenhengjie123 avatar chinwh2019 avatar gaizhenbiao avatar hsungong avatar ihomesoft avatar ina111 avatar iskoldt-x avatar johnz03 avatar keldos-li avatar kilig947 avatar libukai avatar lihuacai168 avatar mzhao-ouo avatar noahzark avatar paradoxzw avatar pedrogruvhagen avatar plucury avatar qingxudw avatar redheartsecretman avatar slideslide avatar stingshen avatar toantranct avatar tusik avatar xhongc avatar xingfanxia avatar xudongliu avatar xzajyjs avatar yefori-go avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chuanhuchatgpt's Issues

希望提供 docker-compose 部署方式

docker-compose 方便提供映射路径,将 API key、System prompt 和保留会话都保留在 NAS 硬盘存储。

另外,dockerhub 提示没有标签,不能直接通过群晖 Docker 下载。

ubuntu采用新clone运行出现不回复情况

后端错误代码:
File "/usr/local/lib/python3.8/dist-packages/gradio/routes.py", line 384, in run_predict
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.8/dist-packages/gradio/blocks.py", line 1032, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.8/dist-packages/gradio/blocks.py", line 854, in call_function
raise ValueError("Need to enable queue to use generators.")
ValueError: Need to enable queue to use generators.
什么原因呢?
问了以下chatgpt说是enable_queue 没有设置为Ture也未能解决

请提供通过代理访问 openai 的功能

目前 openai 已经被墙了, 请提供 socks5/http 代理接口让程序走代理来访问 openai API

最好想 API key 一样 可以通过 代码/环境变量/网页等多种形式来输入代理地址

项目运行1天后请求gpt的api失败

提示:
image
重新运行项目后可以正常访问,看报错是openai.error.APIConnectionError: Error communicating with OpenAI: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))

更新脚本文件后,SSLError

下面是报错内容,麻烦up主了,谢谢您

chat_counter - 0
payload is - {'model': 'gpt-3.5-turbo', 'messages': [{'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': '你好'}], 'temperature': 1, 'top_p': 1, 'n': 1, 'stream': True, 'presence_penalty': 0, 'frequency_penalty': 0}
Traceback (most recent call last):
  File "C:\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
    self._prepare_proxy(conn)
  File "C:\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
    conn.connect()
  File "C:\Miniconda3\lib\site-packages\urllib3\connection.py", line 364, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "C:\Miniconda3\lib\site-packages\urllib3\connection.py", line 501, in _connect_tls_proxy
    socket = ssl_wrap_socket(
  File "C:\Miniconda3\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "C:\Miniconda3\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "C:\Miniconda3\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Miniconda3\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Miniconda3\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Miniconda3\lib\site-packages\requests\adapters.py", line 440, in send
    resp = conn.urlopen(
  File "C:\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Miniconda3\lib\site-packages\urllib3\util\retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Miniconda3\lib\site-packages\gradio\routes.py", line 384, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Miniconda3\lib\site-packages\gradio\blocks.py", line 1032, in process_api
    result = await self.call_function(
  File "C:\Miniconda3\lib\site-packages\gradio\blocks.py", line 858, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Miniconda3\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\Miniconda3\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "C:\Miniconda3\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "C:\Miniconda3\lib\site-packages\gradio\utils.py", line 448, in async_iteration
    return next(iterator)
  File "D:\Desktop\ChuanhuChatGPT-main\ChuanhuChatbot.py", line 99, in predict
    response = requests.post(API_URL, headers=headers,
  File "C:\Miniconda3\lib\site-packages\requests\api.py", line 117, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Miniconda3\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Miniconda3\lib\site-packages\requests\sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Miniconda3\lib\site-packages\requests\sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "C:\Miniconda3\lib\site-packages\requests\adapters.py", line 517, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

生成大量 <br/> 标签

当第二次输入代码时,第一次对话的代码会自动加上非常多的
标签,然后超过token数,返回失败。

image

image

已解决:报错openai.error.APIConnectionError

返回错误信息:
raise error.APIConnectionError(
openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)')))

我试过更换API KEY、使用全局代理都显示这个错误。

Chatgpt说:该代码中使用了Python的raise语句来抛出APIConnectionError异常,这是一个自定义的异常类,表示与OpenAI API通讯时发生了错误。其中的错误信息包括了请求的URL地址以及导致错误的具体原因。从错误信息中可以看出,这个异常是由OpenAI API返回的,表明与该API的通讯过程中出现了SSLError(SSL错误)的异常,而具体的错误原因是违反了SSL协议。因此,这是一个由于与OpenAI API通讯时出现SSL连接问题而导致的异常。

api被墙了?

部署在阿里云华北服务器上,key认证一直过不去, 是api也被墙了吗?

It seems dialog saving is not working

Thanks for this project.

Everything seems to be functioning as expected, however, I am experiencing an issue with the save dialog. When I click on it, nothing happens. Interestingly, the loading dialog button works perfectly fine.

Just to keep you informed, I have been running the project using Docker, as I have been experiencing errors when attempting to run the project directly.

I have tried accessing the project on both Firefox and Chrome, and unfortunately, the issue persists on both browsers.

如何保存这次对话

在关闭网页之后,本次的对话就结束了,那么如何保存这次对话,让下次打开可以接着用呢?

一些关于显示的小bug,&lt;、&gt;、&nbsp;等异常显示

首先,十分感谢作者的开源,使我们可以更加方便的调用API。如下是部分代码:

def parse_text(text):
    lines = text.split("\n")
    for i,line in enumerate(lines):
        if "```" in line:
            items = line.split('`')
            if items[-1]:
                lines[i] = f'<pre><code class="{items[-1]}">'
            else:
                lines[i] = f'</code></pre>'
        else:
            if i > 0:
                line = line.replace("<", "&lt;")
                line = line.replace(">", "&gt;")
                lines[i] = '<br/>'+line.replace(" ", "&nbsp;")
    return "".join(lines)

关于上述代码,我发现在web中显示时,有时候会将符号<>转换为&lt;&gt;,空格显示转换为&nbsp;

1.这应该是由于chatGPT在给出回复时,```包裹的代码块中,HTML相关特殊字符部分是没有转义的,需要如上代码转义。但是非代码块部分,对于特殊字符,chatGPT的回复都会带上`,因此不应该对所有行的特殊字符进行替换,而是只替换代码块中的部分
2.我发现chatGPT的回复中,````包裹的代码块不一定会给出使用的语言(如c++),因此通过tems[-1]来判断是否会有问题?

如下是我更改后的代码,目前解决了我遇到的异常显示问题。

def parse_text(text):
    lines = text.split("\n")
    count = 0 // 用于判断'''符号是起始标志还是结束标志
    for i,line in enumerate(lines):
        if "```" in line:
            count += 1
            items = line.split('`')
            if count % 2 == 1:
                lines[i] = f'<pre><code class="{items[-1]}">'
            else:
                lines[i] = f'</code></pre>'
        else:
            if i > 0:
                if count % 2 == 1:
                    line = line.replace("&", "&amp;")
                    line = line.replace("\"", "&quot;")
                    line = line.replace("\'", "&apos;")
                    line = line.replace("<", "&lt;")
                    line = line.replace(">", "&gt;")
                    line = line.replace(" ", "&nbsp;")
                lines[i] = '<br/>'+line
    return "".join(lines)

如有错误请指正

如何用nginx反向代理

我想使用nginx反向代理到127.0.0.1:7860,不知道是不是我的nginx配置问题,访问后返回{"detail":"Not Found"},请问应该如何设置?

请教如何加密码?

抱歉大佬,我确实是小白。
下载了py文件,本地修改好,cp到容器内,还是不行。
大佬的docker安装方法,能否加个目录映射。

感谢辛苦了。

ws连接超时

image
您好,我部署在了国外的vps上,启动后发现ws连接都是超时的,知道是啥情况吗

fail installing gradio

运行 pip install gradio --upgrade --force-reinstall 遇到错误,求解

Building wheels for collected packages: orjson
Building wheel for orjson (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for orjson (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [1462 lines of output]
Running maturin pep517 build-wheel -i c:\users\woshi\appdata\local\programs\python\python38-32\python.exe --compatibility off --target i686-pc-windows-msvc
馃摝 Including license file "C:\Users\woshi\AppData\Local\Temp\pip-install-l8q22sjy\orjson_67485430601d4ac5858f65d14f071b31\LICENSE-APACHE"
馃摝 Including license file "C:\Users\woshi\AppData\Local\Temp\pip-install-l8q22sjy\orjson_67485430601d4ac5858f65d14f071b31\LICENSE-MIT"
馃嵐 Building a mixed python/rust project
馃敆 Found pyo3-ffi bindings
馃悕 Found CPython 3.8 at c:\users\woshi\appdata\local\programs\python\python38-32\python.exe
Compiling target-lexicon v0.12.6
Compiling autocfg v1.1.0
Compiling once_cell v1.17.1
Compiling serde v1.0.152
Compiling version_check v0.9.4
Compiling rustversion v1.0.11
Compiling libc v0.2.139
Compiling itoa v1.0.5
Compiling cfg-if v1.0.0
Compiling ryu v1.0.12
Compiling cc v1.0.79
Compiling serde_json v1.0.93
Compiling num-traits v0.2.15
error: could not compile cfg-if due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile itoa due to 10 previous errors
error: could not compile ryu due to 39 previous errors
error: could not compile once_cell due to 145 previous errors
馃挜 maturin failed
Caused by: Failed to build a native library through cargo
Caused by: Cargo build finished with "exit code: 101": "cargo" "rustc" "--release" "--target" "i686-pc-windows-msvc" "--manifest-path" "C:\\Users\\woshi\\AppData\\Local\\Temp\\pip-install-l8q22sjy\\orjson_67485430601d4ac5858f65d14f071b31\\Cargo.toml" "--message-format" "json" "--lib"
error[E0463]: can't find crate for core
|
= note: the i686-pc-windows-msvc target may not be installed
= help: consider downloading the target with rustup target add i686-pc-windows-msvc

  error[E0463]: can't find crate for `compiler_builtins`


  error: aborting due to 2 previous errors


  For more information about this error, try `rustc --explain E0463`.

  error[E0463]: can't find crate for `core`
    |
    = note: the `i686-pc-windows-msvc` target may not be installed
    = help: consider downloading the target with `rustup target add i686-pc-windows-msvc`


  error[E0463]: can't find crate for `compiler_builtins`


  error[E0463]: can't find crate for `core`

建议在readme里加上urllib3版本问题的解决方法

因为这个问题重装了urllib3也没解决,后来在b站评论里看到说要装1.25.11版本的,才终于搞定,下面是原评论:

如果有人也出现了openai.error.APIConnectionError提示的报错,那可能是urllib3的版本导致的。urllib3版本大于1.25.11,就会出现这个问题。

解决方案是卸载urllib3然后重装至1.25.11版本再重新运行一遍就可以

在终端或命令提示符中卸载urllib3
pip uninstall urllib3

然后,您可以通过使用指定版本号的pip install命令来安装所需的版本:
pip install urllib3==1.25.11

请问怎么关闭服务

请问怎么合理的关闭服务,ctrl-C 会提示关闭中,再来一次看起来是退了,但是看起来会堵死,导致下次启动的时候报 getaddrinfo failed

mac下使用docker无法启用share模式

问题描述

依赖冲突导致无法本地安装,使用了docker
但因为网络环境build不成功,我重新写了个dockerfile文件(换源,但针对arm处理器)。但是启动后发现,host模式不可用(docker不支持mac和win的host模式),只能使用端口转发。但是并不清楚share所使用的端口号,无法实现公网访问功能。
另外建议提供一个docker-compose.yml,方便将日志和聊天记录输出到挂载点。

环境

macbook m1
docker
dockerfile
”“” Dockerfile
FROM ubuntu:20.04
RUN sed -i 's/ports.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN sed -i 's/focal/jammy/g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y python3 python3-pip build-essential
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
RUN pip install openai gradio markdown
ENV PATH=/root/.local/bin:$PATH
COPY . /app
WORKDIR /app
ENV my_api_key empty
CMD ["python3", "-u", "ChuanhuChatbot.py", "2>&1", "|", "tee", "/var/log/application.log"]
“”“

输出

”“”
Running on local URL: http://0.0.0.0:80

Could not create share link. Please check your internet connection or our status page: https://status.gradio.app/
“”“

能否改成流式输出?

就是chatgpt边回复的时候边输出,不要等它回复完再一起显示,这样可以更快阅读到回复的内容,以及知道它是否卡住/卡死

docker运行报错啥情况啊

docker: Error response from daemon: invalid volume specification: '/root/chatGPThistory:app/history': invalid mount config for type "bind": invalid mount path: 'app/history' mount path must be absolute.

could not create share link

When I set demo.launch(share=True),the command line reminds me Could not create share link, please check your internet connection. However,My internet connection is fine,what sh
the problem
ould I do to solve this problem?

代码里的中文引号问题

这个问题有点难搞,是个HTML/CSS问题。出于某种诡异的本地化考虑,"在系统语言为中文的浏览器上会显示为中文引号。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.