Update code to openai 1.0 api

pull/7/head
Daniel Bornkessel 2023-11-16 12:27:50 +01:00
rodzic 5db883be5c
commit cde981285a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: D3AC158CC5C98052
2 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -116,7 +116,10 @@ def chatgpt(context):
messages.append({"role": "user", "content": "Please provide me with Blender (3D software) python code satisfying the following task: " +
prompts[lan] + ". \n. Do not provide with anything that is not Python code. Do not provide explanations and comments."})
response = openai.ChatCompletion.create(
client = openai.OpenAI(
api_key = context.preferences.addons["blender-gpt"].preferences.openai_key,
)
response = client.chat.completions.create(
model=models[lan],
messages=messages,
temperature=temperatures[lan],

Wyświetl plik

@ -95,9 +95,9 @@ class BLENDERGPT_OT_SEND_MSG(Operator):
# TODO: connect to GPT
prf = context.preferences
openai.api_key = prf.addons["blender-gpt"].preferences.openai_key
openai_api_key = prf.addons["blender-gpt"].preferences.openai_key
if not openai.api_key:
if not openai_api_key:
if int(context.scene.lan) == 0:
self.report(
{'ERROR'}, "錯誤: 沒有偵測到 OPENAI API Key請在插件設定中設定 OPENAI API Key")