Publisher task
This commit is contained in:
24
app_urls/fetcher/src/llm.py
Normal file
24
app_urls/fetcher/src/llm.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import ollama
|
||||
import os
|
||||
|
||||
class OllamaClient():
|
||||
def __init__(self):
|
||||
self.client = ollama.Client(host=os.getenv("ENDPOINT_OLLAMA", "https://ollamamodel.matitos.org"))
|
||||
|
||||
def _get_default_model(self):
|
||||
return "llama3.2:3b"
|
||||
|
||||
def get_models(self):
|
||||
models = sorted([m.model for m in self.client.list().models])
|
||||
if (self._get_default_model() in models):
|
||||
return [self._get_default_model()] + [m for m in models if m != self._get_default_model()]
|
||||
else:
|
||||
return models
|
||||
|
||||
def get_prompt(self):
|
||||
return ("Rewrite the text below into a clear and concise summary of one paragraph maximum, presenting the key points as if they are newly written insights. "
|
||||
"Do not mention or reference the original text, its source, or any phrases like 'According to' or 'The text states'. "
|
||||
"Write in a natural, standalone format that feels like an original explanation. "
|
||||
"Keep it brief, engaging, informative, in the style of a news article: \n"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user