From 6159e096d35fc589ccad2cf757ff16a83fa5d5a5 Mon Sep 17 00:00:00 2001 From: platisd Date: Thu, 9 May 2024 21:16:18 +0200 Subject: [PATCH] Migrate to OpenAI v1 library The new one is much better anyway... --- autofill_description.py | 8 +++----- requirements.txt | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/autofill_description.py b/autofill_description.py index 265ac50..bf8dc11 100755 --- a/autofill_description.py +++ b/autofill_description.py @@ -103,9 +103,7 @@ def main(): model_sample_response = os.environ.get( "INPUT_MODEL_SAMPLE_RESPONSE", GOOD_SAMPLE_RESPONSE ) - completion_prompt = os.environ.get( - "INPUT_COMPLETION_PROMPT", COMPLETION_PROMPT - ) + completion_prompt = os.environ.get("INPUT_COMPLETION_PROMPT", COMPLETION_PROMPT) authorization_header = { "Accept": "application/vnd.github.v3+json", "Authorization": "token %s" % github_token, @@ -177,8 +175,8 @@ def main(): if len(completion_prompt) > max_allowed_characters: completion_prompt = completion_prompt[:max_allowed_characters] - openai.api_key = openai_api_key - openai_response = openai.ChatCompletion.create( + openai_client = openai.OpenAI(api_key=openai_api_key) + openai_response = openai_client.chat.completions.create( model=open_ai_model, messages=[ { diff --git a/requirements.txt b/requirements.txt index 74a8950..574708b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ requests>=2.18 -openai==0.27.2 +openai==1.27.0