Skip to content

Commit 5446487

Browse files
committed
Refactor OpenAI integration in release notes generator script
1 parent fbd90bf commit 5446487

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scripts/generate_release_notes.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import sys
22
import os
3-
import openai
43
import json
4+
from openai import OpenAI
55

6-
openai.api_key = os.getenv("OPENAI_API_KEY")
6+
# Setup OpenAI client with API Key
7+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
78

89
# PR data passed from workflow
910
pr_data = json.loads(sys.argv[1])
@@ -19,10 +20,12 @@
1920
for pr in pr_data:
2021
prompt += f"- Title: {pr['title']}\n Description: {pr['body']}\n Link: {pr['url']}\n\n"
2122

22-
response = openai.ChatCompletion.create(
23+
response = client.chat.completions.create(
2324
model="gpt-4o",
24-
messages=[{"role": "system", "content": "You generate release notes in markdown."},
25-
{"role": "user", "content": prompt}],
25+
messages=[
26+
{"role": "system", "content": "You generate release notes in markdown."},
27+
{"role": "user", "content": prompt}
28+
],
2629
temperature=0.3
2730
)
2831

0 commit comments

Comments
 (0)