Closed Christopherliiii closed 1 year ago
@Christopherliiii All necessary changes related on the engines's model are made in the script chatBot/bot.py
.
If you want to use the model "gpt-3.5-turbo" or "gpt-3.5-turbo-0301", change the code of the bot.py to this version:
import openai
from dotenv import load_dotenv
import os
import sys
# MODELS:
# text-curie-001
# text-babbage-001
# text-ada-001
# text-davinci-003
# text-davinci-002
# text-davinci-001
# davinci-instruct-beta
# davinci
# curie-instruct-beta
# curie
# babbage
# ada
# gpt-3.5-turbo
# gpt-3.5-turbo-0301
def bot(prompt):
load_dotenv()
openai.api_key = os.environ["OPENAI_API_KEY"]
model = "gpt-3.5-turbo-0301"
if "turbo" in model:
completion = openai.ChatCompletion.create(
model = model,
messages = [{"role": "user", "content": prompt}]
)
return str(completion.choices[0]).split("content")[1][6:].split("role")[0][:-1].replace('\\n', '\n')[:-7].encode('utf-8').decode('unicode_escape')
else:
completions = openai.Completion.create(
engine = model,
prompt = prompt,
max_tokens = 1024,
n = 1,
temperature = 0.5,
)
response = completions.choices[0].text
return response
def main():
print(bot(sys.argv[1]))
return bot(sys.argv[1])
if __name__ == '__main__':
main()
You'll find a list of the models and their descriptions in this url: https://platform.openai.com/docs/models/gpt-3-5
General code has been upgraded to include the "gpt-3.5-turbo" and "gpt-3.5-turbo-0301" models.
The model "gpt-3.5-turbo-0301" has been implemented in the code. It will only be supported for a three month period ending on June 1st 2023.
It seems the output of the bot response format is not utf-8 friendly so I will try to change that
Unicode escape sequences redirected to utf-8.
Thank you very much!!!
This api version of the chatBot linked is text-davinci-003,how can I change it to the gpt-3.5-turbo?Its necessary?Thank U !