diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-04-08 22:28:47 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-04-08 22:28:47 +0200 |
commit | d487ef8b04cc7f5ac1491f0638f902fe2abe5ac5 (patch) | |
tree | c2e02b81b410092f083d8c1d6c606e5975f2b568 /rag/llm/generator.py | |
parent | 5f777ecdfbf486e5057d31547bdc53358037dce0 (diff) |
Wip refactor
Diffstat (limited to 'rag/llm/generator.py')
-rw-r--r-- | rag/llm/generator.py | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/rag/llm/generator.py b/rag/llm/generator.py deleted file mode 100644 index 8c7702f..0000000 --- a/rag/llm/generator.py +++ /dev/null @@ -1,33 +0,0 @@ -import os -from dataclasses import dataclass - -import ollama -from loguru import logger as log - - -@dataclass -class Prompt: - query: str - context: str - - -class Generator: - def __init__(self) -> None: - self.model = os.environ["GENERATOR_MODEL"] - - def __metaprompt(self, prompt: Prompt) -> str: - metaprompt = ( - "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".\n\n' - f"Question: {prompt.query.strip()}\n\n" - "Context:\n" - f"{prompt.context.strip()}\n\n" - "Answer:\n" - ) - return metaprompt - - def generate(self, prompt: Prompt) -> str: - log.debug("Generating answer...") - metaprompt = self.__metaprompt(prompt) - return ollama.generate(model=self.model, prompt=metaprompt) |