Skip to content

Commit 0e2ddca

Browse files
committed
logging
1 parent a7903c1 commit 0e2ddca

File tree

6 files changed

+23
-88
lines changed

6 files changed

+23
-88
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,7 @@ cython_debug/
163163

164164
.idea/
165165
.vscode/
166+
167+
168+
# Testing files
169+
gitdiff.txt

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 76 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ This blueprint guides you to easily generate AI-powered git commit messages base
4646
ollama pull llama3.1
4747
```
4848

49-
4. Make changes to your git repo and run:
49+
4. After adding your changes to your git repo, run:
5050

5151
```bash
5252
lcg

src/blueprint/ai_service.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""AI Service module for interacting with different LLM providers."""
22

3-
import os
4-
from typing import Dict, Optional
3+
from typing import Optional
54

65
import requests
76

7+
JAN_BASE_URL = "http://localhost:1337/v1/chat/completions"
8+
OLLAMA_BASE_URL = "http://localhost:11434/api/generate"
9+
810

911
class AIService:
1012
"""Service for interacting with different AI providers."""
@@ -21,8 +23,8 @@ def __init__(self, service_type: str, model: Optional[str] = None):
2123

2224
# Set up base URLs for services
2325
self.base_urls = {
24-
"ollama": "http://localhost:11434/api/generate",
25-
"jan": "http://localhost:1337/v1/chat/completions",
26+
"ollama": OLLAMA_BASE_URL,
27+
"jan": JAN_BASE_URL,
2628
}
2729

2830
if service_type not in self.base_urls:

src/blueprint/cli.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
create_commit,
1313
)
1414

15+
DEFAULT_OLLAMA_MODEL = "llama3.1"
16+
DEFAULT_JAN_MODEL = "llama3.1-8b-instruct"
17+
1518

1619
def main():
1720
"""Main entry point for the CLI application."""
18-
OLLAMA_MODEL = os.getenv("OLLAMA_MODEL", "llama3.1")
19-
JAN_MODEL = os.getenv("JAN_MODEL", "llama 3.1")
21+
OLLAMA_MODEL = os.getenv("OLLAMA_MODEL", DEFAULT_OLLAMA_MODEL)
22+
JAN_MODEL = os.getenv("JAN_MODEL", DEFAULT_JAN_MODEL)
2023

2124
parser = argparse.ArgumentParser(
2225
description="Generate git commit messages using LLMs."
@@ -67,7 +70,7 @@ def main():
6770

6871
# Show analytics if requested
6972
if args.analytics:
70-
print(f"\nAnalytics:")
73+
print("\nAnalytics:")
7174
print(
7275
f"Time taken to generate commit messages: {end_time - start_time:.2f} seconds"
7376
)
@@ -101,7 +104,7 @@ def main():
101104
end_time = time.time()
102105

103106
if args.analytics:
104-
print(f"\nRegeneration Analytics:")
107+
print("\nRegeneration Analytics:")
105108
print(
106109
f"Time taken to regenerate commit messages: {end_time - start_time:.2f} seconds"
107110
)

src/blueprint/commit_generator.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""Git commit message generator using AI models."""
22

3-
import os
43
import subprocess
54
import sys
6-
import time
75
from typing import List, Optional
86

97
from blueprint.ai_service import AIService
@@ -73,7 +71,11 @@ def parse_commit_messages(response: str) -> List[str]:
7371
messages = []
7472
for line in response.split("\n"):
7573
if line.strip().startswith(("1.", "2.", "3.")):
76-
messages.append(line.split(".", 1)[1].strip())
74+
message = line.split(".", 1)[1].strip()
75+
# Strip surrounding single quotes if present
76+
if message.startswith("'") and message.endswith("'"):
77+
message = message[1:-1]
78+
messages.append(message)
7779
return messages
7880

7981

0 commit comments

Comments
 (0)