Hey team,
noticing another model deprecation in L1_Router_Engine for the course: Building Agentic RAG with Llamaindex
Getting the following error Code after trying to run the first Query Engine
Retrying llama_index.llms.openai.base.OpenAI._chat in 0.2668917181231596 seconds as it raised NotFoundError: Error code: 404 - {'error': {'message': 'The model `gpt-3.5-turbo` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}.
Retrying llama_index.llms.openai.base.OpenAI._chat in 1.361193232893352 seconds as it raised NotFoundError: Error code: 404 - {'error': {'message': 'The model `gpt-3.5-turbo` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}.
Retrying llama_index.llms.openai.base.OpenAI._chat in 0.057395592527235806 seconds as it raised NotFoundError: Error code: 404 - {'error': {'message': 'The model `gpt-3.5-turbo` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}.
Retrying llama_index.llms.openai.base.OpenAI._chat in 6.479215397467871 seconds as it raised NotFoundError: Error code: 404 - {'error': {'message': 'The model `gpt-3.5-turbo` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}.
Retrying llama_index.llms.openai.base.OpenAI._chat in 5.056465519975079 seconds as it raised NotFoundError: Error code: 404 - {'error': {'message': 'The model `gpt-3.5-turbo` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}.
---------------------------------------------------------------------------
NotFoundError Traceback (most recent call last)
Cell In[11], line 1
----> 1 response = query_engine.query("What is the summary of the document?")
2 print(str(response))
File /usr/local/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py:274, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
270 self.span_enter(
271 id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
272 )
273 try:
--> 274 result = func(*args, **kwargs)
275 except BaseException as e:
276 self.event(SpanDropEvent(span_id=id_, err_str=str(e)))
File /usr/local/lib/python3.11/site-packages/llama_index/core/base/base_query_engine.py:53, in BaseQueryEngine.query(self, str_or_query_bundle)
51 if isinstance(str_or_query_bundle, str):
52 str_or_query_bundle = QueryBundle(str_or_query_bundle)
---> 53 query_result = self._query(str_or_query_bundle)
54 dispatch_event(QueryEndEvent())
55 return query_result
File /usr/local/lib/python3.11/site-packages/llama_index/core/query_engine/router_query_engine.py:169, in RouterQueryEngine._query(self, query_bundle)
165 def _query(self, query_bundle: QueryBundle) -> RESPONSE_TYPE:
166 with self.callback_manager.event(
167 CBEventType.QUERY, payload={EventPayload.QUERY_STR: query_bundle.query_str}
168 ) as query_event:
--> 169 result = self._selector.select(self._metadatas, query_bundle)
171 if len(result.inds) > 1:
172 responses = []
File /usr/local/lib/python3.11/site-packages/llama_index/core/base/base_selector.py:87, in BaseSelector.select(self, choices, query)
85 metadatas = [_wrap_choice(choice) for choice in choices]
86 query_bundle = _wrap_query(query)
---> 87 return self._select(choices=metadatas, query=query_bundle)
File /usr/local/lib/python3.11/site-packages/llama_index/core/selectors/llm_selectors.py:109, in LLMSingleSelector._select(self, choices, query)
106 choices_text = _build_choices_text(choices)
108 # predict
--> 109 prediction = self._llm.predict(
110 prompt=self._prompt,
111 num_choices=len(choices),
112 context_list=choices_text,
113 query_str=query.query_str,
114 )
116 # parse output
117 assert self._prompt.output_parser is not None
File /usr/local/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py:274, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
270 self.span_enter(
271 id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
272 )
273 try:
--> 274 result = func(*args, **kwargs)
275 except BaseException as e:
276 self.event(SpanDropEvent(span_id=id_, err_str=str(e)))
File /usr/local/lib/python3.11/site-packages/llama_index/core/llms/llm.py:430, in LLM.predict(self, prompt, **prompt_args)
428 if self.metadata.is_chat_model:
429 messages = self._get_messages(prompt, **prompt_args)
--> 430 chat_response = self.chat(messages)
431 output = chat_response.message.content or ""
432 else:
File /usr/local/lib/python3.11/site-packages/llama_index/core/llms/callbacks.py:144, in llm_chat_callback.<locals>.wrap.<locals>.wrapped_llm_chat(_self, messages, **kwargs)
128 dispatcher.event(
129 LLMChatStartEvent(
130 model_dict=_self.to_dict(),
(...)
134 )
135 )
136 event_id = callback_manager.on_event_start(
137 CBEventType.LLM,
138 payload={
(...)
142 },
143 )
--> 144 f_return_val = f(_self, messages, **kwargs)
146 if isinstance(f_return_val, Generator):
147 # intercept the generator and add a callback to the end
148 def wrapped_gen() -> ChatResponseGen:
File /usr/local/lib/python3.11/site-packages/llama_index/llms/openai/base.py:296, in OpenAI.chat(self, messages, **kwargs)
294 else:
295 chat_fn = completion_to_chat_decorator(self._complete)
--> 296 return chat_fn(messages, **kwargs)
File /usr/local/lib/python3.11/site-packages/tenacity/__init__.py:289, in BaseRetrying.wraps.<locals>.wrapped_f(*args, **kw)
287 @functools.wraps(f)
288 def wrapped_f(*args: t.Any, **kw: t.Any) -> t.Any:
--> 289 return self(f, *args, **kw)
File /usr/local/lib/python3.11/site-packages/tenacity/__init__.py:379, in Retrying.__call__(self, fn, *args, **kwargs)
377 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)
378 while True:
--> 379 do = self.iter(retry_state=retry_state)
380 if isinstance(do, DoAttempt):
381 try:
File /usr/local/lib/python3.11/site-packages/tenacity/__init__.py:325, in BaseRetrying.iter(self, retry_state)
323 retry_exc = self.retry_error_cls(fut)
324 if self.reraise:
--> 325 raise retry_exc.reraise()
326 raise retry_exc from fut.exception()
328 if self.wait:
File /usr/local/lib/python3.11/site-packages/tenacity/__init__.py:158, in RetryError.reraise(self)
156 def reraise(self) -> t.NoReturn:
157 if self.last_attempt.failed:
--> 158 raise self.last_attempt.result()
159 raise self
File /usr/local/lib/python3.11/concurrent/futures/_base.py:449, in Future.result(self, timeout)
447 raise CancelledError()
448 elif self._state == FINISHED:
--> 449 return self.__get_result()
451 self._condition.wait(timeout)
453 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
File /usr/local/lib/python3.11/concurrent/futures/_base.py:401, in Future.__get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
404 self = None
File /usr/local/lib/python3.11/site-packages/tenacity/__init__.py:382, in Retrying.__call__(self, fn, *args, **kwargs)
380 if isinstance(do, DoAttempt):
381 try:
--> 382 result = fn(*args, **kwargs)
383 except BaseException: # noqa: B902
384 retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type]
File /usr/local/lib/python3.11/site-packages/llama_index/llms/openai/base.py:362, in OpenAI._chat(self, messages, **kwargs)
360 client = self._get_client()
361 message_dicts = to_openai_message_dicts(messages)
--> 362 response = client.chat.completions.create(
363 messages=message_dicts,
364 stream=False,
365 **self._get_model_kwargs(**kwargs),
366 )
367 openai_message = response.choices[0].message
368 message = from_openai_message(openai_message)
File /usr/local/lib/python3.11/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.11/site-packages/openai/resources/chat/completions.py:581, in Completions.create(self, messages, model, frequency_penalty, function_call, functions, logit_bias, logprobs, max_tokens, n, presence_penalty, response_format, seed, stop, stream, temperature, tool_choice, tools, top_logprobs, top_p, user, extra_headers, extra_query, extra_body, timeout)
550 @required_args(["messages", "model"], ["messages", "model", "stream"])
551 def create(
552 self,
(...)
579 timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
580 ) -> ChatCompletion | Stream[ChatCompletionChunk]:
--> 581 return self._post(
582 "/chat/completions",
583 body=maybe_transform(
584 {
585 "messages": messages,
586 "model": model,
587 "frequency_penalty": frequency_penalty,
588 "function_call": function_call,
589 "functions": functions,
590 "logit_bias": logit_bias,
591 "logprobs": logprobs,
592 "max_tokens": max_tokens,
593 "n": n,
594 "presence_penalty": presence_penalty,
595 "response_format": response_format,
596 "seed": seed,
597 "stop": stop,
598 "stream": stream,
599 "temperature": temperature,
600 "tool_choice": tool_choice,
601 "tools": tools,
602 "top_logprobs": top_logprobs,
603 "top_p": top_p,
604 "user": user,
605 },
606 completion_create_params.CompletionCreateParams,
607 ),
608 options=make_request_options(
609 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
610 ),
611 cast_to=ChatCompletion,
612 stream=stream or False,
613 stream_cls=Stream[ChatCompletionChunk],
614 )
File /usr/local/lib/python3.11/site-packages/openai/_base_client.py:1232, in SyncAPIClient.post(self, path, cast_to, body, options, files, stream, stream_cls)
1218 def post(
1219 self,
1220 path: str,
(...)
1227 stream_cls: type[_StreamT] | None = None,
1228 ) -> ResponseT | _StreamT:
1229 opts = FinalRequestOptions.construct(
1230 method="post", url=path, json_data=body, files=to_httpx_files(files), **options
1231 )
-> 1232 return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
File /usr/local/lib/python3.11/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.11/site-packages/openai/_base_client.py:1012, in SyncAPIClient._request(self, cast_to, options, remaining_retries, stream, stream_cls)
1009 err.response.read()
1011 log.debug("Re-raising status error")
-> 1012 raise self._make_status_error_from_response(err.response) from None
1014 return self._process_response(
1015 cast_to=cast_to,
1016 options=options,
(...)
1019 stream_cls=stream_cls,
1020 )
NotFoundError: Error code: 404 - {'error': {'message': 'The model `gpt-3.5-turbo` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}
Can you please have a look into this.