Spaces:
Running
Running
Update utils/llm.py
Browse files- utils/llm.py +6 -20
utils/llm.py
CHANGED
@@ -38,28 +38,14 @@ class LLMProcessor:
|
|
38 |
|
39 |
def generate_answer(self, context: str, question: str) -> str:
|
40 |
"""Generate answer using structured context"""
|
41 |
-
prompt = f"""
|
42 |
-
|
43 |
|
44 |
-
|
|
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
{context}
|
49 |
-
|
50 |
-
### User Question:
|
51 |
-
{question}
|
52 |
-
|
53 |
-
---
|
54 |
-
#### Instructions:
|
55 |
-
- Use only the given context to construct your answer.
|
56 |
-
- Reference relevant sections and page numbers where applicable.
|
57 |
-
- Be concise yet informative, focusing on clarity and usefulness.
|
58 |
-
- If uncertain, respond honestly (e.g., "The answer is not found in the provided context.").
|
59 |
-
- If out of context, state so clearly (e.g., "The question is out of context, but here’s what I found in the document...").
|
60 |
-
|
61 |
-
---
|
62 |
-
### Helpful Answer:
|
63 |
"""
|
64 |
|
65 |
return self.llm.invoke(prompt)
|
|
|
38 |
|
39 |
def generate_answer(self, context: str, question: str) -> str:
|
40 |
"""Generate answer using structured context"""
|
41 |
+
prompt = f"""Use the following pieces of information to answer the user's question.
|
42 |
+
If you don't know the answer, just say that you don't know,if it is out of context say that it is out of context and also try to provide the answer and don't be rude.
|
43 |
|
44 |
+
Context: {context}
|
45 |
+
Question: {question}
|
46 |
|
47 |
+
Only return the helpful answer below and nothing else.
|
48 |
+
Helpful answer:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
"""
|
50 |
|
51 |
return self.llm.invoke(prompt)
|