diff --git a/Dockerfile b/Dockerfile index e69de29..62e0eb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ubuntu:latest + +RUN apt-get update && \ + apt-get install -y python3 python3-pip && \ + rm -rf /var/lib/apt/lists/* + +RUN echo '[global]' > /etc/pip.conf && \ + echo 'index-url = https://mirrors.aliyun.com/pypi/simple/' >> /etc/pip.conf && \ + echo 'trusted-host = mirrors.aliyun.com' >> /etc/pip.conf + +RUN pip3 install gradio requests[socks] mdtex2html + +COPY . /gpt +WORKDIR /gpt + + +CMD ["python3", "main.py"] \ No newline at end of file diff --git a/README.md b/README.md index f1c86dd..6655d36 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ # ChatGPT 学术优化 +## 使用docker + +``` sh +# 构建镜像 +docker build -t gpt-academic . +# 运行 +docker run --rm -it --net=host gpt-academic + +``` + +## 参考项目 +``` +https://github.com/Python-Markdown/markdown +https://github.com/gradio-app/gradio +https://github.com/polarwinkel/mdtex2html +https://github.com/GaiZhenbiao/ChuanhuChatGPT +``` diff --git a/predict.py b/predict.py index 32432be..da8b887 100644 --- a/predict.py +++ b/predict.py @@ -6,10 +6,11 @@ import requests import importlib import os -from config import proxies, API_URL, API_KEY if os.path.exists('config_private.py'): # 放自己的秘密如API和代理网址 from config_private import proxies, API_URL, API_KEY +else: + from config import proxies, API_URL, API_KEY @@ -90,6 +91,7 @@ def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt='' except: chatbot.append(('', 'Requests Timeout, Network Error.')) yield chatbot, history, "Requests Timeout" + raise TimeoutError token_counter = 0 partial_words = ""