merge is going to suck
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import os, re, json, random, time
|
||||
import os, re, json, random, time, string
|
||||
from ollama import Client
|
||||
import chromadb
|
||||
from langchain_ollama import ChatOllama
|
||||
@@ -10,7 +10,7 @@ class OllamaGenerator:
|
||||
self.inner_title = inner_title
|
||||
self.content = content
|
||||
self.response = None
|
||||
self.chroma = chromadb.HttpClient(host="172.19.0.2", port=8000)
|
||||
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 = os.environ["EDITOR_MODEL"]
|
||||
@@ -86,12 +86,14 @@ class OllamaGenerator:
|
||||
'''Get embeddings for the draft chunks'''
|
||||
embeds = self.ollama_client.embed(model=self.embed_model, input=draft_chunks)
|
||||
return embeds.get('embeddings', [])
|
||||
|
||||
|
||||
def id_generator(self, size=6, chars=string.ascii_uppercase + string.digits):
|
||||
return ''.join(random.choice(chars) for _ in range(size))
|
||||
|
||||
def load_to_vector_db(self):
|
||||
'''Load the generated blog drafts into a vector database'''
|
||||
collection_name = f"blog_{self.title.lower().replace(" ", "_")}"
|
||||
collection = self.chroma.get_or_create_collection(name=collection_name, metadata={"hnsw:space": "cosine"})
|
||||
collection_name = f"blog_{self.title.lower().replace(" ", "_")}_{self.id_generator()}"
|
||||
collection = self.chroma.get_or_create_collection(name=collection_name)#, metadata={"hnsw:space": "cosine"})
|
||||
#if any(collection.name == collectionname for collectionname in self.chroma.list_collections()):
|
||||
# self.chroma.delete_collection("blog_creator")
|
||||
for model in self.agent_models:
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ for note in tril_notes:
|
||||
ai_gen.save_to_file(blog_path)
|
||||
# Generate commit messages and push to repo
|
||||
commit_message = ai_gen.generate_commit_message()
|
||||
git_user = os.environp["GIT_USER"]
|
||||
git_user = os.environ["GIT_USER"]
|
||||
git_pass = os.environ["GIT_PASS"]
|
||||
repo_manager = git_repo("blog/", git_user, git_pass)
|
||||
repo_manager.create_copy_commit_push(blog_path, os_friendly_title, commit_message)
|
||||
|
||||
Reference in New Issue
Block a user