ldhldh commited on
Commit
06f7edb
โ€ข
1 Parent(s): 6dabdb1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -9
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['id']
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['id']
 
 
 
 
 
 
 
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/predict_5",
131
  )
132
 
133
  nnp = gr.Interface(
134
  fn=get_p,
135
  inputs=["text"],
136
  outputs="text",
137
- description="get_p, /run/predict_6",
 
 
 
 
 
 
 
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)