From 8fd1d94124a93332c3ef038c7e4c0b4bf436a3f7 Mon Sep 17 00:00:00 2001 From: Lasse Studion Date: Thu, 30 May 2024 14:13:01 +0200 Subject: [PATCH] Refactor Ollama class and script for fetching electric car documents --- ollama_class.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ollama_class.py diff --git a/ollama_class.py b/ollama_class.py new file mode 100644 index 0000000..4b9217d --- /dev/null +++ b/ollama_class.py @@ -0,0 +1,15 @@ +import ollama + +class Ollama: + def __init__(self, model='llama3:8b-instruct-q5_K_M', temperature=0): + self.model = model + self.temperature = temperature + + def generate(self, prompt): + return ollama.generate(prompt=prompt, model=self.model, options={'temperature': self.temperature})['response'] + + +if __name__ == "__main__": + # Example usage + prompt = 'Tell me a joke!' + ollama = Ollama() \ No newline at end of file