From f94cbe79239858008a5d8c595bf6b430b64c0a86 Mon Sep 17 00:00:00 2001 From: w_xiaolizu Date: Thu, 18 May 2023 20:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E7=AB=AF=E5=8F=A3=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 0 bytes .__test.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 12 ++++------- __main__.py | 23 ++++++++++++--------- 4 files changed, 75 insertions(+), 17 deletions(-) delete mode 100644 .DS_Store create mode 100644 .__test.py diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 840f8fcc743009882fedee2c4134ac4a69b4221b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!Ac`R5Uq|`Gr?WRLBV5#*MQNe5cV=e{ehiD536KnNQi^ubjVCLhY*;v{?LBO zevhxZ+n{8mRJ}@d)lBMj=uQ!l>d%G;L@go;pp3O9%wL4pS=XfIBO5?vpE0Hh zmA|5Co|(053A{%Jc<&k%(~L?o^lbm~F;=jv^cj0P#o8V3Ee()a&Ygl@&0uG5 z|LeEGZFZNNdwe&D;yzfuI9S;Sc(3;7e#a{wRz>0n1HynX@ZlNor(&@6;X9EAgaKjT zUo*hxgN8DO9xI3T=zy^!0I-g*75F?$aE我是Bolcks") + with gr.Row(): + with gr.Column(scale=100): # 组件绘制在布局元素下,则会根据布局元素的规定展示 + gr.Markdown('# 这里是列1') + chatbot = gr.Chatbot().style(height=400) + status = gr.Markdown() + + with gr.Column(scale=50): + gr.Markdown('# 这里是列2') + i_say = gr.Textbox() + submit = gr.Button(value='submit', variant='primary') + with gr.Row(): + you_say = gr.Textbox(show_label=False, placeholder='没有任何用的输出框') + Noo = gr.Button(value='没有任何用的按钮') + + + def respond(say, chat_history): + import random + bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"]) + chat_history.append((say, bot_message)) + return "我要开始胡说了", chat_history + + # 注册函数 fn=要注册的函数, input=函数接收的参数, outputs=函数处理后返回接收的组件 + submit.click(fn=respond, inputs=[i_say, chatbot], outputs=[status, chatbot]) + +demo.launch() + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index 34af516..17cceb4 100644 --- a/.gitignore +++ b/.gitignore @@ -111,7 +111,8 @@ env/ venv/ ENV/ env.bak/ -venv.bak/ +venv.bak/ +.DS_Store # Spyder project settings .spyderproject @@ -127,13 +128,10 @@ venv.bak/ .mypy_cache/ .dmypy.json dmypy.json - # Pyre type checker .pyre/ - .vscode .idea - history ssr_conf config_private.py @@ -148,7 +146,5 @@ crazy_functions/test_project/pdf_and_word crazy_fun ctions/test_samples crazy_functions/test_samples -request_llm/jittorllms -!prompt_users/.keep -prompt_users/* -.__test.py +request_llm/jittorllms +prompt_users/* \ No newline at end of file diff --git a/__main__.py b/__main__.py index 03668af..4ed02e7 100644 --- a/__main__.py +++ b/__main__.py @@ -342,14 +342,6 @@ class ChatBot(ChatBotFrame): threading.Thread(target=auto_update, name="self-upgrade", daemon=True).start() # threading.Thread(target=warm_up_modules, name="warm-up", daemon=True).start() - def check_proxy_free(self): - proxy_state = func_box.Shell(f'lsof -i :{PORT}').read()[1].splitlines() - if proxy_state != ["", ""]: - print('Kill Old Server') - for i in proxy_state[1:]: - func_box.Shell(f'kill -9 {i.split()[1]}').read() - import time - time.sleep(5) def main(self): with gr.Blocks(title="Chatbot for KSO ", theme=set_theme, analytics_enabled=False, css=advanced_css) as demo: @@ -391,9 +383,22 @@ class ChatBot(ChatBotFrame): # Start self.auto_opentab_delay() demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=PORT, - auth=AUTHENTICATION) + auth=AUTHENTICATION) +def check_proxy_free(): + proxy_state = func_box.Shell(f'lsof -i :{PORT}').read()[1].splitlines() + if proxy_state != ["", ""]: + print('Kill Old Server') + for i in proxy_state[1:]: + func_box.Shell(f'kill -9 {i.split()[1]}').read() + import time + time.sleep(5) if __name__ == '__main__': + # PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT + PORT = 7891 if WEB_PORT <= 0 else WEB_PORT + check_proxy_free() ChatBot().main() + gr.close_all() + check_proxy_free()