Ungraded lab - M2_UGL_1 - model choice invalid

In the notebook, M2_UGL_1When I experiment with changing the generation or reflection model in the workflow, I get this error if I try to use ‘claude-3–7-sonnet’ for the reflection model:

PermissionDeniedError: Error code: 403 - {'error': {'message': 'using claude-3-7-sonnet is invalid'}}

What Claude models are available to try?

Looks like using “claude-3-7-sonnet-latest” as model name would work.

reflection_model=“claude-3-7-sonnet-latest” #“o4-mini”

@greenvinyl can you give it a try on your side?

1 Like

I had the same issue. On the notebook it says:

“Use a stronger reasoning model for reflection (gpt-4.1 or claude-3-7-sonnet).”

I tried with

reflection_model=“claude-3-7-sonnet”

and returned an error. The error included this page Model deprecations - Claude Docs

I tried with:

reflection_model=“claude-3-7-sonnet-latest”

and

reflection_model=“claude-3-7-sonnet-20250219”

and on both cases it worked alright.

1 Like

@hguan Thank you - both your suggestions worked fine.

1 Like

@Lluichi Thank you - both your suggestions worked for me too.

While changing the generation model from original “gpt-4o-mini” to “gpt-3.5-turbo” got the following error:

====
Step 2: Executing chart code (V1)… :laptop:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File /usr/local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key)
   3811 try:
-> 3812     return self._engine.get_loc(casted_key)
   3813 except KeyError as err:

File pandas/_libs/index.pyx:167, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/index.pyx:196, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:7088, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:7096, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'year'

The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)
Cell In[26], line 8
      5 image_basename="drink_sales"
      7 # Run the complete agentic workflow
----> 8 _ = run_workflow(
      9     dataset_path="coffee_sales.csv",
     10     user_instructions=user_instructions,
     11     generation_model=generation_model,
     12     reflection_model=reflection_model,
     13     image_basename=image_basename
     14 )

Cell In[23], line 41, in run_workflow(dataset_path, user_instructions, generation_model, reflection_model, image_basename)
     39     initial_code = match.group(1).strip()
     40     exec_globals = {"df": df}
---> 41     exec(initial_code, exec_globals)
     42 utils.print_html(out_v1, is_image=True, title="Generated Chart (V1)")
     44 # 3) Reflect on V1 (image + original code) to get feedback and refined code (V2)

File <string>:6

File /usr/local/lib/python3.11/site-packages/pandas/core/frame.py:4113, in DataFrame.__getitem__(self, key)
   4111 if self.columns.nlevels > 1:
   4112     return self._getitem_multilevel(key)
-> 4113 indexer = self.columns.get_loc(key)
   4114 if is_integer(indexer):
   4115     indexer = [indexer]

File /usr/local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3819, in Index.get_loc(self, key)
   3814     if isinstance(casted_key, slice) or (
   3815         isinstance(casted_key, abc.Iterable)
   3816         and any(isinstance(x, slice) for x in casted_key)
   3817     ):
   3818         raise InvalidIndexError(key)
-> 3819     raise KeyError(key) from err
   3820 except TypeError:
   3821     # If we have a listlike key, _check_indexing_error will raise
   3822     #  InvalidIndexError. Otherwise we fall through and re-raise
   3823     #  the TypeError.
   3824     self._check_indexing_error(key)

KeyError: 'year'
================

Need help

Welcome @Achint_Aggarwal! Try “gpt-3.5-turbo-0125” - I’ve just tested and it worked for me. Some gpt 3.5 models have been deprecated - I’m not sure if that is what is affecting this but hopefully this fixes it for you.

Got the same error.

I’m sorry but I’m not sure what else to suggest. I’m wondering if @hguan @Lluichi have any ideas?

Hi Achint_Aggarwal,

I get the same error messages. A plausible conclusion is that gpt-3.5-turbo is a less powerful coding model than gpt-4o-mini. So gpt-3.5-turbo may only be useful for initial code generation which needs to be debugged. This is currently still a common experience when using LLMs for coding.

@Achint_Aggarwal per the stacktrace, looks like the error is from LLM generated code execution. It will be helpful if the generated code is shared here.

btw: I agree with others shared, that different models have different coding capability therefore might generate code differently, sometimes with bugs. This seems to be one of those cases.