mohbay commited on
Commit
eacf3db
·
verified ·
1 Parent(s): 9e4540a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -129,20 +129,27 @@ def predict(text):
129
  top_idx = int(util.pytorch_cos_sim(query_embedding, embeddings)[0].argmax())
130
  top_idx2 = int(util.pytorch_cos_sim(query_embedding, embeddings2)[0].argmax())
131
 
132
- result = f"""Question 1: {df.iloc[top_idx]["question"]}
133
- Link 1: {df.iloc[top_idx]["link"]}
134
 
135
- Question 2: {df2.iloc[top_idx2]["question"]}
136
- Link 2: {df2.iloc[top_idx2]["link"]}"""
 
 
137
 
138
- return result
 
 
 
 
 
139
 
140
  # Match the EXACT structure of your working translation app
141
  title = "Search CSV"
142
  iface = gr.Interface(
143
  fn=predict, # Changed from search_fatwa to predict
144
  inputs=[gr.Textbox(label="text", lines=3)],
145
- outputs='text',
146
  title=title,
147
  )
148
  iface.launch()
 
129
  top_idx = int(util.pytorch_cos_sim(query_embedding, embeddings)[0].argmax())
130
  top_idx2 = int(util.pytorch_cos_sim(query_embedding, embeddings2)[0].argmax())
131
 
132
+ # result = f"""Question 1: {df.iloc[top_idx]["question"]}
133
+ # Link 1: {df.iloc[top_idx]["link"]}
134
 
135
+ # Question 2: {df2.iloc[top_idx2]["question"]}
136
+ # Link 2: {df2.iloc[top_idx2]["link"]}"""
137
+
138
+ # return result
139
 
140
+ return {
141
+ "question1": df.iloc[top_idx]["question"],
142
+ "link1": df.iloc[top_idx]["link"],
143
+ "question2": df2.iloc[top_idx2]["question"],
144
+ "link2": df2.iloc[top_idx2]["link"]
145
+ }
146
 
147
  # Match the EXACT structure of your working translation app
148
  title = "Search CSV"
149
  iface = gr.Interface(
150
  fn=predict, # Changed from search_fatwa to predict
151
  inputs=[gr.Textbox(label="text", lines=3)],
152
+ outputs='json',
153
  title=title,
154
  )
155
  iface.launch()