Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #7786

Open
Harshal292004 opened this issue Jan 15, 2025 · 0 comments
Open

Issue #7786

Harshal292004 opened this issue Jan 15, 2025 · 0 comments

Comments

@Harshal292004
Copy link

from litellm import completion
import os

os.environ["HUGGINGFACE_API_KEY"] = ""

response = completion(
model="huggingface/microsoft/phi-4",
messages=[{ "content": "Hello, how are you?","role": "user"}],
api_base="https://my-endpoint.huggingface.cloud"
)

print(response)

causes the below error :

you need to debug this error, use `litellm.set_verbose=True'.

---------------------------------------------------------------------------
ConnectError                              Traceback (most recent call last)
File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:101, in map_httpcore_exceptions()
     [89](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:89)         raise mapped_exc(message) from exc
     [92](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:92) HTTPCORE_EXC_MAP = {
     [93](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:93)     httpcore.TimeoutException: TimeoutException,
     [94](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:94)     httpcore.ConnectTimeout: ConnectTimeout,
     [95](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:95)     httpcore.ReadTimeout: ReadTimeout,
     [96](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:96)     httpcore.WriteTimeout: WriteTimeout,
     [97](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:97)     httpcore.PoolTimeout: PoolTimeout,
     [98](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:98)     httpcore.NetworkError: NetworkError,
     [99](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:99)     httpcore.ConnectError: ConnectError,
    [100](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:100)     httpcore.ReadError: ReadError,
--> [101](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:101)     httpcore.WriteError: WriteError,
    [102](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:102)     httpcore.ProxyError: ProxyError,
    [103](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:103)     httpcore.UnsupportedProtocol: UnsupportedProtocol,
    [104](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:104)     httpcore.ProtocolError: ProtocolError,
    [105](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:105)     httpcore.LocalProtocolError: LocalProtocolError,
    [106](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:106)     httpcore.RemoteProtocolError: RemoteProtocolError,
    [107](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:107) }
    [110](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:110) class ResponseStream(SyncByteStream):

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:250, in handle_request(self, request)
      [0](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:0) <Error retrieving source code with stack_data see ipython/ipython#13598>

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:256, in ConnectionPool.handle_request(self, request)
    [255](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:255)     self._close_connections(closing)
--> [256](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:256)     raise exc from None
    [258](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:258) # Return the response. Note that in this case we still have to manage
    [259](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:259) # the point at which the response is closed.

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:236, in ConnectionPool.handle_request(self, request)
    [234](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:234) try:
    [235](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:235)     # Send the request on the assigned connection.
--> [236](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:236)     response = connection.handle_request(
    [237](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:237)         pool_request.request
    [238](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:238)     )
    [239](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:239) except ConnectionNotAvailable:
    [240](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:240)     # In some cases a connection may initially be available to
    [241](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:241)     # handle a request, but then become unavailable.
    [242](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:242)     #
    [243](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:243)     # In this case we clear the connection and try again.

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:101, in HTTPConnection.handle_request(self, request)
    [100](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:100)     self._connect_failed = True
--> [101](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:101)     raise exc
    [103](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:103) return self._connection.handle_request(request)

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:78, in HTTPConnection.handle_request(self, request)
     [77](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:77) if self._connection is None:
---> [78](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:78)     stream = self._connect(request)
     [80](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:80)     ssl_object = stream.get_extra_info("ssl_object")

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:124, in HTTPConnection._connect(self, request)
    [123](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:123) with Trace("connect_tcp", logger, request, kwargs) as trace:
--> [124](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:124)     stream = self._network_backend.connect_tcp(**kwargs)
    [125](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py:125)     trace.return_value = stream

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:207, in SyncBackend.connect_tcp(self, host, port, timeout, local_address, socket_options)
    [202](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:202) exc_map: ExceptionMapping = {
    [203](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:203)     socket.timeout: ConnectTimeout,
    [204](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:204)     OSError: ConnectError,
    [205](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:205) }
--> [207](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:207) with map_exceptions(exc_map):
    [208](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:208)     sock = socket.create_connection(
    [209](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:209)         address,
    [210](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:210)         timeout,
    [211](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:211)         source_address=source_address,
    [212](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py:212)     )

File /usr/lib/python3.13/contextlib.py:162, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
    [161](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:161) try:
--> [162](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:162)     self.gen.throw(value)
    [163](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:163) except StopIteration as exc:
    [164](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:164)     # Suppress StopIteration *unless* it's the same exception that
    [165](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:165)     # was passed to throw().  This prevents a StopIteration
    [166](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:166)     # raised inside the "with" statement from being suppressed.

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_exceptions.py:14, in map_exceptions(map)
     [13](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_exceptions.py:13)     if isinstance(exc, from_exc):
---> [14](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_exceptions.py:14)         raise to_exc(exc) from exc
     [15](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_exceptions.py:15) raise

ConnectError: [Errno -2] Name or service not known

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

ConnectError                              Traceback (most recent call last)
File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:239, in Huggingface.completion(self, model, messages, api_base, model_response, print_verbose, timeout, encoding, api_key, logging_obj, optional_params, litellm_params, custom_prompt_dict, acompletion, logger_fn, client, headers)
    [237](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:237) ### SYNC COMPLETION
    [238](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:238) else:
--> [239](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:239)     response = client.post(
    [240](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:240)         url=completion_url,
    [241](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:241)         headers=headers,
    [242](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:242)         data=json.dumps(data),
    [243](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:243)     )
    [245](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:245)     return hf_chat_config.transform_response(
    [246](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:246)         model=model,
    [247](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:247)         raw_response=response,
   (...)
    [256](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:256)         litellm_params=litellm_params,
    [257](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:257)     )

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py:529, in HTTPHandler.post(self, url, data, json, params, headers, stream, timeout, files, content)
    [528](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py:528) except Exception as e:
--> [529](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py:529)     raise e

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py:507, in HTTPHandler.post(self, url, data, json, params, headers, stream, timeout, files, content)
    [504](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py:504)     req = self.client.build_request(
    [505](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py:505)         "POST", url, data=data, json=json, params=params, headers=headers, files=files, content=content  # type: ignore
    [506](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py:506)     )
--> [507](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py:507) response = self.client.send(req, stream=stream)
    [508](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py:508) response.raise_for_status()

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:914, in send(self, request, stream, auth, follow_redirects)
      [0](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:0) <Error retrieving source code with stack_data see ipython/ipython#13598>

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:942, in _send_handling_auth(self, request, auth, follow_redirects, history)
    [940](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:940)         raise exc
--> [942](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:942) def _send_handling_auth(
    [943](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:943)     self,
    [944](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:944)     request: Request,
    [945](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:945)     auth: Auth,
    [946](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:946)     follow_redirects: bool,
    [947](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:947)     history: list[Response],
    [948](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:948) ) -> Response:
    [949](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:949)     auth_flow = auth.sync_auth_flow(request)

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:979, in _send_handling_redirects(self, request, follow_redirects, history)
    [974](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:974)         auth_flow.close()
    [976](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:976) def _send_handling_redirects(
    [977](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:977)     self,
    [978](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:978)     request: Request,
--> [979](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:979)     follow_redirects: bool,
    [980](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:980)     history: list[Response],
    [981](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:981) ) -> Response:
    [982](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:982)     while True:

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:1014, in _send_single_request(self, request)
   [1013](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:1013) def _send_single_request(self, request: Request) -> Response:
-> [1014](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:1014)     """
   [1015](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:1015)     Sends a single request, without handling any redirections.
   [1016](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:1016)     """
   [1017](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py:1017)     transport = self._transport_for_url(request.url)

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:249, in handle_request(self, request)
      [0](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:0) <Error retrieving source code with stack_data see ipython/ipython#13598>

File /usr/lib/python3.13/contextlib.py:162, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
    [161](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:161) try:
--> [162](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:162)     self.gen.throw(value)
    [163](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:163) except StopIteration as exc:
    [164](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:164)     # Suppress StopIteration *unless* it's the same exception that
    [165](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:165)     # was passed to throw().  This prevents a StopIteration
    [166](https://file+.vscode-resource.vscode-cdn.net/usr/lib/python3.13/contextlib.py:166)     # raised inside the "with" statement from being suppressed.

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:118, in map_httpcore_exceptions()
      [0](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py:0) <Error retrieving source code with stack_data see ipython/ipython#13598>

ConnectError: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

HuggingfaceError                          Traceback (most recent call last)
File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2004, in completion(model, messages, timeout, temperature, top_p, n, stream, stream_options, stop, max_completion_tokens, max_tokens, modalities, prediction, audio, presence_penalty, frequency_penalty, logit_bias, user, response_format, seed, tools, tool_choice, logprobs, top_logprobs, parallel_tool_calls, deployment_id, extra_headers, functions, function_call, base_url, api_version, api_key, model_list, **kwargs)
   [2003](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2003) custom_prompt_dict = custom_prompt_dict or litellm.custom_prompt_dict
-> [2004](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2004) model_response = huggingface.completion(
   [2005](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2005)     model=model,
   [2006](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2006)     messages=messages,
   [2007](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2007)     api_base=api_base,  # type: ignore
   [2008](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2008)     headers=hf_headers or {},
   [2009](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2009)     model_response=model_response,
   [2010](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2010)     print_verbose=print_verbose,
   [2011](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2011)     optional_params=optional_params,
   [2012](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2012)     litellm_params=litellm_params,
   [2013](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2013)     logger_fn=logger_fn,
   [2014](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2014)     encoding=encoding,
   [2015](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2015)     api_key=huggingface_key,
   [2016](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2016)     acompletion=acompletion,
   [2017](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2017)     logging_obj=logging,
   [2018](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2018)     custom_prompt_dict=custom_prompt_dict,
   [2019](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2019)     timeout=timeout,  # type: ignore
   [2020](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2020)     client=client,
   [2021](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2021) )
   [2022](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2022) if (
   [2023](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2023)     "stream" in optional_params
   [2024](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2024)     and optional_params["stream"] is True
   [2025](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2025)     and acompletion is False
   [2026](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2026) ):
   [2027](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2027)     # don't try to access stream object,

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:273, in Huggingface.completion(self, model, messages, api_base, model_response, print_verbose, timeout, encoding, api_key, logging_obj, optional_params, litellm_params, custom_prompt_dict, acompletion, logger_fn, client, headers)
    [271](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:271) import traceback
--> [273](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py:273) raise HuggingfaceError(status_code=500, message=traceback.format_exc())

HuggingfaceError: Traceback (most recent call last):
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions
    httpcore.WriteError: WriteError,
        ^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py", line 250, in handle_request
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py", line 256, in handle_request
    raise exc from None
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py", line 236, in handle_request
    response = connection.handle_request(
        pool_request.request
    )
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py", line 101, in handle_request
    raise exc
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py", line 78, in handle_request
    stream = self._connect(request)
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py", line 124, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py", line 207, in connect_tcp
    with map_exceptions(exc_map):
         ~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/lib/python3.13/contextlib.py", line 162, in __exit__
    self.gen.throw(value)
    ~~~~~~~~~~~~~~^^^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno -2] Name or service not known

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

Traceback (most recent call last):
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py", line 239, in completion
    response = client.post(
        url=completion_url,
        headers=headers,
        data=json.dumps(data),
    )
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 529, in post
    raise e
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 507, in post
    response = self.client.send(req, stream=stream)
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py", line 914, in send
    
    
    ...<4 lines>...
        else follow_redirects
        ^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py", line 942, in _send_handling_auth
    def _send_handling_auth(
                           ^
    ...<3 lines>...
        follow_redirects: bool,
        ^^^^^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py", line 979, in _send_handling_redirects
    follow_redirects: bool,
                   ^^^^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py", line 1014, in _send_single_request
    """
    
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py", line 249, in handle_request
  File "/usr/lib/python3.13/contextlib.py", line 162, in __exit__
    self.gen.throw(value)
    ~~~~~~~~~~~~~~^^^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
httpx.ConnectError: [Errno -2] Name or service not known


During handling of the above exception, another exception occurred:

APIError                                  Traceback (most recent call last)
Cell In[19], [line 6](vscode-notebook-cell:?execution_count=19&line=6)
      [2](vscode-notebook-cell:?execution_count=19&line=2) import os
      [4](vscode-notebook-cell:?execution_count=19&line=4) os.environ["HUGGINGFACE_API_KEY"] = "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"
----> [6](vscode-notebook-cell:?execution_count=19&line=6) response = completion(
      [7](vscode-notebook-cell:?execution_count=19&line=7)   model="huggingface/microsoft/phi-4",
      [8](vscode-notebook-cell:?execution_count=19&line=8)   messages=[{ "content": "Hello, how are you?","role": "user"}],
      [9](vscode-notebook-cell:?execution_count=19&line=9)   api_base="https://my-endpoint.huggingface.cloud/"
     [10](vscode-notebook-cell:?execution_count=19&line=10) )
     [12](vscode-notebook-cell:?execution_count=19&line=12) print(response)

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:1030, in client.<locals>.wrapper(*args, **kwargs)
   [1026](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:1026) if logging_obj:
   [1027](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:1027)     logging_obj.failure_handler(
   [1028](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:1028)         e, traceback_exception, start_time, end_time
   [1029](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:1029)     )  # DO NOT MAKE THREADED - router retry fallback relies on this!
-> [1030](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:1030) raise e

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:906, in client.<locals>.wrapper(*args, **kwargs)
    [904](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:904)         print_verbose(f"Error while checking max token limit: {str(e)}")
    [905](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:905) # MODEL CALL
--> [906](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:906) result = original_function(*args, **kwargs)
    [907](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:907) end_time = datetime.datetime.now()
    [908](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/utils.py:908) if "stream" in kwargs and kwargs["stream"] is True:

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2967, in completion(model, messages, timeout, temperature, top_p, n, stream, stream_options, stop, max_completion_tokens, max_tokens, modalities, prediction, audio, presence_penalty, frequency_penalty, logit_bias, user, response_format, seed, tools, tool_choice, logprobs, top_logprobs, parallel_tool_calls, deployment_id, extra_headers, functions, function_call, base_url, api_version, api_key, model_list, **kwargs)
   [2964](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2964)     return response
   [2965](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2965) except Exception as e:
   [2966](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2966)     ## Map to OpenAI Exception
-> [2967](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2967)     raise exception_type(
   [2968](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2968)         model=model,
   [2969](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2969)         custom_llm_provider=custom_llm_provider,
   [2970](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2970)         original_exception=e,
   [2971](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2971)         completion_kwargs=args,
   [2972](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2972)         extra_kwargs=kwargs,
   [2973](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/main.py:2973)     )

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:2189, in exception_type(model, original_exception, custom_llm_provider, completion_kwargs, extra_kwargs)
   [2187](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:2187) if exception_mapping_worked:
   [2188](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:2188)     setattr(e, "litellm_response_headers", litellm_response_headers)
-> [2189](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:2189)     raise e
   [2190](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:2190) else:
   [2191](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:2191)     for error_type in litellm.LITELLM_EXCEPTION_TYPES:

File ~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1491, in exception_type(model, original_exception, custom_llm_provider, completion_kwargs, extra_kwargs)
   [1489](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1489)         else:
   [1490](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1490)             exception_mapping_worked = True
-> [1491](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1491)             raise APIError(
   [1492](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1492)                 status_code=original_exception.status_code,
   [1493](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1493)                 message=f"HuggingfaceException - {original_exception.message}",
   [1494](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1494)                 llm_provider="huggingface",
   [1495](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1495)                 model=model,
   [1496](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1496)                 request=original_exception.request,
   [1497](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1497)             )
   [1498](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1498) elif custom_llm_provider == "ai21":
   [1499](https://file+.vscode-resource.vscode-cdn.net/home/harshal/Desktop/pydantic-agents/~/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py:1499)     if hasattr(original_exception, "message"):

APIError: litellm.APIError: HuggingfaceException - Traceback (most recent call last):
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions
    httpcore.WriteError: WriteError,
        ^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py", line 250, in handle_request
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py", line 256, in handle_request
    raise exc from None
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py", line 236, in handle_request
    response = connection.handle_request(
        pool_request.request
    )
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py", line 101, in handle_request
    raise exc
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py", line 78, in handle_request
    stream = self._connect(request)
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_sync/connection.py", line 124, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_backends/sync.py", line 207, in connect_tcp
    with map_exceptions(exc_map):
         ~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/lib/python3.13/contextlib.py", line 162, in __exit__
    self.gen.throw(value)
    ~~~~~~~~~~~~~~^^^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno -2] Name or service not known

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

Traceback (most recent call last):
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/huggingface/chat/handler.py", line 239, in completion
    response = client.post(
        url=completion_url,
        headers=headers,
        data=json.dumps(data),
    )
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 529, in post
    raise e
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 507, in post
    response = self.client.send(req, stream=stream)
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py", line 914, in send
    
    
    ...<4 lines>...
        else follow_redirects
        ^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py", line 942, in _send_handling_auth
    def _send_handling_auth(
                           ^
    ...<3 lines>...
        follow_redirects: bool,
        ^^^^^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py", line 979, in _send_handling_redirects
    follow_redirects: bool,
                   ^^^^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_client.py", line 1014, in _send_single_request
    """
    
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py", line 249, in handle_request
  File "/usr/lib/python3.13/contextlib.py", line 162, in __exit__
    self.gen.throw(value)
    ~~~~~~~~~~~~~~^^^^^^^
  File "/home/harshal/Desktop/pydantic-agents/my_env/lib/python3.13/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
httpx.ConnectError: [Errno -2] Name or service not known
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@Harshal292004 and others