L4: Q & A error: `text-davinci-003` was deprecated on 4 Jan


When running this line of the L4-QnA notebook:
response = index.query(query)

I get an error:
InvalidRequestError: The model text-davinci-003 has been deprecated

Is there an easy way to modify the old code so that the error is fixed?

Thank you,

1 Like

Hi @EgNLP,

Are you running the notebook on the platform or locally ?

I just checked, it is on the platform as well. This has been reported to the team, thanks for pointing it out.

As of now, at least I, don’t know the workaround. I’ll let you know as soon as I know.

Hi EgNLP, the issue appears to have been resolved. try pip install --upgrade langchain. I updated around 10 EST (30 minutes ago) and the error cleared.

Running local.


Hi @EgNLP, I also had the same error :sweat_smile:.

I solved the problem by manually creating an llm instance and passing it to the query method, forcing the query engine to use my model:

llm = ChatOpenAI(temperature = 0.0, model=llm_model) # define the model explicitly
response = index.query(query, llm=llm)`

where “llm_model” was already defined at the beginning of the notebook by th following block

# Set the model variable based on the current date
if current_date > target_date:
    llm_model = "gpt-3.5-turbo"
    llm_model = "gpt-3.5-turbo-0301"

I think you can replicate the idea using other models than ChatOpenAI or other versions (such as “gpt-4”) but I haven’t tried yet.


Hi Mubsi,

I was running the notebook on the platform. So it’s about the platform of course.


Thanks Chuckm, but the issue is with the platform.


Thank you, rigleonecoder

I think this is the solution.

What I had noticed even before but forgot to include in my inquiry is that the penultimate line of the notebook is exactly like you wrore:
response = index.query(query, llm=llm)
and it worked well in that instance.

So now we know that the key was including llm=llm in it.


This worked out well.

This works. Thanks

P.S. at the time I’m using, i use model “gpt-3.5-turbo-0125”