langchain
langchain copied to clipboard
Importing LangChain into a Python OCI Function failing
Checked other resources
- [x] I added a very descriptive title to this issue.
- [x] I searched the LangChain documentation with the integrated search.
- [x] I used the GitHub search to find a similar question and didn't find it.
- [x] I am sure that this is a bug in LangChain rather than my code.
- [x] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
from langchain_community.chat_models.oci_generative_ai import ChatOCIGenAI
from langchain_community.utilities import SQLDatabase
from langchain_experimental.sql import SQLDatabaseSequentialChain
from langchain.prompts.prompt import PromptTemplate
Error Message and Stack Trace (if applicable)
"01JJKPZFJS1BT0C20ZJ0011W8X - fn - ERROR - 'NoneType' object is not callable:
File "/python/fdk/runner.py", line 74, in handle_request\n response_data = await with_deadline(ctx, handler_code, body)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n
File "/python/fdk/runner.py", line 54, in with_deadline\n raise ex\n File "/python/fdk/runner.py", line 47, in with_deadline\n handle_func = handler_code.handler()\n ^^^^^^^^^^^^^^^^^^^^^^\n
File "/python/fdk/customer_code.py", line 94, in handler\n mod = self._delayed_module_class.get_module()\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n
File "/python/fdk/customer_code.py", line 59, in get_module\n .load_module()\n ^^^^^^^^^^^^^\n
File "
File "
File "
File "
File "
File "
File "
File "/function/func.py", line 6, in
File "/python/langchain_community/chat_models/oci_generative_ai.py", line 18, in
File "/python/langchain_core/callbacks/init.py", line 23, in
File "/python/langchain_core/callbacks/manager.py", line 23, in
File "/python/langsmith/run_helpers.py", line 56, in
Description
I'm trying to use LangChain in a Python OCI Function and I'm getting the following error when trying to import anything from LangChain.
I get the error for all of these import statements (have tried each individually, same result) with or without using any of these imports further in my code.
Some context on my environment:
The Function is deploying successfully, error only occurs at invocation. Building in Python 3.11 My requirements.txt has the following:
fdk>=0.1.86 oci oracledb langchain-community==0.3.15 langchain-experimental==0.3.4 langchain==0.3.15 sqlalchemy
I've tried pinning the versions as above and not pinning the versions, same error. I've also successfully run these imports along with the rest of my code locally using the above pinned versions in Python 3.11, and it works perfectly fine.
I've also tried using earlier LangChain versions along with using a Python 3.9 and Python 3.8 OCI Function environment, same issue.
It seems therefore to be a problem running these particular Python imports in the OCI Function environment. Taking out these imports allows my code to work ok.
System Info
System Information
OS: Windows OS Version: 10.0.26100 Python Version: 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
Package Information
langchain_core: 0.3.31 langchain: 0.3.15 langchain_community: 0.3.15 langsmith: 0.3.1 langchain-job: Installed. No version info available. langchain_anthropic: 0.3.4 langchain_astradb: 0.5.2 langchain_aws: 0.2.7 langchain_chroma: 0.2.0 langchain_cohere: 0.3.5 langchain_elasticsearch: 0.3.2 langchain_experimental: 0.3.4 langchain_google_calendar_tools: 0.0.1 langchain_google_community: 2.0.4 langchain_google_genai: 2.0.9 langchain_google_vertexai: 2.0.7 langchain_groq: 0.2.3 langchain_milvus: 0.1.7 langchain_mistralai: 0.2.4 langchain_mongodb: 0.4.0 langchain_nvidia: Installed. No version info available. langchain_nvidia_ai_endpoints: 0.3.7 langchain_ollama: 0.2.1 langchain_openai: 0.2.14 langchain_pinecone: 0.2.2 langchain_tests: 0.3.9 langchain_text_splitters: 0.3.5 langchain_unstructured: 0.1.5 langchainhub: 0.1.21
Optional packages not installed
langserve
Other Dependencies
aiohttp: 3.11.11 anthropic: 0.45.0 anthropic[vertexai]: Installed. No version info available. astrapy: 1.5.2 async-timeout: 5.0.1 beautifulsoup4: 4.12.3 boto3: 1.34.162 chromadb: 0.5.23 cohere: 5.13.11 dataclasses-json: 0.6.7 db-dtypes: Installed. No version info available. defusedxml: 0.7.1 elasticsearch[vectorstore-mmr]: Installed. No version info available. fastapi: 0.115.7 filetype: 1.2.0 gapic-google-longrunning: Installed. No version info available. google-api-core: 2.24.0 google-api-python-client: 2.159.0 google-api-python-client>=2.104.0: Installed. No version info available. google-auth-httplib2: 0.2.0 google-auth-oauthlib: 1.2.1 google-auth-oauthlib>=1.1.0: Installed. No version info available. google-cloud-aiplatform: 1.78.0 google-cloud-bigquery: 3.29.0 google-cloud-bigquery-storage: Installed. No version info available. google-cloud-contentwarehouse: Installed. No version info available. google-cloud-core: 2.4.1 google-cloud-discoveryengine: Installed. No version info available. google-cloud-documentai: Installed. No version info available. google-cloud-documentai-toolbox: Installed. No version info available. google-cloud-speech: Installed. No version info available. google-cloud-storage: 2.19.0 google-cloud-texttospeech: Installed. No version info available. google-cloud-translate: Installed. No version info available. google-cloud-vision: Installed. No version info available. google-generativeai: 0.8.4 googlemaps: Installed. No version info available. groq: 0.15.0 grpcio: 1.70.0 httpx: 0.28.1 httpx-sse: 0.4.0 jsonpatch: 1.33 langchain-core>=0.3: Installed. No version info available. langchain-text-splitters>=0.3: Installed. No version info available. langchain>=0.0.335: Installed. No version info available. langchain>=0.3: Installed. No version info available. langsmith-pyo3: Installed. No version info available. numpy: 1.26.4 numpy>=1.26: Installed. No version info available. ollama: 0.3.3 openai: 1.60.0 orjson: 3.10.15 packaging: 24.2 pandas: 2.2.2 pillow: 10.4.0 pinecone: 5.4.2 protobuf>=4.25.0: Installed. No version info available. pyarrow: 17.0.0 pydantic: 2.9.2 pydantic-settings: 2.7.1 pymilvus: 2.4.9 pymongo>=4.6.1: Installed. No version info available. pytest: 8.3.4 pytest-asyncio: 0.25.2 pytest-socket: 0.7.0 pytz>=2023.3.post1: Installed. No version info available. PyYAML: 6.0.2 requests: 2.32.3 requests-toolbelt: 1.0.0 rich: 13.9.4 SQLAlchemy: 2.0.37 syrupy: 4.8.1 tabulate: 0.9.0 tenacity: 9.0.0 tiktoken: 0.7.0 tokenizers: 0.20.3 types-requests: 2.32.0.20241016 typing-extensions: 4.12.2 unstructured-client: 0.25.9 unstructured[all-docs]: Installed. No version info available. zstandard: 0.23.0