Hi, I am taking the M2_UGL_1 ungraded lab, for the last cell, when I changed the reflection_model to “claude-3-7-sonnet-latest“, and I got the error code as:
ConnectError: [Errno -2] Name or service not known
The above exception was the direct cause of the following exception:
Thank you for reporting this! Indeed, sonnet model was deprecated and we’re updating the notebooks! Anthropic’s Short Courses notebooks were updated from claude-3-7-sonnet-20250219 to claude-sonnet-4-6
I’ll check this with the team to update this Ungraded Lab for the Agentic AI course.
Here, insert your updates
user_instructions=“Create a plot comparing Q1 coffee sales in 2024 and 2025 using the data in coffee_sales.csv.” # write your instruction here
generation_model=“gpt-4o-mini”
reflection_model=“claude-sonnet-4-6”
image_basename=“drink_sales”
Run the complete agentic workflow
_ = run_workflow(
dataset_path=“coffee_sales.csv”,
user_instructions=user_instructions,
generation_model=generation_model,
reflection_model=reflection_model,
image_basename=image_basename
)
Unfortunately, I got the following error:
271 # Timedelta/Timestamp and other custom scalars are included in the check
272 # because numexpr will fail on it, see GH#31457
--> 273 res_values = op(left, right)
274 else:
275 # TODO we should handle EAs consistently and move this check before the if/else
276 # (https://github.com/pandas-dev/pandas/issues/41165)
277 # error: Argument 2 to "_bool_arith_check" has incompatible type
278 # "Union[ExtensionArray, ndarray[Any, Any]]"; expected "ndarray[Any, Any]"
279 _bool_arith_check(op, left, right) # type: ignore[arg-type]
TypeError: unsupported operand type(s) for +: 'DatetimeArray' and 'str'
It seems a type incompatible issue, would you mind take a look ?
Thanks for getting back to me on the weekend; I have appended the “Check operand type…” to the prompt; however, when I used “claude-sonnet-4-6“ as the reflection model, I still got the API connection error.
My code as:
# Here, insert your updates
user_instructions="Create a plot comparing Q1 coffee sales in 2024 and 2025 using the data in coffee_sales.csv. Check operand type to avoid any operand type errors " # write your instruction here
generation_model="gpt-4o-mini"
reflection_model="claude-sonnet-4-6"
image_basename="drink_sales"
# Run the complete agentic workflow
_ = run_workflow(
dataset_path="coffee_sales.csv",
user_instructions=user_instructions,
generation_model=generation_model,
reflection_model=reflection_model,
image_basename=image_basename
)
The error msg I got as:
---------------------------------------------------------------------------
ConnectError Traceback (most recent call last)
File /usr/local/lib/python3.11/site-packages/httpx/_transports/default.py:72, in map_httpcore_exceptions()
71 try:
---> 72 yield
73 except Exception as exc:
File /usr/local/lib/python3.11/site-packages/httpx/_transports/default.py:236, in HTTPTransport.handle_request(self, request)
235 with map_httpcore_exceptions():
--> 236 resp = self._pool.handle_request(req)
238 assert isinstance(resp.stream, typing.Iterable)
File /usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py:256, in ConnectionPool.handle_request(self, request)
255 self._close_connections(closing)
--> 256 raise exc from None
258 # Return the response. Note that in this case we still have to manage
259 # the point at which the response is closed.
File /usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py:236, in ConnectionPool.handle_request(self, request)
234 try:
235 # Send the request on the assigned connection.
--> 236 response = connection.handle_request(
237 pool_request.request
238 )
239 except ConnectionNotAvailable:
240 # In some cases a connection may initially be available to
241 # handle a request, but then become unavailable.
242 #
243 # In this case we clear the connection and try again.
File /usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py:101, in HTTPConnection.handle_request(self, request)
100 self._connect_failed = True
--> 101 raise exc
103 return self._connection.handle_request(request)
File /usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py:78, in HTTPConnection.handle_request(self, request)
77 if self._connection is None:
---> 78 stream = self._connect(request)
80 ssl_object = stream.get_extra_info("ssl_object")
File /usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py:124, in HTTPConnection._connect(self, request)
123 with Trace("connect_tcp", logger, request, kwargs) as trace:
--> 124 stream = self._network_backend.connect_tcp(**kwargs)
125 trace.return_value = stream
File /usr/local/lib/python3.11/site-packages/httpcore/_backends/sync.py:207, in SyncBackend.connect_tcp(self, host, port, timeout, local_address, socket_options)
202 exc_map: ExceptionMapping = {
203 socket.timeout: ConnectTimeout,
204 OSError: ConnectError,
205 }
--> 207 with map_exceptions(exc_map):
208 sock = socket.create_connection(
209 address,
210 timeout,
211 source_address=source_address,
212 )
File /usr/local/lib/python3.11/contextlib.py:158, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
157 try:
--> 158 self.gen.throw(typ, value, traceback)
159 except StopIteration as exc:
160 # Suppress StopIteration *unless* it's the same exception that
161 # was passed to throw(). This prevents a StopIteration
162 # raised inside the "with" statement from being suppressed.
File /usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py:14, in map_exceptions(map)
13 if isinstance(exc, from_exc):
---> 14 raise to_exc(exc) from exc
15 raise
ConnectError: [Errno -2] Name or service not known
Hi @xczhang07 thank you for testing again and reporting this seems to be a known issue which was reported to the team and the recommendation is to “improve the prompt” to make it specific about the date.
Let me talk to the team again, due to the model updates we might need a double check.
I will let you know when we have updates! Stay tuned!
can you post the detail response you just shared with me on how you resolved this issue with claude latest model version. I wanted you to respond here as you did the work, and didn’t wanted to take credit for.
The proxy URL configured in the notebook seems to be wrong, hence the Name or service not known error. Before calling run_workflow, run the following code:
@nramon Also suggested in order to have better generation of code the prompt part can be edited. I am sharing his response here
To fix it I changed the prompt in generate_chart_code from:
The code should create a visualization from a DataFrame 'df' with these columns:
- date (M/D/YY)
- time (HH:MM)
- cash_type (card or cash)
- card (string)
- price (number)
- coffee_name (string)
- quarter (1-4)
- month (1-12)
- year (YYYY)
To:
The code should create a visualization from a DataFrame 'df' with these columns:
{df.dtypes.to_string()}
The same can be done in reflect_on_image_and_regenerate
The M2_UGL_1 notebook has been updated (prompts updated to solve the issue)
Also, the note about reflection model using sonnet has been updated to the recommended version “claude-sonnet-4-6”