diff --git a/gpt_gpt.py b/gpt_gpt.py index 0d1743d..f806c37 100644 --- a/gpt_gpt.py +++ b/gpt_gpt.py @@ -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], diff --git a/gpt_opt.py b/gpt_opt.py index b188288..d73d497 100644 --- a/gpt_opt.py +++ b/gpt_opt.py @@ -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")