add reuse code

This commit is contained in:
yichuan520030910320
2025-07-07 21:07:00 +00:00
parent 95a653993a
commit 6fc57eb48e
4 changed files with 25 additions and 1 deletions

View File

@@ -217,7 +217,12 @@ class LeannChat:
results = self.searcher.search(question, top_k=top_k, **kwargs)
context = "\n\n".join([r.text for r in results])
prompt = f"Context:\n{context}\n\nQuestion: {question}\n\nAnswer:"
prompt = (
"Here is some retrieved context that might help answer your question:\n\n"
f"{context}\n\n"
f"Question: {question}\n\n"
"Please provide the best answer you can based on this context and your knowledge."
)
print(f"DEBUG: Calling LLM with prompt: {prompt}...")
try: