Spaces:
Sleeping
Sleeping
Update app.py
Browse files8 unmodified lines910111212131415 unmodified lines3031323334353637383940414243343536373839404142434444454647484950515253545556574658596061626364656667686970717273747576777879808149505152538283848586878859899091928 unmodified linesimport timeimport datetime
loop = asyncio.get_event_loop()gradio_client = GrClient(os.environ.get('GrClient_url'))# Monkey patch15 unmodified lines return docset, typesroutes.get_types = get_types
_x = ""_id = ""_cdata = ""_url = ""_do = False
def chat(): global _do global _x global _id global _cdata# App codedef chat(x, id, cdata): start = time.time() result = gradio_client.predict( x, # str representing input in 'User input' Textbox component id, cdata, fn_index=0 ) result = str(result) if _do: _do = False start = 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() 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 result
th_a = Thread(target = chat)th_a.daemon = Trueth_a.start()
# App codedef res(x, id, cdata, url): global _do global _x global _id global _cdata global _url
_x = x _id = id _cdata = cdata _url = url _do = True
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 result print("\n_Done\n\n") return "Done"
with gr.Blocks() as demo: count = 0 aa = gr.Interface( fn=chat, inputs=["text","text", "text"], inputs=["text","text", "text", "text"], outputs="text", description="chat", )app.py+49-19