From cee2803d29e93b5f7764f08be7042a5752537aa7 Mon Sep 17 00:00:00 2001 From: Hamza Tahir Date: Tue, 24 Sep 2024 11:02:49 +0200 Subject: [PATCH] Added PR workflow --- scripts/generate_pr_description.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/generate_pr_description.py b/scripts/generate_pr_description.py index 0c718c4aae5..e373a740cfa 100644 --- a/scripts/generate_pr_description.py +++ b/scripts/generate_pr_description.py @@ -67,22 +67,19 @@ def generate_pr_description(): # Generate description using OpenAI openai.api_key = os.environ['OPENAI_API_KEY'] - response = openai.ChatCompletion.create( - model="gpt-3.5-turbo", + response = openai.OpenAI().chat.completions.create( + model="gpt-4o-mini", messages=[ {"role": "system", "content": "You are a helpful assistant that generates concise pull request descriptions based on changes to files."}, {"role": "user", "content": f"Generate a brief, informative pull request description based on these changes:\n\n{changes_text}"} ], - max_tokens=250 + max_tokens=1000 ) generated_description = response.choices[0].message['content'].strip() - # Replace the placeholder in the template with the generated description - updated_description = current_description.replace(default_template_indicator, generated_description) - # Update PR description - data = {'body': updated_description} + data = {'body': generated_description} requests.patch(api_url, json=data, headers=headers) print(f"Updated PR description with generated content") return True