Spaces:
Sleeping
Sleeping
Update app.py
Browse files8 unmodified lines910111213141515 unmodified lines31323334353637383940414243444546474849505152535455565758596061628 unmodified linesimport timeimport datetimeloop = asyncio.get_event_loop()gradio_client = GrClient(os.environ.get('GrClient_url'))# Monkey patch15 unmodified linesreturn docset, typesroutes.get_types = get_types# App codedef chat(x, id, cdata):start = time.time()result = gradio_client.predict(x,# str representing input in 'User input' Textbox componentid,cdata,fn_index=0)result = str(result)end = time.time()sec = (end - start)result_list = str(datetime.timedelta(seconds=sec)).split(".")print()print("응답 시간 : " + result_list[0] +"\nx:"+ x +"\nid:"+ id +"\ncdata:" + cdata +"\nresult:"+ result)return resultwith gr.Blocks() as demo:count = 0aa = gr.Interface(fn=chat,inputs=["text","text", "text"],outputs="text",description="chat",)8 unmodified lines9101112131415 unmodified lines3031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091928 unmodified linesimport timeimport datetimeloop = asyncio.get_event_loop()gradio_client = GrClient(os.environ.get('GrClient_url'))# Monkey patch15 unmodified linesreturn docset, typesroutes.get_types = get_types_x = ""_id = ""_cdata = ""_url = ""_do = Falsedef chat():global _doglobal _xglobal _idglobal _cdataif _do:_do = Falsestart = time.time()result = gradio_client.predict(_x,# str representing input in 'User input' Textbox component_id,_cdata,fn_index=0)result = str(result)end = time.time()sec = (end - start)result_list = str(datetime.timedelta(seconds=sec)).split(".")print("응답 시간 : " + result_list[0] +"\nx:"+ x +"\nid:"+ id +"\ncdata:" + cdata +"\nresult:"+ result)return resultth_a = Thread(target = chat)th_a.daemon = Trueth_a.start()# App codedef res(x, id, cdata, url):global _doglobal _xglobal _idglobal _cdataglobal _url_x = x_id = id_cdata = cdata_url = url_do = Trueprint("\n_Done\n\n")return "Done"with gr.Blocks() as demo:count = 0aa = gr.Interface(fn=chat,inputs=["text","text", "text", "text"],outputs="text",description="chat",)
app.py+49-19