From 8aca43bdb3cb9a5020f6d57589d85679dc873b1c Mon Sep 17 00:00:00 2001 From: Strive-for-excellence <1505656319@qq.com> Date: Thu, 23 Nov 2023 00:28:27 +0800 Subject: [PATCH] update Openai API call method (#27628) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 张兴言 --- src/transformers/tools/agents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transformers/tools/agents.py b/src/transformers/tools/agents.py index 51e3f6db0c25a3..3e423ebb30556d 100644 --- a/src/transformers/tools/agents.py +++ b/src/transformers/tools/agents.py @@ -440,13 +440,13 @@ def generate_one(self, prompt, stop): return self._completion_generate([prompt], stop)[0] def _chat_generate(self, prompt, stop): - result = openai.ChatCompletion.create( + result = openai.chat.completions.create( model=self.model, messages=[{"role": "user", "content": prompt}], temperature=0, stop=stop, ) - return result["choices"][0]["message"]["content"] + return result.choices[0].message.content def _completion_generate(self, prompts, stop): result = openai.Completion.create(