Author SHA1 Message Date
armistace 9e9ac7b99d finished repo work 2025-05-30 15:17:52 +10:00
armistace 328e870bf0 finailising repo manager 2025-05-29 23:55:12 +10:00
armistace 546b86738a TODO: parse URL paramters correctly 2025-05-29 17:29:48 +10:00
armistace 1bb99c2343 change the .env to openthinkier as editor 2025-05-29 16:30:45 +10:00
= c5444f1a7f merge is going to suck 2025-05-27 23:33:27 +10:00
6 changed files with 90 additions and 28 deletions
+1
View File
@@ -5,3 +5,4 @@ __pycache__
.vscode
.zed
pyproject.toml
.ropeproject
+5 -1
View File
@@ -8,7 +8,11 @@ ENV PYTHONUNBUFFERED 1
ADD src/ /blog_creator
RUN apt-get update && apt-get install -y rustc cargo python-is-python3 pip python3-venv libmagic-dev git
# Need to set up git here or we get funky errors
RUN git config --global user.name "Blog Creator"
RUN git config --global user.email "ridgway.infrastructure@gmail.com"
RUN git config --global push.autoSetupRemote true
#Get a python venv going as well cause safety
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
+45
View File
@@ -0,0 +1,45 @@
# When to Use AI: Navigating the Right Moments for Machine Learning and Beyond
In today's tech landscape, the question "When should we use AI?" is as common as it is critical. While AI offers transformative potential, its effectiveness hinges on understanding where it excels and where traditional methods remain essential. Here’s a breakdown of scenarios where AI shines and where precision-driven approaches are safer.
### AI’s Sweet Spot: Where Humans Fail
1. **Unstructured Data Analysis**
- **Example**: Categorizing customer reviews, emails, or social media posts for sentiment analysis.
- **Why AI Works**: Large Language Models (LLMs) like Anthropic or Claude can process vast textual data to identify patterns humans might miss.
2. **Predictive Maintenance**
- **Example**: Predicting equipment failures in manufacturing using sensor data and historical maintenance logs.
- **Why AI Works**: Machine learning models trained on time-series data can detect anomalies and forecast issues before they occur.
3. **Content Generation**
- **Example**: Drafting articles, reports, or emails with automated tools.
- **Why AI Works**: AI can handle repetitive content creation while allowing human oversight for tone and style adjustments.
### Where AI Falls Short: Precision Over Flexibility
1. **Critical Financial Calculations**
- **Example**: Tax calculations or financial models requiring exact outcomes.
- **Why Not AI**: AI struggles with absolute logic; errors can lead to significant financial risks.
2. **Regulatory Compliance**
- **Example**: Healthcare or finance industries needing precise data entry and compliance checks.
- **Why Not AI**: AI might misinterpret rules, leading to legal issues.
3. **Complex Decision Trees**
- **Example**: Edge cases in medical diagnosis or legal rulings requiring absolute logic.
- **Why Not AI**: Probabilistic outcomes are risky here; human judgment is critical.
### Hybrid Approaches for Success
- **Data Collection & Initial Analysis**: Use AI to gather insights from unstructured data.
- **Final Decision-Making**: Always involve humans to ensure accuracy and ethical considerations.
**Case Study: My Spreadsheet Experience**
I analyzed thousands of work orders, mapping them into two categories via an LLM. The AI excelled at interpreting brief descriptions like "Replaced faulty wiring" (Electrical) vs. "Fixed AC unit" (Plumbing). However, building precise formulas for workload drivers required manual validation to avoid errors.
### Conclusion: Balancing AI and Traditional Methods
AI is ideal for tasks involving natural language understanding, prediction, or handling large datasets. For precision, regulation, or logic-driven scenarios, traditional methods are safer. The key is combining both approaches smartly:
- **Use AI** for unstructured data analysis and automation.
- **Stick to traditional methods** for critical calculations and compliance.
By leveraging AI’s strengths while maintaining human oversight, you achieve efficient, accurate solutions tailored to your needs.
+7 -5
View File
@@ -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"]
@@ -87,11 +87,13 @@ class OllamaGenerator:
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:
@@ -153,7 +155,7 @@ class OllamaGenerator:
def generate_commit_message(self):
prompt_system = "You are a blog creator commiting a piece of content to a central git repo"
prompt_human = f"Generate a 10 word git commit message describing {self.response}"
prompt_human = f"Generate a 5 word git commit message describing {self.response}"
messages = [("system", prompt_system), ("human", prompt_human),]
commit_message = self.llm.invoke(messages).text()
return commit_message
+2 -2
View File
@@ -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 = git_repo.GitRepository("blog/", git_user, git_pass)
repo_manager.create_copy_commit_push(blog_path, os_friendly_title, commit_message)
+22 -12
View File
@@ -1,4 +1,5 @@
import os, shutil
from urllib.parse import quote
from git import Repo
from git.exc import GitCommandError
@@ -10,7 +11,15 @@ class GitRepository:
def __init__(self, repo_path, username=None, password=None):
git_protocol = os.environ["GIT_PROTOCOL"]
git_remote = os.environ["GIT_REMOTE"]
remote = f"{git_protocol}://{username}:{password}@{git_remote}"
#if username is not set we don't need parse to the url
if username==None or password == None:
remote = f"{git_protocol}://{git_remote}"
else:
# of course if it is we need to parse and escape it so that it
# can generate a url
git_user = quote(username)
git_password = quote(password)
remote = f"{git_protocol}://{git_user}:{git_password}@{git_remote}"
if os.path.exists(repo_path):
shutil.rmtree(repo_path)
@@ -41,7 +50,7 @@ class GitRepository:
def pull(self, remote_name='origin', ref_name='main'):
"""Pull updates from a remote repository with authentication"""
try:
self.repo.remotes[remote_name].pull(ref_name=ref_name)
self.repo.remotes[remote_name].pull(ref_name)
return True
except GitCommandError as e:
print(f"Pulling failed: {e}")
@@ -52,15 +61,15 @@ class GitRepository:
return [branch.name for branch in self.repo.branches]
def create_branch(self, branch_name, remote_name='origin', ref_name='main'):
def create_and_switch_branch(self, branch_name, remote_name='origin', ref_name='main'):
"""Create a new branch in the repository with authentication."""
try:
# Use the same remote and ref as before
self.repo.git.branch(branch_name, commit=True)
return True
except GitCommandError as e:
print(f"Failed to create branch: {e}")
return False
self.repo.git.branch(branch_name)
except GitCommandError:
print("Branch already exists switching")
# ensure remote commits are pulled into local
self.repo.git.checkout(branch_name)
def add_and_commit(self, message=None):
"""Add and commit changes to the repository."""
@@ -72,20 +81,21 @@ class GitRepository:
commit_message = "Added and committed new content"
else:
commit_message = message
self.repo.git.commit(commit_message=commit_message)
self.repo.git.commit(message=commit_message)
return True
except GitCommandError as e:
print(f"Commit failed: {e}")
return False
def create_copy_commit_push(self, file_path, title, commit_messge):
self.create_branch(title)
self.create_and_switch_branch(title)
self.pull(ref_name=title)
shutil.copy(f"{file_path}", f"{self.repo_path}src/content/")
self.add_and_commit(commit_messge)
self.add_and_commit(f"'{commit_messge}'")
self.repo.git.push(remote_name='origin', ref_name=title, force=True)
self.repo.git.push()
def remove_repo(self):
shutil.rmtree(self.repo_path)