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

Hello,

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,
E

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.

Chuck

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"
else:
    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.

3 Likes

Hi Mubsi,

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

Thanks,
E

Thanks Chuckm, but the issue is with the platform.

E

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.

Best,
E

This worked out well.

This works. Thanks

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

Below code segment in L4-QnA

# account for deprecation of LLM model
import datetime
# Get the current date
current_date = datetime.datetime.now().date()

# Define the date after which the model should be set to “gpt-3.5-turbo”
target_date = datetime.date(2024, 6, 12)

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

sets llm_model to gpt-3.5-turbo

But with that
response for below question is coming blank


When llm model is change to “gpt-3.5-turbo-0301” its working fine

1 Like

Yes, i can confirm that this was my experience too. “gpt-3.5-turbo-0301” is the one giving useable outputs. Current code is generating a blank markdown response.