Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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=
|
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
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|