dschandra commited on
Commit
6be3cee
·
verified ·
1 Parent(s): d06bdd1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ from sentence_transformers import SentenceTransformer, util
4
+
5
+ # Load FAQs
6
+ faq_df = pd.read_csv("lic_faq.csv")
7
+ model = SentenceTransformer('all-MiniLM-L6-v2')
8
+ faq_embeddings = model.encode(faq_df['question'].tolist(), convert_to_tensor=True)
9
+
10
+ def chatbot(query):
11
+ query_embedding = model.encode(query, convert_to_tensor=True)
12
+ scores = util.pytorch_cos_sim(query_embedding, faq_embeddings)[0]
13
+ best_idx = scores.argmax()
14
+ return faq_df.iloc[best_idx]['answer']
15
+
16
+ iface = gr.Interface(fn=chatbot, inputs="text", outputs="text",
17
+ title="LIC Agent Assistant",
18
+ description="Ask about LIC claims, policies, onboarding, etc.")
19
+ iface.launch()