mohbay commited on
Commit
0430419
·
verified ·
1 Parent(s): 6d37b4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -76,14 +76,26 @@ def search_fatwa(data):
76
  query_embedding = model.encode(query, convert_to_tensor=True)
77
  top_idx = int(util.pytorch_cos_sim(query_embedding, embeddings)[0].argmax())
78
  top_idx2 = int(util.pytorch_cos_sim(query_embedding, embeddings2)[0].argmax())
79
- return {
80
- "question1": df.iloc[top_idx]["question"],
81
- "link1": df.iloc[top_idx]["link"],
82
- "question2": df2.iloc[top_idx2]["question"],
83
- "link2": df2.iloc[top_idx2]["link"]
84
- }
85
-
86
- iface = gr.Interface(fn=search_fatwa, inputs=[gr.Textbox(label="text", lines=3)], outputs="json")
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
 
89
 
 
76
  query_embedding = model.encode(query, convert_to_tensor=True)
77
  top_idx = int(util.pytorch_cos_sim(query_embedding, embeddings)[0].argmax())
78
  top_idx2 = int(util.pytorch_cos_sim(query_embedding, embeddings2)[0].argmax())
79
+ # return {
80
+ # "question1": df.iloc[top_idx]["question"],
81
+ # "link1": df.iloc[top_idx]["link"],
82
+ # "question2": df2.iloc[top_idx2]["question"],
83
+ # "link2": df2.iloc[top_idx2]["link"]
84
+ # }
85
+ result = f"""Question 1: {df.iloc[top_idx]["question"]}
86
+ Link 1: {df.iloc[top_idx]["link"]}
87
+
88
+ Question 2: {df2.iloc[top_idx2]["question"]}
89
+ Link 2: {df2.iloc[top_idx2]["link"]}"""
90
+ return result
91
+
92
+ iface = gr.Interface(
93
+ fn=search_fatwa,
94
+ inputs=[gr.Textbox(label="text", lines=3)],
95
+ outputs="text" # Changed from "json" to "text"
96
+ )
97
+
98
+ # iface = gr.Interface(fn=search_fatwa, inputs=[gr.Textbox(label="text", lines=3)], outputs="json")
99
 
100
 
101