Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,6 @@ import math
|
|
9 |
import time
|
10 |
import datetime
|
11 |
|
12 |
-
|
13 |
loop = asyncio.get_event_loop()
|
14 |
gradio_client = GrClient(os.environ.get('GrClient_url'))
|
15 |
# Monkey patch
|
@@ -31,32 +30,63 @@ def get_types(cls_set: List[Type], component: str):
|
|
31 |
return docset, types
|
32 |
routes.get_types = get_types
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
print()
|
52 |
-
print("์๋ต ์๊ฐ : " + result_list[0] +"\nx:"+ x +"\nid:"+ id +"\ncdata:" + cdata +"\nresult:"+ result)
|
53 |
-
return result
|
54 |
|
55 |
with gr.Blocks() as demo:
|
56 |
count = 0
|
57 |
aa = gr.Interface(
|
58 |
fn=chat,
|
59 |
-
inputs=["text","text", "text"],
|
60 |
outputs="text",
|
61 |
description="chat",
|
62 |
)
|
|
|
9 |
import time
|
10 |
import datetime
|
11 |
|
|
|
12 |
loop = asyncio.get_event_loop()
|
13 |
gradio_client = GrClient(os.environ.get('GrClient_url'))
|
14 |
# Monkey patch
|
|
|
30 |
return docset, types
|
31 |
routes.get_types = get_types
|
32 |
|
33 |
+
_x = ""
|
34 |
+
_id = ""
|
35 |
+
_cdata = ""
|
36 |
+
_url = ""
|
37 |
+
_do = False
|
38 |
+
|
39 |
+
def chat():
|
40 |
+
global _do
|
41 |
+
global _x
|
42 |
+
global _id
|
43 |
+
global _cdata
|
44 |
+
if _do:
|
45 |
+
_do = False
|
46 |
+
start = time.time()
|
47 |
+
result = gradio_client.predict(
|
48 |
+
_x,
|
49 |
+
# str representing input in 'User input' Textbox component
|
50 |
+
_id,
|
51 |
+
_cdata,
|
52 |
+
fn_index=0
|
53 |
+
)
|
54 |
+
result = str(result)
|
55 |
+
|
56 |
+
end = time.time()
|
57 |
|
58 |
+
|
59 |
+
sec = (end - start)
|
60 |
+
result_list = str(datetime.timedelta(seconds=sec)).split(".")
|
61 |
+
print("์๋ต ์๊ฐ : " + result_list[0] +"\nx:"+ x +"\nid:"+ id +"\ncdata:" + cdata +"\nresult:"+ result)
|
62 |
+
return result
|
63 |
+
|
64 |
+
th_a = Thread(target = chat)
|
65 |
+
th_a.daemon = True
|
66 |
+
th_a.start()
|
67 |
+
|
68 |
+
# App code
|
69 |
+
def res(x, id, cdata, url):
|
70 |
+
global _do
|
71 |
+
global _x
|
72 |
+
global _id
|
73 |
+
global _cdata
|
74 |
+
global _url
|
75 |
|
76 |
+
_x = x
|
77 |
+
_id = id
|
78 |
+
_cdata = cdata
|
79 |
+
_url = url
|
80 |
+
_do = True
|
81 |
|
82 |
+
print("\n_Done\n\n")
|
83 |
+
return "Done"
|
|
|
|
|
|
|
84 |
|
85 |
with gr.Blocks() as demo:
|
86 |
count = 0
|
87 |
aa = gr.Interface(
|
88 |
fn=chat,
|
89 |
+
inputs=["text","text", "text", "text"],
|
90 |
outputs="text",
|
91 |
description="chat",
|
92 |
)
|