madoss commited on
Commit
704ef0e
·
1 Parent(s): d69bc63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -8
app.py CHANGED
@@ -13,7 +13,7 @@ model = sentence_transformers.SentenceTransformer(
13
  dataset = datasets.load_dataset("json", data_files=["./dataset.json"], split="train")
14
  dataset.load_faiss_index("embeddings", "index.faiss")
15
 
16
- def search(query, k):
17
  query_embedding = model.encode(query)
18
  _, retrieved_examples = dataset.get_nearest_examples(
19
  "embeddings",
@@ -38,21 +38,54 @@ def search(query, k):
38
  results.append(result)
39
  return results
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  iface = gr.Interface(
42
- search,
43
  inputs=[
44
- gr.inputs.Textbox(label="Query"),
45
- gr.inputs.Number(label="K", default=3),
 
 
 
 
 
 
46
  ],
47
  outputs=[
48
- gr.outputs.Textbox(label="Title"),
49
- gr.outputs.Textbox(label="Transcript"),
50
- gr.outputs.Textbox(label="Link"),
 
 
 
 
 
 
51
  ],
52
  title="Camembert and Faiss-powered Search Engine",
53
  description="Search through a dataset using Camembert and Faiss",
54
- theme="light",
55
  layout="vertical",
 
 
 
 
 
56
  )
57
 
58
  iface.launch()
 
13
  dataset = datasets.load_dataset("json", data_files=["./dataset.json"], split="train")
14
  dataset.load_faiss_index("embeddings", "index.faiss")
15
 
16
+ def search(query, k=3):
17
  query_embedding = model.encode(query)
18
  _, retrieved_examples = dataset.get_nearest_examples(
19
  "embeddings",
 
38
  results.append(result)
39
  return results
40
 
41
+ # Add custom styles to the interface
42
+ styles = gr.Styles(
43
+ button_color="white",
44
+ label_font="Arial",
45
+ label_font_size=18,
46
+ label_color="black",
47
+ input_font="Arial",
48
+ input_font_size=18,
49
+ input_color="black",
50
+ output_font="Arial",
51
+ output_font_size=18,
52
+ output_color="black",
53
+ full_width=True,
54
+ background="#f2f2f2",
55
+ )
56
+
57
  iface = gr.Interface(
58
+ fn=search,
59
  inputs=[
60
+ gr.inputs.Textbox(
61
+ label="Query", placeholder="Type in a search query...", lines=3
62
+ ),
63
+ gr.inputs.Number(
64
+ label="K",
65
+ default=3,
66
+ description="Number of results to return",
67
+ ),
68
  ],
69
  outputs=[
70
+ gr.outputs.Label(
71
+ label="Result 1", type="auto", default="Search results will appear here."
72
+ ),
73
+ gr.outputs.Label(
74
+ label="Result 2", type="auto", default=""
75
+ ),
76
+ gr.outputs.Link(
77
+ label="Result 3", type="auto", default=""
78
+ ),
79
  ],
80
  title="Camembert and Faiss-powered Search Engine",
81
  description="Search through a dataset using Camembert and Faiss",
82
+ theme="default",
83
  layout="vertical",
84
+ allow_flagging=False,
85
+ allow_screenshot=False,
86
+ allow_share=True,
87
+ allow_download=False,
88
+ style=styles,
89
  )
90
 
91
  iface.launch()