Repository: truera/trulens
Issue: [BUG] OpenAICallbackHandler Issue- LangChainDeprecationWarning
Root cause: External Dependency Breakage

**Bug Description**
getting OpenAICallbackHandler error and nltk_data error 

**To Reproduce**
Seems to be hidden dependencies in trulens_eval package installation 
This piece of code in Pycharm 2024.1 community edition
from trulens_eval import Feedback, LiteLLM, TruLlama

**Expected behavior**
No error 

**Relevant Logs/Tracebacks**
LangChainDeprecationWarning: Importing OpenAICallbackHandler from /Users/abc/PycharmProjects/rag_training/.venv/lib/python3.12/site-packages/langchain/callbacks/openai_info.py is deprecated. Please replace deprecated imports:

>> from /Users/abc/PycharmProjects/rag_training/.venv/lib/python3.12/site-packages/langchain/callbacks/openai_info.py import OpenAICallbackHandler

with new imports of:

>> from langchain_community.callbacks.openai_info import OpenAICallbackHandler
You can use the langchain cli to **automatically** upgrade many imports. Please see documentation here <https://python.langchain.com/v0.2/docs/versions/v0_2/>
  warn_deprecated(
[nltk_data] Error loading stopwords: <urlopen error [SSL:
[nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed:
[nltk_data]     unable to get local issuer certificate (_ssl.c:1000)>
[nltk_data] Error loading punkt: <urlopen error [SSL:
[nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed:
[nltk_data]     unable to get local issuer certificate (_ssl.c:1000)>

**Environment:**
 - OS: MacOS
 - Python Version: 3.12
 - Langchain: 0.2.6
- Langchain- community: 0.2.6
- langchain cli: 0.0.25
- trulens_eval: 0.32.0

**Additional context**
The debugging options so far: 
1. used the langchain cli to **automatically** upgrade any imports. Then cleared the cache in pycharm and restarted it. But no luck
2. Code line “from langchain_community.callbacks.openai_info import OpenAICallbackHandler” is already  reflected in openai_info.py file.

Though the code exits with 0, not sure if it will create any issues down the line 




<!-- Greeting -->
Hello, @hackrz! I'm here to help you with any bugs, questions, or contributions you have. Let's squash those bugs together!

<!-- Answer -->
To resolve the `OpenAICallbackHandler` deprecation warning and the `nltk_data` certificate verification error, follow these steps:

1. **Deprecation Warning for `OpenAICallbackHandler`**:
   - Update your import statement to use the new path:
     ```python
     from langchain_community.callbacks.openai_info import OpenAICallbackHandler
     ```
   - Ensure that all instances of the old import path are replaced with the new one. You can use the `langchain` CLI tool to help with this process as described in the [LangChain documentation](https://python.langchain.com/v0.2/docs/versions/v0_2/).

2. **NLTK Data Certificate Verification Error**:
   - Bypass SSL certificate verification for NLTK by adding the following code at the beginning of your script:
     ```python
     import ssl
     import nltk

     # Bypass SSL certificate verification
     ssl._create_default_https_context = ssl._create_unverified_context

     # Download the NLTK data
     nltk.download('stopwords')
     nltk.download('punkt')
     ```

By following these steps, you should be able to resolve both the deprecation warning and the certificate verification error <sup>[[1]](https://github.com/truera/trulens/blob/main/trulens_eval/trulens_eval/utils/imports.py)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*


I already tried option 1 per my description in issue and option 2 did not work in pycharm 

Thanks for the deprecation warning. I think the nltk error was unrelated here. Were you fully online when this happened? I'm guessing that you might have had the nltk download request redirected (to a wifi login page or something similar) hence the ssl failure. Can you verify or check that you are getting the same error while fully online?

It was on Pycharm and my wifi was also fully functional on macOs. Not sure what you meant by fully online. Could you please clarify?

By fully online I was referring to a situation where sometimes with public wifi hotspots, you first connect in such a way that it looks like you are online but all connections get replaced by a special login page where you are asked to accept some hotspot terms or some such. This is one way in which an SSL would fail to verify a connection.

What was the problem when you tried dosu's second suggestion? (can you try it without the ssl... line?)

Also, does this apply to you: https://stackoverflow.com/questions/41348621/ssl-error-downloading-nltk-data/42890688#42890688 ?

Yes, this worked like a charm. Thanks
Do you also have any visibility into LangChainDeprecationWarning issue?