Repository: explodinggradients/ragas
Issue: Issue with SSL certificate verification
Root cause: Configuration Error

[ ] I have checked the [documentation](https://docs.ragas.io/) and related resources and couldn't resolve my bug.

**When I try to run the metric scores, I keep getting the SSL certificate error. I have tried both hhtpx client verify=False, and validate_base_url = False. **

Ragas version:0.2.3
Python version:3.11.9

**Code to Reproduce**
```py

wrapped_llm = LangchainLLMWrapper(AzureChatOpenAI(
         openai_api_version="2023-12-01-preview",
         azure_endpoint=<my_endpoint>,
         azure_deployment="testing", model="gpt-4o", http_client=httpx.Client(verify=False)
))

sample = SingleTurnSample("""<input, response and retrieved_contexts included properly as per format>""")
scorer = Faithfulness(llm=wrapped_llm)
scorer.single_turn_score(sample)
```

**Error trace**
ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed in certificate chain (_ssl.c:1000)



<!-- PS: bugs suck but is also part of the process. We sincerely apologies for breaking your flow because of it, but don't worry, we got your back ❤️. We will get this fixed as fast as we can and thanks for helping us out by reporting it 🙏. -->


hey @AkileshSivaswamy are you able to do 

```py
unwrapped_llm = AzureChatOpenAI(
         openai_api_version="2023-12-01-preview",
         azure_endpoint=<my_endpoint>,
         azure_deployment="testing", model="gpt-4o", http_client=httpx.Client(verify=False)
)
unwrapped_llm.invoke("hello")
```

hi @jjmachan, yes, that runs

I see, can you get me the whole trace?

I am trying to fix the issue from my corporate laptop, while working behind a proxy. Unfortunately I dont.


Hi @jjmachan, managed to get it:

---------------------------------------------------------------------------
ConnectError                              Traceback (most recent call last)
File ~\Anaconda3\envs\psap2\Lib\site-packages\httpx\_transports\default.py:72, in map_httpcore_exceptions()
     71 try:
---> 72     yield
     73 except Exception as exc:

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpx\_transports\default.py:377, in AsyncHTTPTransport.handle_async_request(self, request)
    376 with map_httpcore_exceptions():
--> 377     resp = await self._pool.handle_async_request(req)
    379 assert isinstance(resp.stream, typing.AsyncIterable)

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpcore\_async\connection_pool.py:216, in AsyncConnectionPool.handle_async_request(self, request)
    215     await self._close_connections(closing)
--> 216     raise exc from None
    218 # Return the response. Note that in this case we still have to manage
    219 # the point at which the response is closed.

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpcore\_async\connection_pool.py:196, in AsyncConnectionPool.handle_async_request(self, request)
    194 try:
    195     # Send the request on the assigned connection.
--> 196     response = await connection.handle_async_request(
    197         pool_request.request
    198     )
    199 except ConnectionNotAvailable:
    200     # In some cases a connection may initially be available to
    201     # handle a request, but then become unavailable.
    202     #
    203     # In this case we clear the connection and try again.

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpcore\_async\http_proxy.py:317, in AsyncTunnelHTTPConnection.handle_async_request(self, request)
    316 async with Trace("start_tls", logger, request, kwargs) as trace:
--> 317     stream = await stream.start_tls(**kwargs)
    318     trace.return_value = stream

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpcore\_async\http11.py:383, in AsyncHTTP11UpgradeStream.start_tls(self, ssl_context, server_hostname, timeout)
    377 async def start_tls(
    378     self,
    379     ssl_context: ssl.SSLContext,
    380     server_hostname: Optional[str] = None,
    381     timeout: Optional[float] = None,
    382 ) -> AsyncNetworkStream:
--> 383     return await self._stream.start_tls(ssl_context, server_hostname, timeout)

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpcore\_backends\anyio.py:69, in AnyIOStream.start_tls(self, ssl_context, server_hostname, timeout)
     63 exc_map = {
     64     TimeoutError: ConnectTimeout,
     65     anyio.BrokenResourceError: ConnectError,
     66     anyio.EndOfStream: ConnectError,
     67     ssl.SSLError: ConnectError,
     68 }
---> 69 with map_exceptions(exc_map):
     70     try:

File ~\Anaconda3\envs\psap2\Lib\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 ~\Anaconda3\envs\psap2\Lib\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: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)

The above exception was the direct cause of the following exception:

ConnectError                              Traceback (most recent call last)
File ~\Anaconda3\envs\psap2\Lib\site-packages\openai\_base_client.py:1571, in AsyncAPIClient._request(self, cast_to, options, stream, stream_cls, retries_taken)
   1570 try:
-> 1571     response = await self._client.send(
   1572         request,
   1573         stream=stream or self._should_stream_response_body(request=request),
   1574         **kwargs,
   1575     )
   1576 except httpx.TimeoutException as err:

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpx\_client.py:1674, in AsyncClient.send(self, request, stream, auth, follow_redirects)
   1672 auth = self._build_request_auth(request, auth)
-> 1674 response = await self._send_handling_auth(
   1675     request,
   1676     auth=auth,
   1677     follow_redirects=follow_redirects,
   1678     history=[],
   1679 )
   1680 try:

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpx\_client.py:1702, in AsyncClient._send_handling_auth(self, request, auth, follow_redirects, history)
   1701 while True:
-> 1702     response = await self._send_handling_redirects(
   1703         request,
   1704         follow_redirects=follow_redirects,
   1705         history=history,
   1706     )
   1707     try:

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpx\_client.py:1739, in AsyncClient._send_handling_redirects(self, request, follow_redirects, history)
   1737     await hook(request)
-> 1739 response = await self._send_single_request(request)
   1740 try:

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpx\_client.py:1776, in AsyncClient._send_single_request(self, request)
   1775 with request_context(request=request):
-> 1776     response = await transport.handle_async_request(request)
   1778 assert isinstance(response.stream, AsyncByteStream)

File ~\Anaconda3\envs\psap2\Lib\site-packages\httpx\_transports\default.py:376, in AsyncHTTPTransport.handle_async_request(self, request)
    364 req = httpcore.Request(
    365     method=request.method,
    366     url=httpcore.URL(
   (...)
    374     extensions=request.extensions,
    375 )
--> 376 with map_httpcore_exceptions():
    377     resp = await self._pool.handle_async_request(req)

File ~\Anaconda3\envs\psap2\Lib\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 ~\Anaconda3\envs\psap2\Lib\site-packages\httpx\_transports\default.py:89, in map_httpcore_exceptions()
     88 message = str(exc)
---> 89 raise mapped_exc(message) from exc

ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)

The above exception was the direct cause of the following exception:

APIConnectionError                        Traceback (most recent call last)
Cell In[16], line 1
----> 1 scorer.single_turn_score(sample)

File ~\Anaconda3\envs\psap2\Lib\site-packages\ragas\metrics\base.py:253, in SingleTurnMetric.single_turn_score(self, sample, callbacks)
    251     if not group_cm.ended:
    252         rm.on_chain_error(e)
--> 253     raise e
    254 else:
    255     if not group_cm.ended:

File ~\Anaconda3\envs\psap2\Lib\site-packages\ragas\metrics\base.py:247, in SingleTurnMetric.single_turn_score(self, sample, callbacks)
    243             raise ImportError(
    244                 "It seems like your running this in a jupyter-like environment. Please install nest_asyncio with `pip install nest_asyncio` to make it work."
    245             )
    246     loop = asyncio.get_event_loop()
--> 247     score = loop.run_until_complete(
    248         self._single_turn_ascore(sample=sample, callbacks=group_cm)
    249     )
    250 except Exception as e:
    251     if not group_cm.ended:

File ~\Anaconda3\envs\psap2\Lib\site-packages\nest_asyncio.py:98, in _patch_loop.<locals>.run_until_complete(self, future)
     95 if not f.done():
     96     raise RuntimeError(
     97         'Event loop stopped before Future completed.')
---> 98 return f.result()

File ~\Anaconda3\envs\psap2\Lib\asyncio\futures.py:203, in Future.result(self)
    201 self.__log_traceback = False
    202 if self._exception is not None:
--> 203     raise self._exception.with_traceback(self._exception_tb)
    204 return self._result

File ~\Anaconda3\envs\psap2\Lib\asyncio\tasks.py:277, in Task.__step(***failed resolving arguments***)
    273 try:
    274     if exc is None:
    275         # We use the `send` method directly, because coroutines
    276         # don't have `__iter__` and `__next__` methods.
--> 277         result = coro.send(None)
    278     else:
    279         result = coro.throw(exc)

File ~\Anaconda3\envs\psap2\Lib\site-packages\ragas\metrics\_faithfulness.py:257, in Faithfulness._single_turn_ascore(self, sample, callbacks)
    253 async def _single_turn_ascore(
    254     self, sample: SingleTurnSample, callbacks: Callbacks
    255 ) -> float:
    256     row = sample.to_dict()
--> 257     return await self._ascore(row, callbacks)

File ~\Anaconda3\envs\psap2\Lib\site-packages\ragas\metrics\_faithfulness.py:265, in Faithfulness._ascore(self, row, callbacks)
    260 """
    261 returns the NLI score for each (q, c, a) pair
    262 """
    263 assert self.llm is not None, "LLM is not set"
--> 265 statements_simplified = await self._create_statements(row, callbacks)
    266 if statements_simplified is None:
    267     return np.nan

File ~\Anaconda3\envs\psap2\Lib\site-packages\ragas\metrics\_faithfulness.py:230, in Faithfulness._create_statements(self, row, callbacks)
    223 sentences = self.sentence_segmenter.segment(text)
    224 sentences_with_index = {
    225     i: sentence
    226     for i, sentence in enumerate(sentences)
    227     if sentence.strip().endswith((".", "。", "!", "！"))
    228 }
--> 230 statements_simplified = await self.statement_prompt.generate(
    231     llm=self.llm,
    232     data=FaithfulnessStatements(
    233         question=question, answer=text, sentences=sentences_with_index
    234     ),
    235     callbacks=callbacks,
    236 )
    237 return statements_simplified

File ~\Anaconda3\envs\psap2\Lib\site-packages\ragas\prompt\pydantic_prompt.py:130, in PydanticPrompt.generate(self, llm, data, temperature, stop, callbacks, retries_left)
    127 callbacks = callbacks or []
    129 # this is just a special case of generate_multiple
--> 130 output_single = await self.generate_multiple(
    131     llm=llm,
    132     data=data,
    133     n=1,
    134     temperature=temperature,
    135     stop=stop,
    136     callbacks=callbacks,
    137     retries_left=retries_left,
    138 )
    139 return output_single[0]

File ~\Anaconda3\envs\psap2\Lib\site-packages\ragas\prompt\pydantic_prompt.py:190, in PydanticPrompt.generate_multiple(self, llm, data, n, temperature, stop, callbacks, retries_left)
    183 prompt_rm, prompt_cb = new_group(
    184     name=self.name,
    185     inputs={"data": processed_data},
    186     callbacks=callbacks,
    187     metadata={"type": ChainType.RAGAS_PROMPT},
    188 )
    189 prompt_value = PromptValue(text=self.to_string(processed_data))
--> 190 resp = await llm.generate(
    191     prompt_value,
    192     n=n,
    193     temperature=temperature,
    194     stop=stop,
    195     callbacks=prompt_cb,
    196 )
    198 output_models = []
    199 parser = RagasOutputParser(pydantic_object=self.output_model)

File ~\Anaconda3\envs\psap2\Lib\site-packages\ragas\llms\base.py:100, in BaseRagasLLM.generate(self, prompt, n, temperature, stop, callbacks)
     95     temperature = self.get_temperature(n)
     97 agenerate_text_with_retry = add_async_retry(
     98     self.agenerate_text, self.run_config
     99 )
--> 100 result = await agenerate_text_with_retry(
    101     prompt=prompt,
    102     n=n,
    103     temperature=temperature,
    104     stop=stop,
    105     callbacks=callbacks,
    106 )
    108 # check there are no max_token issues
    109 if not self.is_finished(result):

File ~\Anaconda3\envs\psap2\Lib\site-packages\tenacity\asyncio\__init__.py:189, in AsyncRetrying.wraps.<locals>.async_wrapped(*args, **kwargs)
    187 copy = self.copy()
    188 async_wrapped.statistics = copy.statistics  # type: ignore[attr-defined]
--> 189 return await copy(fn, *args, **kwargs)

File ~\Anaconda3\envs\psap2\Lib\site-packages\tenacity\asyncio\__init__.py:111, in AsyncRetrying.__call__(self, fn, *args, **kwargs)
    109 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)
    110 while True:
--> 111     do = await self.iter(retry_state=retry_state)
    112     if isinstance(do, DoAttempt):
    113         try:

File ~\Anaconda3\envs\psap2\Lib\site-packages\tenacity\asyncio\__init__.py:153, in AsyncRetrying.iter(self, retry_state)
    151 result = None
    152 for action in self.iter_state.actions:
--> 153     result = await action(retry_state)
    154 return result

File ~\Anaconda3\envs\psap2\Lib\site-packages\tenacity\_utils.py:99, in wrap_to_async_func.<locals>.inner(*args, **kwargs)
     98 async def inner(*args: typing.Any, **kwargs: typing.Any) -> typing.Any:
---> 99     return call(*args, **kwargs)

File ~\Anaconda3\envs\psap2\Lib\site-packages\tenacity\__init__.py:418, in BaseRetrying._post_stop_check_actions.<locals>.exc_check(rs)
    416 retry_exc = self.retry_error_cls(fut)
    417 if self.reraise:
--> 418     raise retry_exc.reraise()
    419 raise retry_exc from fut.exception()

File ~\Anaconda3\envs\psap2\Lib\site-packages\tenacity\__init__.py:185, in RetryError.reraise(self)
    183 def reraise(self) -> t.NoReturn:
    184     if self.last_attempt.failed:
--> 185         raise self.last_attempt.result()
    186     raise self

File ~\Anaconda3\envs\psap2\Lib\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 ~\Anaconda3\envs\psap2\Lib\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 ~\Anaconda3\envs\psap2\Lib\site-packages\tenacity\asyncio\__init__.py:114, in AsyncRetrying.__call__(self, fn, *args, **kwargs)
    112 if isinstance(do, DoAttempt):
    113     try:
--> 114         result = await fn(*args, **kwargs)
    115     except BaseException:  # noqa: B902
    116         retry_state.set_exception(sys.exc_info())  # type: ignore[arg-type]

File ~\Anaconda3\envs\psap2\Lib\site-packages\ragas\llms\base.py:220, in LangchainLLMWrapper.agenerate_text(self, prompt, n, temperature, stop, callbacks)
    217     temperature = self.get_temperature(n=n)
    219 if is_multiple_completion_supported(self.langchain_llm):
--> 220     return await self.langchain_llm.agenerate_prompt(
    221         prompts=[prompt],
    222         n=n,
    223         temperature=temperature,
    224         stop=stop,
    225         callbacks=callbacks,
    226     )
    227 else:
    228     result = await self.langchain_llm.agenerate_prompt(
    229         prompts=[prompt] * n,
    230         temperature=temperature,
    231         stop=stop,
    232         callbacks=callbacks,
    233     )

File ~\Anaconda3\envs\psap2\Lib\site-packages\langchain_core\language_models\chat_models.py:796, in BaseChatModel.agenerate_prompt(self, prompts, stop, callbacks, **kwargs)
    788 async def agenerate_prompt(
    789     self,
    790     prompts: list[PromptValue],
   (...)
    793     **kwargs: Any,
    794 ) -> LLMResult:
    795     prompt_messages = [p.to_messages() for p in prompts]
--> 796     return await self.agenerate(
    797         prompt_messages, stop=stop, callbacks=callbacks, **kwargs
    798     )

File ~\Anaconda3\envs\psap2\Lib\site-packages\langchain_core\language_models\chat_models.py:756, in BaseChatModel.agenerate(self, messages, stop, callbacks, tags, metadata, run_name, run_id, **kwargs)
    743     if run_managers:
    744         await asyncio.gather(
    745             *[
    746                 run_manager.on_llm_end(
   (...)
    754             ]
    755         )
--> 756     raise exceptions[0]
    757 flattened_outputs = [
    758     LLMResult(generations=[res.generations], llm_output=res.llm_output)  # type: ignore[list-item, union-attr]
    759     for res in results
    760 ]
    761 llm_output = self._combine_llm_outputs([res.llm_output for res in results])  # type: ignore[union-attr]

File ~\Anaconda3\envs\psap2\Lib\asyncio\tasks.py:277, in Task.__step(***failed resolving arguments***)
    273 try:
    274     if exc is None:
    275         # We use the `send` method directly, because coroutines
    276         # don't have `__iter__` and `__next__` methods.
--> 277         result = coro.send(None)
    278     else:
    279         result = coro.throw(exc)

File ~\Anaconda3\envs\psap2\Lib\site-packages\langchain_core\language_models\chat_models.py:924, in BaseChatModel._agenerate_with_cache(self, messages, stop, run_manager, **kwargs)
    922 else:
    923     if inspect.signature(self._agenerate).parameters.get("run_manager"):
--> 924         result = await self._agenerate(
    925             messages, stop=stop, run_manager=run_manager, **kwargs
    926         )
    927     else:
    928         result = await self._agenerate(messages, stop=stop, **kwargs)

File ~\Anaconda3\envs\psap2\Lib\site-packages\langchain_openai\chat_models\base.py:858, in BaseChatOpenAI._agenerate(self, messages, stop, run_manager, **kwargs)
    856     generation_info = {"headers": dict(raw_response.headers)}
    857 else:
--> 858     response = await self.async_client.create(**payload)
    859 return await run_in_executor(
    860     None, self._create_chat_result, response, generation_info
    861 )

File ~\Anaconda3\envs\psap2\Lib\site-packages\openai\resources\chat\completions.py:1633, in AsyncCompletions.create(self, messages, model, audio, frequency_penalty, function_call, functions, logit_bias, logprobs, max_completion_tokens, max_tokens, metadata, modalities, n, parallel_tool_calls, presence_penalty, response_format, seed, service_tier, stop, store, stream, stream_options, temperature, tool_choice, tools, top_logprobs, top_p, user, extra_headers, extra_query, extra_body, timeout)
   1593 @required_args(["messages", "model"], ["messages", "model", "stream"])
   1594 async def create(
   1595     self,
   (...)
   1630     timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
   1631 ) -> ChatCompletion | AsyncStream[ChatCompletionChunk]:
   1632     validate_response_format(response_format)
-> 1633     return await self._post(
   1634         "/chat/completions",
   1635         body=await async_maybe_transform(
   1636             {
   1637                 "messages": messages,
   1638                 "model": model,
   1639                 "audio": audio,
   1640                 "frequency_penalty": frequency_penalty,
   1641                 "function_call": function_call,
   1642                 "functions": functions,
   1643                 "logit_bias": logit_bias,
   1644                 "logprobs": logprobs,
   1645                 "max_completion_tokens": max_completion_tokens,
   1646                 "max_tokens": max_tokens,
   1647                 "metadata": metadata,
   1648                 "modalities": modalities,
   1649                 "n": n,
   1650                 "parallel_tool_calls": parallel_tool_calls,
   1651                 "presence_penalty": presence_penalty,
   1652                 "response_format": response_format,
   1653                 "seed": seed,
   1654                 "service_tier": service_tier,
   1655                 "stop": stop,
   1656                 "store": store,
   1657                 "stream": stream,
   1658                 "stream_options": stream_options,
   1659                 "temperature": temperature,
   1660                 "tool_choice": tool_choice,
   1661                 "tools": tools,
   1662                 "top_logprobs": top_logprobs,
   1663                 "top_p": top_p,
   1664                 "user": user,
   1665             },
   1666             completion_create_params.CompletionCreateParams,
   1667         ),
   1668         options=make_request_options(
   1669             extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
   1670         ),
   1671         cast_to=ChatCompletion,
   1672         stream=stream or False,
   1673         stream_cls=AsyncStream[ChatCompletionChunk],
   1674     )

File ~\Anaconda3\envs\psap2\Lib\site-packages\openai\_base_client.py:1838, in AsyncAPIClient.post(self, path, cast_to, body, files, options, stream, stream_cls)
   1824 async def post(
   1825     self,
   1826     path: str,
   (...)
   1833     stream_cls: type[_AsyncStreamT] | None = None,
   1834 ) -> ResponseT | _AsyncStreamT:
   1835     opts = FinalRequestOptions.construct(
   1836         method="post", url=path, json_data=body, files=await async_to_httpx_files(files), **options
   1837     )
-> 1838     return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)

File ~\Anaconda3\envs\psap2\Lib\site-packages\openai\_base_client.py:1532, in AsyncAPIClient.request(self, cast_to, options, stream, stream_cls, remaining_retries)
   1529 else:
   1530     retries_taken = 0
-> 1532 return await self._request(
   1533     cast_to=cast_to,
   1534     options=options,
   1535     stream=stream,
   1536     stream_cls=stream_cls,
   1537     retries_taken=retries_taken,
   1538 )

File ~\Anaconda3\envs\psap2\Lib\site-packages\openai\_base_client.py:1595, in AsyncAPIClient._request(self, cast_to, options, stream, stream_cls, retries_taken)
   1592 log.debug("Encountered Exception", exc_info=True)
   1594 if remaining_retries > 0:
-> 1595     return await self._retry_request(
   1596         input_options,
   1597         cast_to,
   1598         retries_taken=retries_taken,
   1599         stream=stream,
   1600         stream_cls=stream_cls,
   1601         response_headers=None,
   1602     )
   1604 log.debug("Raising connection error")
   1605 raise APIConnectionError(request=request) from err

File ~\Anaconda3\envs\psap2\Lib\site-packages\openai\_base_client.py:1665, in AsyncAPIClient._retry_request(self, options, cast_to, retries_taken, response_headers, stream, stream_cls)
   1661 log.info("Retrying request to %s in %f seconds", options.url, timeout)
   1663 await anyio.sleep(timeout)
-> 1665 return await self._request(
   1666     options=options,
   1667     cast_to=cast_to,
   1668     retries_taken=retries_taken + 1,
   1669     stream=stream,
   1670     stream_cls=stream_cls,
   1671 )

File ~\Anaconda3\envs\psap2\Lib\site-packages\openai\_base_client.py:1595, in AsyncAPIClient._request(self, cast_to, options, stream, stream_cls, retries_taken)
   1592 log.debug("Encountered Exception", exc_info=True)
   1594 if remaining_retries > 0:
-> 1595     return await self._retry_request(
   1596         input_options,
   1597         cast_to,
   1598         retries_taken=retries_taken,
   1599         stream=stream,
   1600         stream_cls=stream_cls,
   1601         response_headers=None,
   1602     )
   1604 log.debug("Raising connection error")
   1605 raise APIConnectionError(request=request) from err

File ~\Anaconda3\envs\psap2\Lib\site-packages\openai\_base_client.py:1665, in AsyncAPIClient._retry_request(self, options, cast_to, retries_taken, response_headers, stream, stream_cls)
   1661 log.info("Retrying request to %s in %f seconds", options.url, timeout)
   1663 await anyio.sleep(timeout)
-> 1665 return await self._request(
   1666     options=options,
   1667     cast_to=cast_to,
   1668     retries_taken=retries_taken + 1,
   1669     stream=stream,
   1670     stream_cls=stream_cls,
   1671 )

File ~\Anaconda3\envs\psap2\Lib\site-packages\openai\_base_client.py:1605, in AsyncAPIClient._request(self, cast_to, options, stream, stream_cls, retries_taken)
   1595         return await self._retry_request(
   1596             input_options,
   1597             cast_to,
   (...)
   1601             response_headers=None,
   1602         )
   1604     log.debug("Raising connection error")
-> 1605     raise APIConnectionError(request=request) from err
   1607 log.debug(
   1608     'HTTP Request: %s %s "%i %s"', request.method, request.url, response.status_code, response.reason_phrase
   1609 )
   1611 try:

APIConnectionError: Connection error.


hey @AkileshSivaswamy I'm sorry but I unfortunately can't figure out what exactly is the issue. The reason is most likely that `verify=False` is not getting propogated and causing issues

A more comprehensive solution would be to:
1. Configure the corporate proxy settings correctly
2. Add the corporate SSL certificates to Python's certificate store
3. Update the certifi package with the corporate certificates