#gpt-3.5-turbo isn't working for my bot

18 messages · Page 1 of 1 (latest)

drifting ice
#

it used to work with davinci 003, but as soon as i replaced the model with gpt-3.5-turbo, it has stopped working completely and gives me this error. i have been trying for a while to fix it but i'm not good with python and the error doesn't really make sense to me

openai.error.InvalidRequestError: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?

naive sequoia
tame cove
#

Ya you can't just flip models. You need to update openai, then you need to check the docs and change the format. It doesn't just accept a prompt now, it needs you to send it an array.

oblique sedge
#

This works for me:

const fetch = require("node-fetch");

const OPENAI_API_KEY = YOUR_API_KEY;

async function chatgptCompletion() {
const requestOptions = {
method: "POST",
headers: {
Authorization: Bearer ${OPENAI_API_KEY},
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: "What is the OpenAI mission?" }],
}),
};

fetch("https://api.openai.com/v1/chat/completions", requestOptions)
.then((response) => response.json())
.then((result) => console.log(result.choices[0]))
.catch((error) => console.log("error", error));
}

chatgptCompletion();

silver lynx
#

^^ Yup, you can't just flip models

vernal jacinth
#

in python, after defined openai.api_endpoint = "https://api.openai.com/v1/chat/completions", and using "gpt-3.5-turbo", still keep getting "openai.error.InvalidRequestError: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?"

#

import openai
import os

import openai
import os

openai.api_key = os.environ["OPENAI_API_KEY"]
openai.api_endpoint = os.environ.get("OPENAI_API_ENDPOINT", "https://api.openai.com")

#model_engine = "text-codex-002"
model_engine = "code-davinci-edit-001"
model_engine = "babbage-code-search-text"
model_engine = "gpt-3.5-turbo"
openai.api_endpoint = "https://api.openai.com/v1/chat/completions"

prompt = 'generate go code:\npackage main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println("Hello, world!")\n}\n\n'

response = openai.Completion.create(
engine=model_engine,
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.7,
)

choices = response.choices[0].text.strip().split('\n')
print(choices[0])

#

anything wrong here?

#

i am trying those models fetched from model list, none of them worked so far

tribal beacon
#

Use the openai.ChatCompletion function instead.
Also instead of choices[0].text it'll be choices[0].content

#

@vernal jacinth

#

@drifting ice your problem is likely the same as James'. There's a difference between "Completion" and "ChatCompletion"

vernal jacinth
#

Traceback (most recent call last):
File "/Users/jamesqu/mydev/openai/python/codex.go.hello.py", line 15, in <module>
response = openai.ChatCompletion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/openai/api_resources/chat_completion.py", line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/openai/api_requestor.py", line 226, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/openai/api_requestor.py", line 620, in _interpret_response
self._interpret_response_line(
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/openai/api_requestor.py", line 683, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: Invalid URL (POST /v1/engines/code-davinci-edit-001/chat/completions)

#

this time, got Invalid URL error for those models tried so far

#

think one step forward

silver lynx
#

This is a very old request

#

Use openai.ChatCompletion