mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-25 20:12:39 +00:00
[U] openai migrate
This commit is contained in:
parent
01d7cdc7de
commit
36c1b1e0dd
@ -3,7 +3,9 @@ import argparse
|
|||||||
import shlex
|
import shlex
|
||||||
from subprocess import check_call, check_output
|
from subprocess import check_call, check_output
|
||||||
|
|
||||||
import openai
|
from openai import OpenAI
|
||||||
|
|
||||||
|
client = OpenAI()
|
||||||
# Readline is used to fix left/right arrow keys in input(), do not remove as unused
|
# Readline is used to fix left/right arrow keys in input(), do not remove as unused
|
||||||
import readline
|
import readline
|
||||||
|
|
||||||
@ -26,8 +28,7 @@ def gen_merge_msg(commits: str):
|
|||||||
openai_prompt = ("I just merged the following branch, what commit message can best summarize the changes below? "
|
openai_prompt = ("I just merged the following branch, what commit message can best summarize the changes below? "
|
||||||
"Please make sure it is less than 100 characters long.\n\n")
|
"Please make sure it is less than 100 characters long.\n\n")
|
||||||
|
|
||||||
complete = openai.ChatCompletion.create(
|
complete = client.chat.completions.create(model="gpt-4",
|
||||||
model="gpt-4",
|
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system",
|
{"role": "system",
|
||||||
"content": "You are a senior software engineer helping with maintaining a game server repository."},
|
"content": "You are a senior software engineer helping with maintaining a game server repository."},
|
||||||
@ -37,8 +38,7 @@ def gen_merge_msg(commits: str):
|
|||||||
"content": f'"{openai_example_response}"'},
|
"content": f'"{openai_example_response}"'},
|
||||||
{"role": "user",
|
{"role": "user",
|
||||||
"content": f"{openai_prompt}{commits}"},
|
"content": f"{openai_prompt}{commits}"},
|
||||||
]
|
])
|
||||||
)
|
|
||||||
|
|
||||||
m = complete.choices[0].message.content
|
m = complete.choices[0].message.content
|
||||||
return m.strip().strip('"')
|
return m.strip().strip('"')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user