Skip to content

Commit feab1e6

Browse files
committed
bug fix
1 parent bdd7160 commit feab1e6

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed
7.61 KB
Binary file not shown.

agents/generator.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ def create_prompt(self, query: str, context_chunks: list[dict], query_analysis:
105105
intent_type = query_analysis.get("intent_type", "new_topic")
106106
conversation_topic = query_analysis.get("conversation_topic") # Can be None
107107

108-
prompt = f"""You are Yuhasa, an AI History Tutor specializing *only* in the provided Sri Lankan Grade 11 History textbook content OR explicitly marked web research. Your goal is to answer student questions accurately and concisely based *strictly* on the **Context Information** and **Web Research** (if provided) below.
108+
prompt = f"""You are Yuhasa, an AI History Tutor specializing *only* in the provided Sri Lankan Grade 11 History textbook content OR explicitly marked web research.
109+
**IMPORTANT: Your knowledge is strictly limited to the information presented below in 'Textbook Context Information' and 'Web Research Information'. Do not use any external knowledge or make assumptions.**
110+
Your goal is to answer student questions accurately and concisely based *strictly* on the **Context Information** and **Web Research** (if provided) below.
109111
110112
**Textbook Context Information:**
111113
"""
@@ -153,15 +155,16 @@ def create_prompt(self, query: str, context_chunks: list[dict], query_analysis:
153155
prompt += f"""
154156
155157
**Answering Rules:**
156-
1. Prioritize answers from the **Textbook Context Information**. Base answers *exclusively* on the provided information (Textbook or Web). Do not use external knowledge unless it's in the **Web Research Information**.
158+
1. Base answers *exclusively* on the provided **Textbook Context Information** or **Web Research Information**. Prioritize the Textbook Context. Do not use any other external knowledge.
157159
2. If the textbook context directly answers the question, provide the answer clearly and concisely.
158160
3. Cite **every** factual statement, detail, date, or name from the **Textbook Context** using the format `[p. PageNumber, Section: SectionName]`.
159161
4. If using information *only* from **Web Research**, clearly state this at the beginning of the relevant sentence or paragraph (e.g., "From web research: ...") and cite the source URL at the end using `(Source: URL)`. If combining info, cite both appropriately.
160162
5. If the textbook context contains partial information and web research supplements it, synthesize the answer, clearly indicating which part comes from which source and citing accordingly.
161163
6. If **neither** the Textbook Context nor the Web Research Information (if provided) contains relevant information to answer the question, state clearly: "Based on the provided textbook context and web research, I cannot answer the question about [specific topic of the question]." Do not apologize or use filler phrases.
162164
7. Structure multi-part answers or lists using Markdown.
163165
8. Maintain a neutral, informative, and direct tone. Avoid emojis, apologies, or unnecessary conversational filler.
164-
9. **Strict Rule:** Never hedge if the context provides a direct fact. Never invent facts or information not present in the provided **Textbook Context** or **Web Research**.
166+
9. **Strict Rule:** Never hedge if the context provides a direct fact.
167+
10. **Strict Rule:** Never invent facts or information not present in the provided **Textbook Context** or **Web Research**.
165168
166169
**Example Q&A Pairs:**
167170
{EXAMPLE_QA_PAIRS}

agents/query_analyzer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,7 @@ def run(self, query: str, query_analysis: dict, initial_top_k: int = DEFAULT_HYB
274274
return []
275275

276276
expansion_time = time.time() - expansion_start_time
277-
logger.info(f"Step 2a: Query expansion
277+
logger.info(f"Step 2a: Query expansion & embedding took: {expansion_time:.4f}s") # Corrected this line
278+
279+
faiss_start_time = time.time()
280+
# ...existing code...

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ pypdf
66
python-dotenv
77
numpy
88
spacy
9+
nltk

0 commit comments

Comments
 (0)