Faced the same issue and solved it, the error is simply due to the lower version of the Langchain community. I, too was following the Langchain documentation, but since it is very old. Thir error remains.
Check this link and install the requirements mentioned: https://github.com/langchain-ai/langchain/issues/22445
I hope it helps. 😃