truncated answer reponse
Browse files- service/llm_service.py +1 -1
- service/rag_service.py +16 -13
service/llm_service.py
CHANGED
|
@@ -17,7 +17,7 @@ class LLMService:
|
|
| 17 |
|
| 18 |
output = self.model.generate(
|
| 19 |
**inputs,
|
| 20 |
-
max_new_tokens=
|
| 21 |
do_sample=True,
|
| 22 |
temperature=0.7,
|
| 23 |
top_p=0.9,
|
|
|
|
| 17 |
|
| 18 |
output = self.model.generate(
|
| 19 |
**inputs,
|
| 20 |
+
max_new_tokens=256,
|
| 21 |
do_sample=True,
|
| 22 |
temperature=0.7,
|
| 23 |
top_p=0.9,
|
service/rag_service.py
CHANGED
|
@@ -24,23 +24,26 @@ def generate_answer(question: str, session_id: str) -> str:
|
|
| 24 |
memory = get_memory(session_id)
|
| 25 |
|
| 26 |
prompt = f"""
|
| 27 |
-
<|system|>
|
| 28 |
-
You are a helpful assistant.
|
| 29 |
-
Answer ONLY using the provided context.
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
Conversation memory:
|
| 33 |
-
{memory}
|
| 34 |
|
| 35 |
-
<|user|>
|
| 36 |
-
Context:
|
| 37 |
-
{chr(10).join(context)}
|
| 38 |
|
| 39 |
-
Question:
|
| 40 |
-
{question}
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
<|assistant|>
|
| 43 |
-
"""
|
| 44 |
|
| 45 |
answer = llm.generate(prompt)
|
| 46 |
|
|
|
|
| 24 |
memory = get_memory(session_id)
|
| 25 |
|
| 26 |
prompt = f"""
|
| 27 |
+
<|system|>
|
| 28 |
+
You are a helpful assistant.
|
| 29 |
+
Answer ONLY using the provided context.
|
| 30 |
+
Give a COMPLETE, well-formed answer.
|
| 31 |
+
Do not stop mid-sentence.
|
| 32 |
+
If the answer is not in the context, say "I don't know".
|
| 33 |
|
| 34 |
+
Conversation memory:
|
| 35 |
+
{memory}
|
| 36 |
|
| 37 |
+
<|user|>
|
| 38 |
+
Context:
|
| 39 |
+
{chr(10).join(context)}
|
| 40 |
|
| 41 |
+
Question:
|
| 42 |
+
{question}
|
| 43 |
+
|
| 44 |
+
<|assistant|>
|
| 45 |
+
"""
|
| 46 |
|
|
|
|
|
|
|
| 47 |
|
| 48 |
answer = llm.generate(prompt)
|
| 49 |
|