Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -72,17 +72,31 @@ def add_name(id, name):
|
|
72 |
|
73 |
def get_name(id):
|
74 |
if id in name_list:
|
75 |
-
return name_list[
|
76 |
else:
|
77 |
return "no id"
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
def add_p(id, p_id):
|
80 |
p2p_list[id] = p_id
|
81 |
return "ok"
|
82 |
|
83 |
def get_p(id):
|
84 |
if id in p2p_list:
|
85 |
-
return p2p_list[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
else:
|
87 |
return "no id"
|
88 |
|
@@ -92,49 +106,63 @@ with gr.Blocks() as demo:
|
|
92 |
fn=chat,
|
93 |
inputs=["text"],
|
94 |
outputs="text",
|
95 |
-
description="chat, /run/predict",
|
96 |
)
|
97 |
|
98 |
rr = gr.Interface(
|
99 |
fn=register,
|
100 |
inputs=["text", "text"],
|
101 |
outputs="text",
|
102 |
-
description="register, /run/predict_1",
|
103 |
)
|
104 |
|
105 |
ll = gr.Interface(
|
106 |
fn=login,
|
107 |
inputs=["text", "text"],
|
108 |
outputs="text",
|
109 |
-
description="login, /run/predict_2",
|
110 |
)
|
111 |
|
112 |
ad = gr.Interface(
|
113 |
fn=add_name,
|
114 |
inputs=["text", "text"],
|
115 |
outputs="text",
|
116 |
-
description="add_name, /run/predict_3",
|
117 |
)
|
118 |
|
119 |
nn = gr.Interface(
|
120 |
fn=get_name,
|
121 |
inputs=["text"],
|
122 |
outputs="text",
|
123 |
-
description="get_name, /run/predict_4",
|
124 |
)
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
adp = gr.Interface(
|
127 |
fn=add_p,
|
128 |
inputs=["text", "text"],
|
129 |
outputs="text",
|
130 |
-
description="add_p, /run/
|
131 |
)
|
132 |
|
133 |
nnp = gr.Interface(
|
134 |
fn=get_p,
|
135 |
inputs=["text"],
|
136 |
outputs="text",
|
137 |
-
description="get_p, /run/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
)
|
139 |
|
140 |
demo.queue(max_size=32).launch(enable_queue=True)
|
|
|
72 |
|
73 |
def get_name(id):
|
74 |
if id in name_list:
|
75 |
+
return name_list[id]
|
76 |
else:
|
77 |
return "no id"
|
78 |
|
79 |
+
def get_id(name):
|
80 |
+
reverse_dict= dict(map(reversed,name_list.items()))
|
81 |
+
if name in reverse_dict:
|
82 |
+
return reverse_dict[name]
|
83 |
+
else:
|
84 |
+
return "no name"
|
85 |
+
|
86 |
def add_p(id, p_id):
|
87 |
p2p_list[id] = p_id
|
88 |
return "ok"
|
89 |
|
90 |
def get_p(id):
|
91 |
if id in p2p_list:
|
92 |
+
return p2p_list[id]
|
93 |
+
else:
|
94 |
+
return "no id"
|
95 |
+
|
96 |
+
def get_id_from_p2p(i):
|
97 |
+
reverse_dict= dict(map(reversed,p2p_list.items()))
|
98 |
+
if id in p2p_list:
|
99 |
+
return reverse_dict[id]
|
100 |
else:
|
101 |
return "no id"
|
102 |
|
|
|
106 |
fn=chat,
|
107 |
inputs=["text"],
|
108 |
outputs="text",
|
109 |
+
description="chat, ai ์๋ต์ ๋ฐํํฉ๋๋ค.\n /run/predict",
|
110 |
)
|
111 |
|
112 |
rr = gr.Interface(
|
113 |
fn=register,
|
114 |
inputs=["text", "text"],
|
115 |
outputs="text",
|
116 |
+
description="register, ํ์๊ฐ์
(์ฑ๊ณต์:ok, ์ค๋ณต์:exist ๋ฐํ)\n /run/predict_1",
|
117 |
)
|
118 |
|
119 |
ll = gr.Interface(
|
120 |
fn=login,
|
121 |
inputs=["text", "text"],
|
122 |
outputs="text",
|
123 |
+
description="login, ๋ก๊ทธ์ธ(์ฑ๊ณต์: ok, ์คํจ์: password error, ์์ด๋๊ฐ ์์ผ๋ฉด: no id) \n /run/predict_2",
|
124 |
)
|
125 |
|
126 |
ad = gr.Interface(
|
127 |
fn=add_name,
|
128 |
inputs=["text", "text"],
|
129 |
outputs="text",
|
130 |
+
description="add_name, id๋ก ๋๋ค์ ์ถ๊ฐ. ok ๋ฐํ.\n /run/predict_3",
|
131 |
)
|
132 |
|
133 |
nn = gr.Interface(
|
134 |
fn=get_name,
|
135 |
inputs=["text"],
|
136 |
outputs="text",
|
137 |
+
description="get_name, id๋ก ๋๋ค์ ๋ฐํ(์์ผ๋ฉด no id)\n /run/predict_4",
|
138 |
)
|
139 |
|
140 |
+
nnn = gr.Interface(
|
141 |
+
fn=get_id,
|
142 |
+
inputs=["text"],
|
143 |
+
outputs="text",
|
144 |
+
description="get_name, ๋๋ค์์ผ๋ก id ๋ฐํ(์์ผ๋ฉด no name)\n /run/predict_5",
|
145 |
+
)
|
146 |
+
|
147 |
adp = gr.Interface(
|
148 |
fn=add_p,
|
149 |
inputs=["text", "text"],
|
150 |
outputs="text",
|
151 |
+
description="add_p, id๋ก p2p id ์ถ๊ฐ. ok ๋ฐํ. \n /run/predict_6",
|
152 |
)
|
153 |
|
154 |
nnp = gr.Interface(
|
155 |
fn=get_p,
|
156 |
inputs=["text"],
|
157 |
outputs="text",
|
158 |
+
description="get_p, id๋ก p2p id ๋ฐํ. ์์ผ๋ฉด no id. \n /run/predict_7",
|
159 |
+
)
|
160 |
+
|
161 |
+
nnp = gr.Interface(
|
162 |
+
fn=get_id_from_p2p,
|
163 |
+
inputs=["text"],
|
164 |
+
outputs="text",
|
165 |
+
description="get_p, p2p id๋ก ์ผ๋ฐ id ๋ฐํ. ์์ผ๋ฉด no id. \n /run/predict_8",
|
166 |
)
|
167 |
|
168 |
demo.queue(max_size=32).launch(enable_queue=True)
|