svarshney25 commited on
Commit
9dd9b8e
·
verified ·
1 Parent(s): a125ba7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,8 +4,8 @@ import torch
4
  import gradio as gr
5
  from huggingface_hub import InferenceClient
6
 
7
- with open("travel_knowledge_base.txt", "r", encoding="utf-8") as file:
8
- travel_text = file.read()
9
 
10
  def preprocess_text(text):
11
  cleaned_text = text.strip()
@@ -17,7 +17,7 @@ def preprocess_text(text):
17
  cleaned_chunks.append(chunk)
18
  return cleaned_chunks
19
 
20
- cleaned_chunks = preprocess_text(travel_text)
21
 
22
 
23
  model = SentenceTransformer('all-MiniLM-L6-v2')
@@ -44,7 +44,7 @@ client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
44
  def respond(message, history):
45
  top_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
46
  context = "\n\n".join(top_chunks)
47
- messages = [{"role": "system", "content": f"You are a travel advisor. Cover flights, hotels, food, and itineraries. If the user is just greeting you, greet them back and ask where they want to travel. \n{context}"}]
48
  for turn in history:
49
  if turn["role"] == "user":
50
  messages.append({"role": "user", "content": turn["content"]})
 
4
  import gradio as gr
5
  from huggingface_hub import InferenceClient
6
 
7
+ with open("hindu_yuva_knowledge_base.txt", "r", encoding="utf-8") as file:
8
+ yuva_knowledge = file.read()
9
 
10
  def preprocess_text(text):
11
  cleaned_text = text.strip()
 
17
  cleaned_chunks.append(chunk)
18
  return cleaned_chunks
19
 
20
+ cleaned_chunks = preprocess_text(yuva_knowledge)
21
 
22
 
23
  model = SentenceTransformer('all-MiniLM-L6-v2')
 
44
  def respond(message, history):
45
  top_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
46
  context = "\n\n".join(top_chunks)
47
+ messages = [{"role": "system", "content": f"Always greet the user first by asking 'Hello, how can I help you?'. You are an assistant answering users' questions about Hindu YUVA. You just need to pull information from the website to answer basic questions. \n{context}"}]
48
  for turn in history:
49
  if turn["role"] == "user":
50
  messages.append({"role": "user", "content": turn["content"]})