pradeepsengarr commited on
Commit
948c6d1
·
verified ·
1 Parent(s): 2e4b538

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -50,7 +50,7 @@ def process_answer(question, full_text):
50
  docs = loader.load()
51
 
52
  # Chunk the documents with increased size and overlap
53
- text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=300)
54
  splits = text_splitter.split_documents(docs)
55
 
56
  # Load embeddings
@@ -64,14 +64,25 @@ def process_answer(question, full_text):
64
  llm = load_model()
65
 
66
  # Create a custom prompt
67
- prompt_template = PromptTemplate.from_template("""
68
- You are a helpful assistant. Use the following context to answer the question as accurately and thoroughly as possible.
69
-
70
- Context: {context}
71
-
72
- Question: {question}
73
-
74
- Answer in detail:""")
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  # Retrieval QA with custom prompt
77
  qa_chain = RetrievalQA.from_chain_type(
 
50
  docs = loader.load()
51
 
52
  # Chunk the documents with increased size and overlap
53
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=800, chunk_overlap=300)
54
  splits = text_splitter.split_documents(docs)
55
 
56
  # Load embeddings
 
64
  llm = load_model()
65
 
66
  # Create a custom prompt
67
+ prompt_template = PromptTemplate(
68
+ input_variables=["context", "question"],
69
+ template="""
70
+ You are a helpful assistant. Carefully analyze the given context and extract direct answers ONLY from it.
71
+
72
+ Context:
73
+ {context}
74
+
75
+ Question:
76
+ {question}
77
+
78
+ Important Instructions:
79
+ - If the question asks for a URL (e.g., LinkedIn link), provide the exact URL as it appears.
80
+ - Do NOT summarize or paraphrase.
81
+ - If the information is not in the context, say "Not found in the document."
82
+
83
+ Answer:
84
+ """)
85
+
86
 
87
  # Retrieval QA with custom prompt
88
  qa_chain = RetrievalQA.from_chain_type(