Created
March 3, 2024 20:44
-
-
Save namgivu/e2e207dc5913e66ac605b684d6d95b1f to your computer and use it in GitHub Desktop.
convert legacy ChatComplete syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# before | |
completions = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=[ | |
{"role": "system", "content": prompt}, | |
], | |
temperature=0.4, | |
max_tokens=999, | |
) | |
res = completions['choices'][0]['message']['content'] | |
# after | |
completions = client.chat.completions.create( | |
model="gpt-3.5-turbo", | |
messages=[ | |
{"role": "system", "content": prompt}, | |
], | |
temperature=0.4, | |
max_tokens=999, | |
) | |
res = completions.choices[0].message.content | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment