Преглед на файлове

Chore: Improve error handling and model selection

This commit enhances the `ai-commit.sh` script by adding checks
for the existence of necessary Git configuration files
(`.gitconfig` and `.git-credentials`). This prevents the script
from running without proper Git configuration, improving the user
experience by providing informative error messages.

Additionally, updates the `git_commit_ai.py` to utilize
`gemini-2.0-flash` to improve model selection and potential
performance.
seno преди 6 дни
родител
ревизия
1dc3137814
променени са 2 файла, в които са добавени 13 реда и са изтрити 4 реда
  1. 11 0
      ai-commit.sh
  2. 2 4
      git_commit_ai.py

+ 11 - 0
ai-commit.sh

@@ -1,5 +1,16 @@
 #!/bin/bash
 
+# Check for required Git configuration files
+if [ ! -f "$HOME/.gitconfig" ]; then
+    >&2 echo "Error: Git configuration file not found at $HOME/.gitconfig"
+    exit 1
+fi
+
+if [ ! -f "$HOME/.git-credentials" ]; then
+    >&2 echo "Error: Git credentials file not found at $HOME/.git-credentials"
+    exit 1
+fi
+
 docker run --rm -it \
 	-v "$(pwd):/repo" \
 	-v "$HOME/.gitconfig:/home/appuser/.gitconfig:ro" \

+ 2 - 4
git_commit_ai.py

@@ -93,12 +93,10 @@ def generate_commit_message(diff, gemini_api_key):
 
     genai.configure(api_key=gemini_api_key)
     # Use the intended model name
-    model = genai.GenerativeModel("gemini-1.5-flash")
-
-    project_files_list = get_project_files()
+    model = genai.GenerativeModel("gemini-2.0-flash")
 
     # Define prompt as a regular string, not f-string, placeholders will be filled by .format()
-    prompt = f"""
+    prompt = """
     You are an expert assistant that generates Git commit messages following conventional commit standards.
     Analyze the following diff of staged files and generate ONLY the commit message (subject and body) adhering to standard Git conventions.