Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,28 +35,31 @@ routes.get_types = get_types
|
|
| 35 |
q = queue.Queue()
|
| 36 |
|
| 37 |
def chat():
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
result_list = str(datetime.timedelta(seconds=sec)).split(".")
|
| 56 |
-
print("μλ΅ μκ° : " + result_list[0] +"\nx:"+ arr[0] +"\nid:"+ arr[1] +"\ncdata:" + arr[2] +"\nresult:"+ result + "\ncollback_url : " + arr[3])
|
| 57 |
-
return result
|
| 58 |
|
| 59 |
th_a = Thread(target = chat)
|
|
|
|
| 60 |
th_a.start()
|
| 61 |
|
| 62 |
# App code
|
|
|
|
| 35 |
q = queue.Queue()
|
| 36 |
|
| 37 |
def chat():
|
| 38 |
+
while True:
|
| 39 |
+
time.sleep(1)
|
| 40 |
+
global q
|
| 41 |
+
if not q.empty():
|
| 42 |
+
arr = q.get()
|
| 43 |
+
start = time.time()
|
| 44 |
+
result = gradio_client.predict(
|
| 45 |
+
arr[0],
|
| 46 |
+
# str representing input in 'User input' Textbox component
|
| 47 |
+
arr[1],
|
| 48 |
+
arr[2],
|
| 49 |
+
fn_index=0
|
| 50 |
+
)
|
| 51 |
+
result = str(result)
|
| 52 |
+
|
| 53 |
+
end = time.time()
|
| 54 |
+
|
| 55 |
|
| 56 |
+
sec = (end - start)
|
| 57 |
+
result_list = str(datetime.timedelta(seconds=sec)).split(".")
|
| 58 |
+
print("μλ΅ μκ° : " + result_list[0] +"\nx:"+ arr[0] +"\nid:"+ arr[1] +"\ncdata:" + arr[2] +"\nresult:"+ result + "\ncollback_url : " + arr[3])
|
| 59 |
+
return result
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
th_a = Thread(target = chat)
|
| 62 |
+
th_a.daemon = True
|
| 63 |
th_a.start()
|
| 64 |
|
| 65 |
# App code
|