Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
733241554f
|
||
|
|
92e9f3dcc2
|
||
|
|
2fbe47e936 | ||
|
|
f2b95935bb | ||
|
|
bce439921f | ||
|
|
2de2d0fe3a | ||
|
|
cf795bbc35 | ||
|
|
a6ed20451a | ||
|
|
2abc39e3ac | ||
|
|
0594ea54aa | ||
|
|
60f7473297 | ||
|
|
ec69e8e4f7 | ||
|
|
41f804a1eb | ||
|
|
e3262cd366 | ||
|
|
e2c29204fa | ||
|
|
44b5ea6a68 | ||
|
|
9296fda390 | ||
|
|
703a2384e7 |
@@ -1,7 +1,7 @@
|
|||||||
name: Create Blog Article if new notes exist
|
name: Create Blog Article if new notes exist
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "15 3 * * *"
|
- cron: "15 18 * * *"
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ class OllamaGenerator:
|
|||||||
self.llm = ChatOllama(model=self.ollama_model, temperature=0.6, top_p=0.5) #This is the level head in the room
|
self.llm = ChatOllama(model=self.ollama_model, temperature=0.6, top_p=0.5) #This is the level head in the room
|
||||||
self.prompt_inject = f"""
|
self.prompt_inject = f"""
|
||||||
You are a journalist, Software Developer and DevOps expert
|
You are a journalist, Software Developer and DevOps expert
|
||||||
writing a 3000 word draft blog article for other tech enthusiasts.
|
writing a 5000 word draft blog article for other tech enthusiasts.
|
||||||
You like to use almost no code examples and prefer to talk
|
You like to use almost no code examples and prefer to talk
|
||||||
in a light comedic tone. You are also Australian
|
in a light comedic tone. You are also Australian
|
||||||
As this person write this blog as a markdown document.
|
As this person write this blog as a markdown document.
|
||||||
The title for the blog is {self.inner_title}.
|
The title for the blog is {self.inner_title}.
|
||||||
Do not output the title in the markdown.
|
Do not output the title in the markdown.
|
||||||
The basis for the content of the blog is:
|
The basis for the content of the blog is:
|
||||||
{self.content}
|
<blog>{self.content}</blog>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def split_into_chunks(self, text, chunk_size=100):
|
def split_into_chunks(self, text, chunk_size=100):
|
||||||
@@ -71,8 +71,8 @@ class OllamaGenerator:
|
|||||||
top_k = int(random.uniform(30, 80))
|
top_k = int(random.uniform(30, 80))
|
||||||
agent_llm = ChatOllama(model=model, temperature=temp, top_p=top_p, top_k=top_k)
|
agent_llm = ChatOllama(model=model, temperature=temp, top_p=top_p, top_k=top_k)
|
||||||
messages = [
|
messages = [
|
||||||
("system", self.prompt_inject),
|
("system", "You are a creative writer specialising in writing about technology"),
|
||||||
("human", "make the blog post in a format to be edited easily" )
|
("human", self.prompt_inject )
|
||||||
]
|
]
|
||||||
response = agent_llm.invoke(messages)
|
response = agent_llm.invoke(messages)
|
||||||
# self.response = self.ollama_client.chat(model=model,
|
# self.response = self.ollama_client.chat(model=model,
|
||||||
@@ -119,26 +119,30 @@ class OllamaGenerator:
|
|||||||
|
|
||||||
def generate_markdown(self) -> str:
|
def generate_markdown(self) -> str:
|
||||||
|
|
||||||
prompt_system = f"""
|
prompt_human = f"""
|
||||||
You are an editor taking information from {len(self.agent_models)} Software
|
You are an editor taking information from {len(self.agent_models)} Software
|
||||||
Developers and Data experts
|
Developers and Data experts
|
||||||
writing a 3000 word blog article. You like when they use almost no code examples.
|
writing a 5000 word blog article. You like when they use almost no code examples.
|
||||||
You are also Australian. The content may have light comedic elements,
|
You are also Australian. The content may have light comedic elements,
|
||||||
you are more professional and will attempt to tone these down
|
you are more professional and will attempt to tone these down
|
||||||
As this person produce and an amalgamtion of this blog as a markdown document.
|
As this person produce the final version of this blog as a markdown document
|
||||||
|
keeping in mind the context provided by the previous drafts.
|
||||||
|
You are to produce the content not placeholders for further editors
|
||||||
The title for the blog is {self.inner_title}.
|
The title for the blog is {self.inner_title}.
|
||||||
Do not output the title in the markdown. Avoid repeated sentences
|
Do not output the title in the markdown. Avoid repeated sentences
|
||||||
The basis for the content of the blog is:
|
The basis for the content of the blog is:
|
||||||
{self.content}
|
<blog>{self.content}</blog>
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
query_embed = self.ollama_client.embed(model=self.embed_model, input=prompt_system)['embeddings']
|
query_embed = self.ollama_client.embed(model=self.embed_model, input=prompt_human)['embeddings']
|
||||||
collection = self.load_to_vector_db()
|
collection = self.load_to_vector_db()
|
||||||
collection_query = collection.query(query_embeddings=query_embed, n_results=100)
|
collection_query = collection.query(query_embeddings=query_embed, n_results=100)
|
||||||
print("Showing pertinent info from drafts used in final edited edition")
|
print("Showing pertinent info from drafts used in final edited edition")
|
||||||
pertinent_draft_info = '\n\n'.join(collection.query(query_embeddings=query_embed, n_results=100)['documents'][0])
|
pertinent_draft_info = '\n\n'.join(collection.query(query_embeddings=query_embed, n_results=100)['documents'][0])
|
||||||
#print(pertinent_draft_info)
|
#print(pertinent_draft_info)
|
||||||
prompt_human = f"Generate the final document using this information from the drafts: {pertinent_draft_info} - Only output in markdown, do not wrap in markdown tags"
|
prompt_system = f"""Generate the final, 5000 word, draft of the blog using this information from the drafts: <context>{pertinent_draft_info}</context>
|
||||||
|
- Only output in markdown, do not wrap in markdown tags, Only provide the draft not a commentary on the drafts in the context
|
||||||
|
"""
|
||||||
print("Generating final document")
|
print("Generating final document")
|
||||||
messages = [("system", prompt_system), ("human", prompt_human),]
|
messages = [("system", prompt_system), ("human", prompt_human),]
|
||||||
self.response = self.llm.invoke(messages).text()
|
self.response = self.llm.invoke(messages).text()
|
||||||
|
|||||||
Reference in New Issue
Block a user