Skip to content

Commit

Permalink
update Openai API call method (#27628)
Browse files Browse the repository at this point in the history
Co-authored-by: 张兴言 <SENSETIME\[email protected]>
  • Loading branch information
Strive-for-excellence and 张兴言 authored Nov 22, 2023
1 parent 7f6a804 commit 8aca43b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformers/tools/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8aca43b

Please sign in to comment.