ldhldh commited on
Commit
31c04e7
Β·
1 Parent(s): 7a95186

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -42
app.py CHANGED
@@ -1,6 +1,5 @@
1
  from threading import Thread
2
  import gradio as gr
3
- from gradio_client import Client as GrClient
4
  import inspect
5
  from gradio import routes
6
  from typing import List, Type
@@ -35,46 +34,6 @@ routes.get_types = get_types
35
 
36
  q = queue.Queue()
37
 
38
- def chat():
39
- while True:
40
- time.sleep(1)
41
- global q
42
- if not q.empty():
43
- arr = q.get()
44
- start = time.time()
45
- print("응닡 μ‹œμž‘\nx:"+ arr[0] +"\nid:"+ arr[1] +"\ncdata:" + arr[2] + "\ncollback_url : " + arr[3])
46
- result = gradio_client.predict(
47
- arr[0],
48
- # str representing input in 'User input' Textbox component
49
- arr[1],
50
- arr[2],
51
- fn_index=0
52
- )
53
-
54
- end = time.time()
55
-
56
-
57
- sec = (end - start)
58
- result_list = str(datetime.timedelta(seconds=sec)).split(".")
59
- print("응닡 μ‹œκ°„ : " + result_list[0] +"\nresult:"+ result)
60
-
61
- if result.split(":")[0]=="상담원":
62
- result = result.split(":")[1]
63
-
64
- headers = {'Content-Type': 'application/json'}
65
- body = {
66
- "url" : arr[3],
67
- "data" : result
68
- }
69
-
70
- if arr[3] != "Asia/Seoul":
71
- response_collback = requests.post("https://9174963504.for-seoul.synctreengine.com/call", headers=headers, data=json.dumps(body))
72
- print(response_collback)
73
-
74
- th_a = Thread(target = chat)
75
- th_a.daemon = True
76
- th_a.start()
77
-
78
  # App code
79
  def res(x, id, cdata, url):
80
  global q
@@ -91,6 +50,6 @@ with gr.Blocks() as demo:
91
  fn=res,
92
  inputs=["text","text", "text", "text"],
93
  outputs="text",
94
- description="chat",
95
  )
96
  demo.queue(max_size=32).launch(enable_queue=True)
 
1
  from threading import Thread
2
  import gradio as gr
 
3
  import inspect
4
  from gradio import routes
5
  from typing import List, Type
 
34
 
35
  q = queue.Queue()
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  # App code
38
  def res(x, id, cdata, url):
39
  global q
 
50
  fn=res,
51
  inputs=["text","text", "text", "text"],
52
  outputs="text",
53
+ description="call",
54
  )
55
  demo.queue(max_size=32).launch(enable_queue=True)