{"id":3332,"library":"langchain-experimental","title":"LangChain Experimental","description":"LangChain Experimental is a Python package within the broader LangChain ecosystem, providing a testing ground for novel concepts, advanced integrations, and speculative features related to large language models (LLMs). It is explicitly designed for research and experimental uses, and users are warned that portions of its code may be dangerous if not properly deployed in a sandboxed environment. The current version is 0.4.1, and while core LangChain follows semantic versioning with frequent patch and minor releases, the experimental package's cadence is tied to the rapid development of new LLM application patterns.","status":"active","version":"0.4.1","language":"en","source_language":"en","source_url":"https://github.com/langchain-ai/langchain-experimental","tags":["LLM","AI","LangChain","experimental","agent","tooling"],"install":[{"cmd":"pip install langchain-experimental","lang":"bash","label":"Install `langchain-experimental`"},{"cmd":"pip install langchain-openai pandas","lang":"bash","label":"Additional dependencies for quickstart"}],"dependencies":[{"reason":"Core LangChain framework, as 'langchain-experimental' extends its capabilities.","package":"langchain","optional":false},{"reason":"Foundational components for the LangChain ecosystem.","package":"langchain-core","optional":false},{"reason":"Integration with OpenAI models, commonly used in examples and quickstarts.","package":"langchain-openai","optional":true},{"reason":"Required for specific experimental components like the Pandas DataFrame Agent.","package":"pandas","optional":true}],"imports":[{"note":"Experimental agents and toolkits were moved from `langchain` to `langchain-experimental`.","wrong":"from langchain.agents.agent_toolkits import create_pandas_dataframe_agent","symbol":"create_pandas_dataframe_agent","correct":"from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent"}],"quickstart":{"code":"import os\nimport pandas as pd\nfrom langchain_openai import ChatOpenAI\nfrom langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent\n\n# Set your OpenAI API key from environment variables\n# For testing, you can uncomment and replace with your key, but use environment variables in production.\n# os.environ[\"OPENAI_API_KEY\"] = \"sk-...\"\n\n# Ensure OPENAI_API_KEY is set in your environment\nif os.environ.get(\"OPENAI_API_KEY\") is None:\n    print(\"Warning: OPENAI_API_KEY environment variable is not set. Quickstart may fail.\")\n    # In a real application, you'd handle this more robustly, e.g., raise an error or prompt the user.\n\n# Load a sample DataFrame\ndata = {\n    \"name\": [\"Alice\", \"Bob\", \"Charlie\", \"David\"],\n    \"age\": [25, 30, 35, 28],\n    \"city\": [\"New York\", \"London\", \"Paris\", \"New York\"]\n}\ndf = pd.DataFrame(data)\n\n# Initialize the LLM (requires langchain-openai to be installed)\nllm = ChatOpenAI(model=\"gpt-4\", temperature=0)\n\n# Create the pandas dataframe agent\nagent = create_pandas_dataframe_agent(llm, df, verbose=True)\n\n# Run a query on the DataFrame\nquery = \"What is the average age of the people from New York?\"\nprint(f\"\\nQuery: {query}\")\nresponse = agent.invoke({\"input\": query})\nprint(f\"Response: {response['output']}\")\n\nquery_count = \"How many people are from London?\"\nprint(f\"\\nQuery: {query_count}\")\nresponse_count = agent.invoke({\"input\": query_count})\nprint(f\"Response: {response_count['output']}\")","lang":"python","description":"This quickstart demonstrates how to use the `create_pandas_dataframe_agent` from `langchain-experimental` to interact with a Pandas DataFrame using a Large Language Model. It sets up a sample DataFrame, initializes an OpenAI chat model, and then uses the experimental agent to answer questions about the data."},"warnings":[{"fix":"Update `from langchain.experimental.module import Class` to `from langchain_experimental.module import Class`.","message":"Components previously found under `langchain.experimental` have been moved to the `langchain_experimental` package. This requires updating import paths for any code referencing these modules.","severity":"breaking","affected_versions":"<0.0.x (before 'langchain_experimental' package split), all versions if not migrated"},{"fix":"Exercise caution when deploying experimental features to production. Regularly check the official LangChain documentation and GitHub for updates and potential changes. Pin exact versions for production deployments.","message":"The `langchain-experimental` package is designed for 'research and experimental uses' and its components are subject to frequent changes. APIs within this package may not offer the same stability guarantees as core `langchain` and can introduce breaking changes even in minor versions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always review experimental code for security implications. Implement robust sandboxing, input validation, and output sanitization, especially when integrating with sensitive systems or user-controlled inputs. Consult security best practices for LLM applications.","message":"Portions of the code in `langchain-experimental` may be dangerous if not properly deployed in a sandboxed environment. This is due to the nature of experimental LLM applications that can generate and execute code, interact with external systems, or process untrusted input.","severity":"breaking","affected_versions":"All versions"},{"fix":"Thoroughly audit components that handle database interactions, code generation, or any form of dynamic execution. Be extremely cautious with features that involve `eval()` or similar dynamic code execution, and ensure strong input sanitization and validation.","message":"Historical vulnerabilities, such as CVE-2024-21513 affecting versions 0.0.15 to 0.0.20, have highlighted potential arbitrary code execution risks (e.g., through `eval` calls in `VectorSQLDatabaseChain`). While specific CVEs are patched, the experimental nature means similar risks could emerge in new features.","severity":"gotcha","affected_versions":"All versions (as a general caution, specific CVEs are version-dependent)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}