I am executing all the commands in the course kernel . However ran into a blocker in Module 1 and Lesson 9 where print_llm_response is not working throwing the below error
print_llm_response(“What is the capital of France?”)
---------------------------------------------------------------------------
NotFoundError Traceback (most recent call last)
Cell In[4], 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.<locals>.inner.<locals>.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: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}
AI chatbot replies this error as below.
The error means the model name you asked for has been removed (deprecated). Fix by using a current model name and (if needed) updating the OpenAI Python package.
Steps to fix
- Change the model string from “gpt-3.5-turbo-0125” to a supported name, e.g. “gpt-3.5-turbo” or “gpt-3.5-turbo-0613”.
- Upgrade the openai package and restart your Python kernel if you changed packages.
Minimal code change (your existing call—only model changed):
However, I cannot make the changes and blocked . So, can someone please help to unblock this