add private conf
This commit is contained in:
parent
88aaf310c4
commit
3103817990
@ -21,10 +21,6 @@ def check_proxy(proxies):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import os
|
try: from config_private import proxies # 放自己的秘密如API和代理网址 os.path.exists('config_private.py')
|
||||||
if os.path.exists('config_private.py'):
|
except: from config import proxies
|
||||||
# 放自己的秘密如API和代理网址
|
|
||||||
from config_private import proxies
|
|
||||||
else:
|
|
||||||
from config import proxies
|
|
||||||
check_proxy(proxies)
|
check_proxy(proxies)
|
4
main.py
4
main.py
@ -3,7 +3,9 @@ import os
|
|||||||
import markdown, mdtex2html
|
import markdown, mdtex2html
|
||||||
from predict import predict
|
from predict import predict
|
||||||
from show_math import convert as convert_math
|
from show_math import convert as convert_math
|
||||||
from config import proxies, WEB_PORT
|
|
||||||
|
try: from config_private import proxies, WEB_PORT # 放自己的秘密如API和代理网址 os.path.exists('config_private.py')
|
||||||
|
except: from config import proxies, WEB_PORT
|
||||||
|
|
||||||
def find_free_port():
|
def find_free_port():
|
||||||
import socket
|
import socket
|
||||||
|
18
predict.py
18
predict.py
@ -4,24 +4,12 @@ import logging
|
|||||||
import traceback
|
import traceback
|
||||||
import requests
|
import requests
|
||||||
import importlib
|
import importlib
|
||||||
import os
|
|
||||||
|
|
||||||
if os.path.exists('config_private.py'):
|
try: from config_private import proxies, API_URL, API_KEY, TIMEOUT_SECONDS # 放自己的秘密如API和代理网址 os.path.exists('config_private.py')
|
||||||
# 放自己的秘密如API和代理网址
|
except: from config import proxies, API_URL, API_KEY, TIMEOUT_SECONDS
|
||||||
from config_private import proxies, API_URL, API_KEY, TIMEOUT_SECONDS
|
|
||||||
else:
|
|
||||||
from config import proxies, API_URL, API_KEY, TIMEOUT_SECONDS
|
|
||||||
|
|
||||||
timeout_bot_msg = 'Request timeout, network error. please check proxy settings in config.py.'
|
timeout_bot_msg = 'Request timeout, network error. please check proxy settings in config.py.'
|
||||||
|
|
||||||
def compose_system(system_prompt):
|
|
||||||
return {"role": "system", "content": system_prompt}
|
|
||||||
|
|
||||||
|
|
||||||
def compose_user(user_input):
|
|
||||||
return {"role": "user", "content": user_input}
|
|
||||||
|
|
||||||
|
|
||||||
def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt='', retry=False,
|
def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt='', retry=False,
|
||||||
stream = True, additional_fn=None):
|
stream = True, additional_fn=None):
|
||||||
|
|
||||||
@ -46,7 +34,7 @@ def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt=''
|
|||||||
|
|
||||||
print(f"chat_counter - {chat_counter}")
|
print(f"chat_counter - {chat_counter}")
|
||||||
|
|
||||||
messages = [compose_system(system_prompt)]
|
messages = [{"role": "system", "content": system_prompt}]
|
||||||
if chat_counter:
|
if chat_counter:
|
||||||
for index in range(0, 2*chat_counter, 2):
|
for index in range(0, 2*chat_counter, 2):
|
||||||
what_i_have_asked = {}
|
what_i_have_asked = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user