summaryrefslogtreecommitdiff
path: root/rag/cli.py
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2024-04-23 22:08:03 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2024-04-23 22:08:03 +0200
commit75be0914f6bd2cdeda1539f83b38fcbc854d5cfa (patch)
tree8d518f43926a98ee2cbae262d152662d0c07e9f6 /rag/cli.py
parent694a4ad0e5a9e4c7eb6d11fff5ae414292ef8169 (diff)
Add reranking as a separate step
Diffstat (limited to 'rag/cli.py')
-rw-r--r--rag/cli.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/rag/cli.py b/rag/cli.py
index 690563e..932e2a9 100644
--- a/rag/cli.py
+++ b/rag/cli.py
@@ -37,13 +37,13 @@ def rag(generator: str, query: str, limit):
retriever = Retriever()
generator = get_generator(generator)
documents = retriever.retrieve(query, limit=limit)
- prompt = Prompt(query, documents)
+ prompt = generator.rerank(Prompt(query, documents))
print("Answer: ")
for chunk in generator.generate(prompt):
print(chunk, end="", flush=True)
print("\n\n")
- for i, doc in enumerate(documents):
+ for i, doc in enumerate(prompt.documents):
print(f"### Document {i}")
print(f"**Title: {doc.title}**")
print(doc.text)