File size: 697 Bytes
17283b0
aa7bf0f
17283b0
a6bf372
 
576fbe3
a50b133
17283b0
 
 
 
 
 
 
f83222b
 
 
17283b0
 
 
 
f83222b
238e381
656c99e
a6bf372
17283b0
db373f8
17283b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
import pandas as pd
from retrieval import *
import os


hf_writer = gr.HuggingFaceDatasetSaver('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', "Pavankalyan/chitti_data")

df = pd.read_csv("Responses.csv")
text = list(df["text"].values)


def chitti(query):
    re_table = search(query, text)
    with open(query[0:5]+'.txt', 'w') as f:
        f.writelines(["Question: "+query,"Ans 1 : "+ re_table[0][0],"Ans 2 : "+ re_table[1][0]])
    return [re_table[0][0],re_table[1][0]]

demo = gr.Interface(
    fn=chitti,
    inputs=["text"],
    outputs=["text","text"],
    allow_flagging = "manual",
    flagging_options = ["0","1","None"],
    flagging_callback=hf_writer
)
demo.launch()