-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathsummary.py
More file actions
38 lines (30 loc) · 1.29 KB
/
Copy pathsummary.py
File metadata and controls
38 lines (30 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from config import config
from git_utils import get_two_weeks_commits
def generate_smart_summary():
commits = get_two_weeks_commits(return_output=True)
if not commits:
return
# Check if OpenAI API key is set
openai_api_key = config.get('DEFAULT', 'OPENAI_API_KEY', fallback=None)
if not openai_api_key:
print("OpenAI API key not set. Skipping AI summary generation.")
return
# Dynamically import openai only if API key is present
try:
import openai
except ImportError:
print("OpenAI package not installed. Please install it using: pip install openai")
return
openai.api_key = openai_api_key
try:
response = openai.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant that summarizes git commits. Provide a concise, well-organized summary of the main changes and themes."},
{"role": "user", "content": f"Please summarize these git commits in a clear, bulleted format:\n\n{commits}"}
]
)
print("\n📋 AI-Generated Summary of Recent Changes:\n")
print(response.choices[0].message.content)
except Exception as e:
print(f"Error generating AI summary: {e}")