summaryrefslogtreecommitdiff
path: root/rag/llm/generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'rag/llm/generator.py')
-rw-r--r--rag/llm/generator.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/rag/llm/generator.py b/rag/llm/generator.py
index cbe9474..5f164e7 100644
--- a/rag/llm/generator.py
+++ b/rag/llm/generator.py
@@ -2,16 +2,14 @@ import os
from dataclasses import dataclass
import ollama
+from loguru import logger as log
@dataclass
class Prompt:
- question: str
+ query: str
context: str
- # def context(self) -> str:
- # return "\n".join(point.payload["text"] for point in self.points)
-
class Generator:
def __init__(self) -> None:
@@ -22,14 +20,16 @@ class Generator:
f"You are a {role}.\n"
"Answer the following question using the provided context.\n"
"If you can't find the answer, do not pretend you know it,"
- 'but answer "I don\'t know".'
- f"Question: {prompt.question.strip()}\n\n"
+ 'but answer "I don\'t know".\n\n'
+ f"Question: {prompt.query.strip()}\n\n"
"Context:\n"
f"{prompt.context.strip()}\n\n"
"Answer:\n"
)
return metaprompt
- def generate(self, role: str, prompt: Prompt) -> str:
+ def generate(self, prompt: Prompt, role: str) -> str:
+ log.debug("Generating answer...")
metaprompt = self.__metaprompt(role, prompt)
+ print(f"metaprompt = \n{metaprompt}")
return ollama.generate(model=self.model, prompt=metaprompt)