getting gemma3 in the mix
This commit is contained in:
@@ -5,23 +5,23 @@ import chromadb, time
|
||||
|
||||
class OllamaGenerator:
|
||||
|
||||
def __init__(self, title: str, content: str, model: str):
|
||||
def __init__(self, title: str, content: str, model: str, inner_title: str):
|
||||
self.title = title
|
||||
self.inner_title = inner_title
|
||||
self.content = content
|
||||
self.chroma = chromadb.HttpClient(host="172.18.0.2", port=8000)
|
||||
ollama_url = f"{os.environ["OLLAMA_PROTOCOL"]}://{os.environ["OLLAMA_HOST"]}:{os.environ["OLLAMA_PORT"]}"
|
||||
self.ollama_client = Client(host=ollama_url)
|
||||
self.ollama_model = model
|
||||
self.embed_model = "snowflake-arctic-embed2:latest"
|
||||
self.agent_models = ["openthinker:7b", "deepseek-r1:7b", "qwen2.5:7b", "deepseek-coder-v2:16b"]
|
||||
self.agent_models = ["openthinker:7b", "deepseek-r1:7b", "qwen2.5:7b", "gemma3:latest"]
|
||||
self.prompt_inject = f"""
|
||||
You are a journalist Software Developer and DevOps expert
|
||||
who has transistioned in Developer Relations
|
||||
You are a journalist, Software Developer and DevOps expert
|
||||
writing a 1000 word draft blog for other tech enthusiasts.
|
||||
You like to use almost no code examples and prefer to talk
|
||||
in a light comedic tone. You are also Australian
|
||||
As this person write this blog as a markdown document.
|
||||
The title for the blog is {self.title}.
|
||||
The title for the blog is {self.inner_title}.
|
||||
Do not output the title in the markdown.
|
||||
The basis for the content of the blog is:
|
||||
{self.content}
|
||||
@@ -95,13 +95,12 @@ class OllamaGenerator:
|
||||
prompt = f"""
|
||||
You are an editor taking information from {len(self.agent_models)} Software
|
||||
Developers and Data experts
|
||||
who have transistioned into Developer Relations
|
||||
writing a 3000 word blog for other tech enthusiasts.
|
||||
You like when they use almost no code examples and the
|
||||
voice is in a light comedic tone. You are also Australian
|
||||
As this person produce and an amalgamtion of this blog as a markdown document.
|
||||
The title for the blog is {self.title}.
|
||||
Do not output the title in the markdown.
|
||||
The title for the blog is {self.inner_title}.
|
||||
Do not output the title in the markdown. Avoid repeated sentences
|
||||
The basis for the content of the blog is:
|
||||
{self.content}
|
||||
"""
|
||||
@@ -110,10 +109,6 @@ class OllamaGenerator:
|
||||
collection = self.load_to_vector_db()
|
||||
collection_query = collection.query(query_embeddings=query_embed, n_results=100)
|
||||
print("Showing pertinent info from drafts used in final edited edition")
|
||||
for document in collection_query:
|
||||
print (document['ids'])
|
||||
print (document['embeddings'])
|
||||
print (document['documents'])
|
||||
pertinent_draft_info = '\n\n'.join(collection.query(query_embeddings=query_embed, n_results=100)['documents'][0])
|
||||
prompt_enhanced = f"{prompt} - Generate the final document using this information from the drafts: {pertinent_draft_info} - ONLY OUTPUT THE MARKDOWN"
|
||||
print("Generating final document")
|
||||
|
||||
+9
-5
@@ -1,5 +1,6 @@
|
||||
import ai_generators.ollama_md_generator as omg
|
||||
import trilium.notes as tn
|
||||
import string
|
||||
|
||||
tril = tn.TrilumNotes()
|
||||
|
||||
@@ -7,8 +8,10 @@ tril.get_new_notes()
|
||||
tril_notes = tril.get_notes_content()
|
||||
|
||||
|
||||
def convert_to_lowercase_with_underscores(string):
|
||||
return string.lower().replace(" ", "_")
|
||||
def convert_to_lowercase_with_underscores(s):
|
||||
allowed = set(string.ascii_letters + string.digits + ' ')
|
||||
filtered_string = ''.join(c for c in s if c in allowed)
|
||||
return filtered_string.lower().replace(" ", "_")
|
||||
|
||||
|
||||
for note in tril_notes:
|
||||
@@ -16,8 +19,9 @@ for note in tril_notes:
|
||||
# print(tril_notes[note]['content'])
|
||||
print("Generating Document")
|
||||
|
||||
ai_gen = omg.OllamaGenerator(tril_notes[note]['title'],
|
||||
tril_notes[note]['content'],
|
||||
"qwen2.5:7b")
|
||||
os_friendly_title = convert_to_lowercase_with_underscores(tril_notes[note]['title'])
|
||||
ai_gen = omg.OllamaGenerator(os_friendly_title,
|
||||
tril_notes[note]['content'],
|
||||
"gemma3:latest",
|
||||
tril_notes[note]['title'])
|
||||
ai_gen.save_to_file(f"/blog_creator/generated_files/{os_friendly_title}.md")
|
||||
|
||||
Reference in New Issue
Block a user