Spaces:
Sleeping
Sleeping
| from rag.llm import generate | |
| from evaluation.metrics import evaluate_and_log | |
| def run_rag(question, vectorstore): | |
| docs = vectorstore.similarity_search(question, k=3) | |
| context = "\n\n".join(d.page_content for d in docs) | |
| prompt = ( | |
| "Use the context below to answer the question clearly and simply.\n\n" | |
| f"Context:\n{context}\n\n" | |
| f"Question: {question}\n\n" | |
| "Answer:" | |
| ) | |
| answer = generate(prompt) | |
| evaluation = evaluate_and_log(question, context, answer) | |
| sources = f"Retrieved {len(docs)} relevant passages from document" | |
| return answer, sources, evaluation |