Skip to content

Commit

Permalink
Migrate to OpenAI v1 library
Browse files Browse the repository at this point in the history
  • Loading branch information
platisd committed May 9, 2024
1 parent d1aa0a3 commit c2ac01f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions autofill_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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=[
{
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests>=2.18
openai==0.27.2
openai==1.27.0

0 comments on commit c2ac01f

Please sign in to comment.