Spaces:
Runtime error
Runtime error
add private conf
Browse files- check_proxy.py +2 -6
- main.py +3 -1
- predict.py +3 -15
check_proxy.py
CHANGED
@@ -21,10 +21,6 @@ def check_proxy(proxies):
|
|
21 |
|
22 |
|
23 |
if __name__ == '__main__':
|
24 |
-
import os
|
25 |
-
|
26 |
-
# 放自己的秘密如API和代理网址
|
27 |
-
from config_private import proxies
|
28 |
-
else:
|
29 |
-
from config import proxies
|
30 |
check_proxy(proxies)
|
|
|
21 |
|
22 |
|
23 |
if __name__ == '__main__':
|
24 |
+
try: from config_private import proxies # 放自己的秘密如API和代理网址 os.path.exists('config_private.py')
|
25 |
+
except: from config import proxies
|
|
|
|
|
|
|
|
|
26 |
check_proxy(proxies)
|
main.py
CHANGED
@@ -3,7 +3,9 @@ import os
|
|
3 |
import markdown, mdtex2html
|
4 |
from predict import predict
|
5 |
from show_math import convert as convert_math
|
6 |
-
|
|
|
|
|
7 |
|
8 |
def find_free_port():
|
9 |
import socket
|
|
|
3 |
import markdown, mdtex2html
|
4 |
from predict import predict
|
5 |
from show_math import convert as convert_math
|
6 |
+
|
7 |
+
try: from config_private import proxies, WEB_PORT # 放自己的秘密如API和代理网址 os.path.exists('config_private.py')
|
8 |
+
except: from config import proxies, WEB_PORT
|
9 |
|
10 |
def find_free_port():
|
11 |
import socket
|
predict.py
CHANGED
@@ -4,24 +4,12 @@ import logging
|
|
4 |
import traceback
|
5 |
import requests
|
6 |
import importlib
|
7 |
-
import os
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
from config_private import proxies, API_URL, API_KEY, TIMEOUT_SECONDS
|
12 |
-
else:
|
13 |
-
from config import proxies, API_URL, API_KEY, TIMEOUT_SECONDS
|
14 |
|
15 |
timeout_bot_msg = 'Request timeout, network error. please check proxy settings in config.py.'
|
16 |
|
17 |
-
def compose_system(system_prompt):
|
18 |
-
return {"role": "system", "content": system_prompt}
|
19 |
-
|
20 |
-
|
21 |
-
def compose_user(user_input):
|
22 |
-
return {"role": "user", "content": user_input}
|
23 |
-
|
24 |
-
|
25 |
def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt='', retry=False,
|
26 |
stream = True, additional_fn=None):
|
27 |
|
@@ -46,7 +34,7 @@ def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt=''
|
|
46 |
|
47 |
print(f"chat_counter - {chat_counter}")
|
48 |
|
49 |
-
messages = [
|
50 |
if chat_counter:
|
51 |
for index in range(0, 2*chat_counter, 2):
|
52 |
what_i_have_asked = {}
|
|
|
4 |
import traceback
|
5 |
import requests
|
6 |
import importlib
|
|
|
7 |
|
8 |
+
try: from config_private import proxies, API_URL, API_KEY, TIMEOUT_SECONDS # 放自己的秘密如API和代理网址 os.path.exists('config_private.py')
|
9 |
+
except: from config import proxies, API_URL, API_KEY, TIMEOUT_SECONDS
|
|
|
|
|
|
|
10 |
|
11 |
timeout_bot_msg = 'Request timeout, network error. please check proxy settings in config.py.'
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt='', retry=False,
|
14 |
stream = True, additional_fn=None):
|
15 |
|
|
|
34 |
|
35 |
print(f"chat_counter - {chat_counter}")
|
36 |
|
37 |
+
messages = [{"role": "system", "content": system_prompt}]
|
38 |
if chat_counter:
|
39 |
for index in range(0, 2*chat_counter, 2):
|
40 |
what_i_have_asked = {}
|