Dockerfile construct
Browse files- Dockerfile +17 -0
- README.md +17 -0
- predict.py +3 -1
Dockerfile
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ubuntu:latest
|
| 2 |
+
|
| 3 |
+
RUN apt-get update && \
|
| 4 |
+
apt-get install -y python3 python3-pip && \
|
| 5 |
+
rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
RUN echo '[global]' > /etc/pip.conf && \
|
| 8 |
+
echo 'index-url = https://mirrors.aliyun.com/pypi/simple/' >> /etc/pip.conf && \
|
| 9 |
+
echo 'trusted-host = mirrors.aliyun.com' >> /etc/pip.conf
|
| 10 |
+
|
| 11 |
+
RUN pip3 install gradio requests[socks] mdtex2html
|
| 12 |
+
|
| 13 |
+
COPY . /gpt
|
| 14 |
+
WORKDIR /gpt
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
CMD ["python3", "main.py"]
|
README.md
CHANGED
|
@@ -1,2 +1,19 @@
|
|
| 1 |
# ChatGPT 学术优化
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# ChatGPT 学术优化
|
| 2 |
|
| 3 |
+
## 使用docker
|
| 4 |
+
|
| 5 |
+
``` sh
|
| 6 |
+
# 构建镜像
|
| 7 |
+
docker build -t gpt-academic .
|
| 8 |
+
# 运行
|
| 9 |
+
docker run --rm -it --net=host gpt-academic
|
| 10 |
+
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
## 参考项目
|
| 14 |
+
```
|
| 15 |
+
https://github.com/Python-Markdown/markdown
|
| 16 |
+
https://github.com/gradio-app/gradio
|
| 17 |
+
https://github.com/polarwinkel/mdtex2html
|
| 18 |
+
https://github.com/GaiZhenbiao/ChuanhuChatGPT
|
| 19 |
+
```
|
predict.py
CHANGED
|
@@ -6,10 +6,11 @@ import requests
|
|
| 6 |
import importlib
|
| 7 |
import os
|
| 8 |
|
| 9 |
-
from config import proxies, API_URL, API_KEY
|
| 10 |
if os.path.exists('config_private.py'):
|
| 11 |
# 放自己的秘密如API和代理网址
|
| 12 |
from config_private import proxies, API_URL, API_KEY
|
|
|
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
|
|
@@ -90,6 +91,7 @@ def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt=''
|
|
| 90 |
except:
|
| 91 |
chatbot.append(('', 'Requests Timeout, Network Error.'))
|
| 92 |
yield chatbot, history, "Requests Timeout"
|
|
|
|
| 93 |
|
| 94 |
token_counter = 0
|
| 95 |
partial_words = ""
|
|
|
|
| 6 |
import importlib
|
| 7 |
import os
|
| 8 |
|
|
|
|
| 9 |
if os.path.exists('config_private.py'):
|
| 10 |
# 放自己的秘密如API和代理网址
|
| 11 |
from config_private import proxies, API_URL, API_KEY
|
| 12 |
+
else:
|
| 13 |
+
from config import proxies, API_URL, API_KEY
|
| 14 |
|
| 15 |
|
| 16 |
|
|
|
|
| 91 |
except:
|
| 92 |
chatbot.append(('', 'Requests Timeout, Network Error.'))
|
| 93 |
yield chatbot, history, "Requests Timeout"
|
| 94 |
+
raise TimeoutError
|
| 95 |
|
| 96 |
token_counter = 0
|
| 97 |
partial_words = ""
|