Depcrecated model model="gpt-3.5-turbo-0125" used in lesson 9

I am getting error running print_llm_response(“What is the capital of France?”) in lesson 9 as second step in dl-ai-learning-platform. the error reports as follows

NotFoundError: Error code: 404 - {'error': {'message': 'The model `gpt-3.5-turbo-0125` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}

How can i change the model version ? i cannot find any file to edit to model version like helper_functions.py

Hello @Mubsi could you please look into this issue? I believe the scripts may need to be updated to account for the deprecated GPT versions. Thank you!

Here’s a brief explanation you can use:

To fix the 404 model_not_found error caused by the removal of gpt-3.5-turbo-0125, first search for the new model on the OpenAI deprecations page:

Then, in your helper_functions.py file:

  • Replace the model ID "gpt-3.5-turbo-0125" with the new model "gpt-5.6-terra" (make sure you spell it exactly as shown).
  • Change the value of the temperature parameter to 1.

and restart the kernel

This will update your code to use the current model and set the desired temperature, fixing the error.

@Ayoub_Batrich how am I doing this? Or have you been referring to @gent.spah to do this? I’m also getting the same error still (8 hours later):

`` NotFoundError Traceback (most recent call last)
Cell In[2], line 1
----> 1 print_llm_response(“What is the capital of France?”)

File ~/work/L9/helper_functions.py:21, in print_llm_response(prompt)
17 def print_llm_response(prompt):
18 “”“This function takes as input a prompt, which must be a string enclosed in quotation marks,
19 and passes it to OpenAI’s GPT3.5 model. The function then prints the response of the model.
20 “””
—> 21 llm_response = get_llm_response(prompt)
22 print(llm_response)

File ~/work/L9/helper_functions.py:33, in get_llm_response(prompt)
31 if not isinstance(prompt, str):
32 raise ValueError(“Input must be a string enclosed in quotes.”)
—> 33 completion = client.chat.completions.create(
34 model=“gpt-3.5-turbo-0125”,
35 messages=[
36 {
37 “role”: “system”,
38 “content”: “You are a helpful but terse AI assistant who gets straight to the point.”,
39 },
40 {“role”: “user”, “content”: prompt},
41 ],
42 temperature=0.0,
43 )
44 response = completion.choices[0].message.content
45 return response

File /usr/local/lib/python3.9/site-packages/openai/_utils/_utils.py:277, in required_args..inner..wrapper(*args, **kwargs)
275 msg = f"Missing required argument: {quote(missing[0])}"
276 raise TypeError(msg)
→ 277 return func(*args, **kwargs)

File /usr/local/lib/python3.9/site-packages/openai/resources/chat/completions.py:590, in Completions.create(self, messages, model, frequency_penalty, function_call, functions, logit_bias, logprobs, max_tokens, n, presence_penalty, response_format, seed, stop, stream, stream_options, temperature, tool_choice, tools, top_logprobs, top_p, user, extra_headers, extra_query, extra_body, timeout)
558 @required_args([“messages”, “model”], [“messages”, “model”, “stream”])
559 def create(
560 self,
(…)
588 timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
589 ) → ChatCompletion | Stream[ChatCompletionChunk]:
→ 590 return self._post(
591 “/chat/completions”,
592 body=maybe_transform(
593 {
594 “messages”: messages,
595 “model”: model,
596 “frequency_penalty”: frequency_penalty,
597 “function_call”: function_call,
598 “functions”: functions,
599 “logit_bias”: logit_bias,
600 “logprobs”: logprobs,
601 “max_tokens”: max_tokens,
602 “n”: n,
603 “presence_penalty”: presence_penalty,
604 “response_format”: response_format,
605 “seed”: seed,
606 “stop”: stop,
607 “stream”: stream,
608 “stream_options”: stream_options,
609 “temperature”: temperature,
610 “tool_choice”: tool_choice,
611 “tools”: tools,
612 “top_logprobs”: top_logprobs,
613 “top_p”: top_p,
614 “user”: user,
615 },
616 completion_create_params.CompletionCreateParams,
617 ),
618 options=make_request_options(
619 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
620 ),
621 cast_to=ChatCompletion,
622 stream=stream or False,
623 stream_cls=Stream[ChatCompletionChunk],
624 )

File /usr/local/lib/python3.9/site-packages/openai/_base_client.py:1240, in SyncAPIClient.post(self, path, cast_to, body, options, files, stream, stream_cls)
1226 def post(
1227 self,
1228 path: str,
(…)
1235 stream_cls: type[_StreamT] | None = None,
1236 ) → ResponseT | _StreamT:
1237 opts = FinalRequestOptions.construct(
1238 method=“post”, url=path, json_data=body, files=to_httpx_files(files), **options
1239 )
→ 1240 return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))

File /usr/local/lib/python3.9/site-packages/openai/_base_client.py:921, in SyncAPIClient.request(self, cast_to, options, remaining_retries, stream, stream_cls)
912 def request(
913 self,
914 cast_to: Type[ResponseT],
(…)
919 stream_cls: type[_StreamT] | None = None,
920 ) → ResponseT | _StreamT:
→ 921 return self._request(
922 cast_to=cast_to,
923 options=options,
924 stream=stream,
925 stream_cls=stream_cls,
926 remaining_retries=remaining_retries,
927 )

File /usr/local/lib/python3.9/site-packages/openai/_base_client.py:1020, in SyncAPIClient._request(self, cast_to, options, remaining_retries, stream, stream_cls)
1017 err.response.read()
1019 log.debug(“Re-raising status error”)
→ 1020 raise self._make_status_error_from_response(err.response) from None
1022 return self._process_response(
1023 cast_to=cast_to,
1024 options=options,
(…)
1027 stream_cls=stream_cls,
1028 )

NotFoundError: Error code: 404 - {‘error’: {‘message’: 'The model gpt-3.5-turbo-0125 has been deprecated, learn more here: `` Deprecations | OpenAI API ', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}

hello

In the helper_functions.py file, which is located in Menu ===> Open ==> Working Folder ===> helper_functions.py

In this file (helper_functions.py), replace the model name gpt-3.5-turbo-0125 with the new model, which you can find on the website:

On that site, search for the deprecated model: gpt-3.5-turbo-0125, and you’ll find the new model you need to replace it with. I found that the new model is gpt-5.6-terra
Then, in the same file, set the temperature parameter to 1 instead of 0.0

Save the file, return to the exercise, and reload the kernel so it takes the changes into account: Menu ===> Kernel ====> Restart and Clear Input

You’ll need to repeat this method every time you get the error message. Otherwise, to fix it permanently, you’ll need to add the model name to a general configuration file—that way, it’ll be resolved once and for all.

Don’t forget to make this change in the other functions in (helper_functions.py) that call the new model (print_llm_response, get_llm_response, get_chat_completion).

Translated with DeepL.com (free version)

Hi all,

I’m looking into this now. I’ll let you know when the updates have been made to the notebooks.

Hello everyone,

in the C1M2_Assignment of the AI Python for Beginners, module 2 course

I defined the variable book as requested :

python

book = {   "title": "To Kill a Mockingbird",   "author": "Harper Lee",   "on_shelf": False,   "borrower": "Arthur Dent",   "overdue": True,   "on_hold": False, }

But when I run the test command test_your_code.exercise_1(book), I get this error:

NameError: name 'book' is not defined

Even though I have clearly defined book before, can someone help me understand and fix this issue?

I have completed the whole course and passed all exams, this is the only one I have left to pass. Thank you very much for your help!

Please do not post off-topic replies.

You posted a new thread about this same topic, and your question was answered there (the cell type had been changed to Markdown, so your code was never being run).

@Mubsi any update on this? I changed the model as suggested by @Ayoub_Batrich , but I’m actually a bit confused, why nobody from deeplearning.ai is fixing this fundamental issue.

Hopefully you read Mubsi’s reply:

The issue is affecting multiple courses that use the same LLM. So it will take some time before all of the courses are updated.

Thank you. How and where will you notify us?

Expect a reply on this thread.

Hi all,

Tom mentioned a couple of things, all of which hold true.

Yes, this has affected multiple courses, and we are in middle of making changes to them.

Yes, I shall reply in this thread when the notebooks for AI Python for Beginners course are updated.

Hi @Deepender_Baloonie, @Ayoub_Batrich, @Thomas_Theodor_Meiwes, @doug4,

The labs have been updated and should work now.

Just to make sure you have the latest files, please be sure to get the “latest version” of them:

  1. Open the notebook and save it by clicking the :floppy_disk: icon on the left.
  2. Click the “three vertical dots” on the top right and click Restore Original Version.

Closing this thread now. If there are any issues, please create a new post. Thanks!