npc0 commited on
Commit
b83f839
1 Parent(s): 2069ee0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -14,13 +14,25 @@ class User:
14
  self.phone = phone
15
  self.features = features
16
  def create(self):
17
- vector_store.add_texts([f'#features\n{self.features}\n\n#phone\n{self.phone}')
18
  def search(self):
19
  return vector_store.similarity_search(self.features, k=1)
20
 
21
- def greet(name):
22
- return "Hello " + name + "!!"
 
 
 
 
23
 
24
  demo = gr.Interface(fn=greet, inputs=["textbox", "button"], outputs="text")
 
 
 
 
 
 
 
 
25
  # demo.launch()
26
- demo.launch(share=True, auth=("username", "password"))
 
14
  self.phone = phone
15
  self.features = features
16
  def create(self):
17
+ vector_store.add_texts([f'#features\n{self.features}\n\n#phone\n{self.phone}'])
18
  def search(self):
19
  return vector_store.similarity_search(self.features, k=1)
20
 
21
+ def greet(a, b, c):
22
+ u = User(a, b)
23
+ if c:
24
+ return u.search()
25
+ u.create()
26
+ return 1
27
 
28
  demo = gr.Interface(fn=greet, inputs=["textbox", "button"], outputs="text")
29
+ with gr.Blocks():
30
+ p = gr.Textbox()
31
+ f = gr.Textbox()
32
+ n = gr.Textbox()
33
+ btn = gr.Button(value="insert")
34
+ btn.click(greet, inputs=[p, f, 0], outputs=[n])
35
+ btn = gr.Button(value="query")
36
+ btn.click(greet, inputs=[p, f, 1], outputs=[n])
37
  # demo.launch()
38
+ demo.launch(auth=("username", "password"))