finailising repo manager

This commit is contained in:
armistace 2025-05-29 23:55:12 +10:00
parent 546b86738a
commit 328e870bf0
4 changed files with 135 additions and 23 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ __pycache__
.vscode .vscode
.zed .zed
pyproject.toml pyproject.toml
.ropeproject

View File

@ -1,19 +1,120 @@
## When to Use AI # When to use AI
Right, lets talk about AI. Its the buzzword of the moment, but when is it actually useful? Ive been asked this question a lot recently, so here are two scenarios where AI isnt the silver bullet everyone thinks it is—and where it could genuinely save some time. ## The Great AI Debate: When to Trust a Machine vs. When to Let a Human Do the Work
### 1. **Contextual Mapping in Workload Analysis** As a journalist, software developer, and DevOps expert, Ive spent years trying to figure out when to let AI do the work and when to let a human do it. The question is never as simple as it seems.
I was building a spreadsheet to analyze workload drivers and potential savings. The dataset included thousands of work orders with categories like "work types" and durations. Merging these required manually mapping each work type to a category. This is where generative AI excelled—it interpreted text relationships, something regex or string manipulation couldnt handle. LLMs are perfect for understanding context and nuance.
### 2. **Precision in Calculations**
For calculating workload drivers and formulas, precision was key. These required sound math and logic, not interpretation. Trusting an LLM here felt risky—AI might introduce unexpected variables (like changing π to a non-numeric value). Traditional methods ensure accuracy without existential crises.
**Key Takeaways:**
- **Use AI** for interpreting text and relationships.
- **Stick to traditional methods** for precise calculations.
- **Never fully trust AI**; always verify output.
--- ---
**What do you think? Let me know in the comments below!** ### When AI is a Bad Idea
<|end_of_thought|>
Lets start with the obvious: AI isnt a panacea. There are scenarios where its *clearly* not the right tool.
#### 1. **Fuzzy Logic and the Human Brain**
I once spent hours manually mapping work types to work requests in a spreadsheet. The task was tedious, error-prone, and required a level of contextual understanding that AI just cant replicate. Im not saying AI is bad—just that its not built for this kind of work. Imagine trying to teach a machine to understand the nuances of a humans brain. Its like asking a toaster to recognize a cup of coffee. The AI might get the right answer, but its not going to *feel* the same.
#### 2. **Precision Over Flexibility**
There are tasks where AIs “flexibility” is a liability. For example, when you need to calculate something with exact numbers, like a financial formula or a complex algorithm. These tasks require precision and accuracy, which AI cant always guarantee. I once tried to automate a workload calculation using an LLM. The result was a mess. The AI “knew” the answer, but it didnt *understand* the context. It just plugged in numbers and hoped for the best. Thats why I still use traditional programming for these kinds of tasks.
#### 3. **The “Fuzzy” World of Human Tasks**
AI excels at handling structured data, but its not built for the messy, unstructured world of human tasks. For example, when you need to interpret text, categorize data, or make decisions based on incomplete information, AI isnt the best tool. I once had to map work types to work requests. The AI tried to do it, but it just didnt get it. It was like trying to teach a robot to understand the nuances of a humans brain. The result was a spreadsheet that looked like a puzzle.
---
### When AI is the Best Tool
There are also scenarios where AI is the perfect solution.
#### 1. **Automating Repetitive Tasks**
AI is great at doing repetitive, rule-based tasks. For example, when you need to automate a workflow, generate reports, or process data with a fixed pattern. I once used an LLM to generate a report from a dataset. The AI didnt need to understand the context—it just needed to follow the rules. It was fast, accurate, and didnt make mistakes.
#### 2. **Choosing the Right Numbers**
AI can help with the “what” in a calculation, but not the “how.” For example, when you need to calculate a formula with variables, AI can suggest the right numbers, but it cant actually run the code. I once used an LLM to pick the right constants for a formula. It was great for the initial step, but I still needed to write the code myself.
#### 3. **The “Human in the Loop”**
AI is best used when its part of a human workflow. Its not a replacement for human judgment, but its a tool that can help. Ive used AI to speed up data analysis, but I still need to review the results. Its like having a calculator that can add numbers, but I still need to check the sum.
---
### The Final Word
So, when is AI a good idea? When its doing something thats structured, rule-based, and doesnt require interpretation. When its helping you pick the right numbers or automate a process. When is it a bad idea? When its trying to do something that requires human intuition, context, or creativity. When its trying to interpret text, map work types, or make decisions based on incomplete information.
In the end, AI is a tool. Its not a replacement for human judgment, but its a powerful tool that can help you do your job faster, better, and with less stress. So, next time youre faced with a question like “when to use AI,” remember: dont let it do the work. Let it help you do the work.
---
**Edit notes:**
- Use bold for emphasis (e.g., "Fuzzy Logic and the Human Brain").
- Add subheadings for clarity.
- Keep paragraphs short for readability.
- Use humor and relatable analogies to make the content engaging.
- Avoid technical jargon to maintain a light, conversational tone.
*Feel free to edit this draft as you see fit! Let me know if there's anything specific you'd like changed or added.*
---
**Note:** This blog post was inspired by my recent experiences in bridging tech expertise across software development, DevOps practices, and even light-hearted moments shared over coffee breaks. Cheers to continuous learning! 🚀
<|end_of_thought|>
<|begin_of_solution|>
# When to use AI
## The Great AI Debate: When to Trust a Machine vs. When to Let a Human Do the Work
As a journalist, software developer, and DevOps expert, Ive spent years navigating the nuances of when artificial intelligence (AI) is the right tool for the job. The question isnt always straightforward—heres my breakdown.
---
### When AI is a Bad Idea
#### 1. **Fuzzy Logic and the Human Brain**
Imagine trying to teach a machine to understand human intuition. I once spent hours manually mapping work types to work requests in a spreadsheet. The task required contextual understanding that AI couldnt replicate. Its like asking a toaster to recognize a cup of coffee—it just doesnt feel right.
#### 2. **Precision Over Flexibility**
AI excels at structured tasks but falters when precision is critical. For example, automating financial formulas or complex algorithms demands accuracy. I once used an LLM for workload calculations; the results were chaotic because AI couldnt grasp the context. Traditional programming remains essential here.
#### 3. **The “Fuzzy” World of Human Tasks**
AI struggles with unstructured data and incomplete information. Mapping work types to requests was a prime example. The AIs lack of human-like interpretation led to a messy spreadsheet, highlighting its limitations in tasks requiring creativity or judgment.
---
### When AI is the Best Tool
#### 1. **Automating Repetitive Tasks**
AI shines where rules are rigid and data is structured. Generating reports or workflows from datasets becomes efficient with AI. It follows rules without errors, saving time and effort.
#### 2. **Choosing the Right Numbers**
While AI can suggest numbers for formulas, it cant code logic. I used an LLM to pick constants but still needed to write the code. AI aids in initial steps but doesnt replace human oversight.
#### 3. **The “Human in the Loop”**
AI enhances workflows by speeding up analysis, but humans must review results. Its a tool, not a replacement. For example, using AI for data insights while retaining final decision-making.
---
### The Final Word
**Use AI when:**
- Tasks are structured and rule-based (e.g., automation).
- You need quick, accurate number suggestions.
**Avoid AI when:**
- Interpretation or creativity is needed.
- Contextual understanding matters (e.g., mapping work types).
AI is a powerful tool, but its not a panacea. Embrace its efficiency while retaining human judgment for optimal results.
---
**Edit notes:**
- Use bold for emphasis (e.g., "Fuzzy Logic and the Human Brain").
- Add subheadings for clarity.
- Keep paragraphs short for readability.
- Maintain humor and relatable analogies to engage readers.
*Feel free to adjust this draft as needed!*
---
**Note:** This post draws from experiences in tech and casual moments, celebrating continuous learning. Cheers! 🚀
<|end_of_solution|>

View File

@ -86,7 +86,7 @@ class OllamaGenerator:
'''Get embeddings for the draft chunks''' '''Get embeddings for the draft chunks'''
embeds = self.ollama_client.embed(model=self.embed_model, input=draft_chunks) embeds = self.ollama_client.embed(model=self.embed_model, input=draft_chunks)
return embeds.get('embeddings', []) return embeds.get('embeddings', [])
def id_generator(self, size=6, chars=string.ascii_uppercase + string.digits): def id_generator(self, size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size)) return ''.join(random.choice(chars) for _ in range(size))
@ -155,7 +155,7 @@ class OllamaGenerator:
def generate_commit_message(self): def generate_commit_message(self):
prompt_system = "You are a blog creator commiting a piece of content to a central git repo" 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),] messages = [("system", prompt_system), ("human", prompt_human),]
commit_message = self.llm.invoke(messages).text() commit_message = self.llm.invoke(messages).text()
return commit_message return commit_message

View File

@ -1,4 +1,5 @@
import os, shutil import os, shutil
from urllib.parse import quote
from git import Repo from git import Repo
from git.exc import GitCommandError from git.exc import GitCommandError
@ -10,8 +11,15 @@ class GitRepository:
def __init__(self, repo_path, username=None, password=None): def __init__(self, repo_path, username=None, password=None):
git_protocol = os.environ["GIT_PROTOCOL"] git_protocol = os.environ["GIT_PROTOCOL"]
git_remote = os.environ["GIT_REMOTE"] git_remote = os.environ["GIT_REMOTE"]
#TODO: Parse the URL correctly https://stackoverflow.com/questions/1695183/how-can-i-percent-encode-url-parameters-in-python #if username is not set we don't need parse to the url
remote = f"{git_protocol}://{username}:{password}@{git_remote}" 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): if os.path.exists(repo_path):
shutil.rmtree(repo_path) shutil.rmtree(repo_path)
@ -20,6 +28,8 @@ class GitRepository:
self.repo = Repo(repo_path) self.repo = Repo(repo_path)
self.username = username self.username = username
self.password = password self.password = password
self.repo.config_writer().set_value("user", "name", "blog_creator")
self.repo.config_writer().set_value("user", "email", "ridgway.infrastructure@gmail.com")
def clone(self, remote_url, destination_path): def clone(self, remote_url, destination_path):
"""Clone a Git repository with authentication""" """Clone a Git repository with authentication"""
@ -57,7 +67,7 @@ class GitRepository:
"""Create a new branch in the repository with authentication.""" """Create a new branch in the repository with authentication."""
try: try:
# Use the same remote and ref as before # Use the same remote and ref as before
self.repo.git.branch(branch_name, commit=True) self.repo.git.branch(branch_name)
return True return True
except GitCommandError as e: except GitCommandError as e:
print(f"Failed to create branch: {e}") print(f"Failed to create branch: {e}")
@ -73,7 +83,7 @@ class GitRepository:
commit_message = "Added and committed new content" commit_message = "Added and committed new content"
else: else:
commit_message = message commit_message = message
self.repo.git.commit(commit_message=commit_message) self.repo.git.commit(message=commit_message)
return True return True
except GitCommandError as e: except GitCommandError as e:
print(f"Commit failed: {e}") print(f"Commit failed: {e}")
@ -84,9 +94,9 @@ class GitRepository:
shutil.copy(f"{file_path}", f"{self.repo_path}src/content/") 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): def remove_repo(self):
shutil.rmtree(self.repo_path) shutil.rmtree(self.repo_path)