Registry / llm-agents / langchain-experimental

langchain-experimental

JSON →
library0.4.2pypypi✓ verified 23d ago

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.

pip install langchain-experimental
INSTALL
IMPORT
SIG · LANGCHAIN-EXPERIME
L
langchain-experimental
llm-agentspythonv0.4.2
Install
16.2s avg
Import
4184ms
Disk
390MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 4.332s · 349.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 16.2s · import 4.036s · 418MB
390MB installed
● package 390MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

create_pandas_dataframe_agent
from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent
from langchain.agents.agent_toolkits import create_pandas_dataframe_agent
Experimental agents and toolkits were moved from `langchain` to `langchain-experimental`.

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.

import os import pandas as pd from langchain_openai import ChatOpenAI from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent # Set your OpenAI API key from environment variables # For testing, you can uncomment and replace with your key, but use environment variables in production. # os.environ["OPENAI_API_KEY"] = "sk-..." # Ensure OPENAI_API_KEY is set in your environment if os.environ.get("OPENAI_API_KEY") is None: print("Warning: OPENAI_API_KEY environment variable is not set. Quickstart may fail.") # In a real application, you'd handle this more robustly, e.g., raise an error or prompt the user. # Load a sample DataFrame data = { "name": ["Alice", "Bob", "Charlie", "David"], "age": [25, 30, 35, 28], "city": ["New York", "London", "Paris", "New York"] } df = pd.DataFrame(data) # Initialize the LLM (requires langchain-openai to be installed) llm = ChatOpenAI(model="gpt-4", temperature=0) # Create the pandas dataframe agent agent = create_pandas_dataframe_agent(llm, df, verbose=True) # Run a query on the DataFrame query = "What is the average age of the people from New York?" print(f"\nQuery: {query}") response = agent.invoke({"input": query}) print(f"Response: {response['output']}") query_count = "How many people are from London?" print(f"\nQuery: {query_count}") response_count = agent.invoke({"input": query_count}) print(f"Response: {response_count['output']}")
Debug
Known issues
breakingComponents previously found under `langchain.experimental` have been moved to the `langchain_experimental` package. This requires updating import paths for any code referencing these modules.
fix
Update `from langchain.experimental.module import Class` to `from langchain_experimental.module import Class`.
affects: <0.0.x (before 'langchain_experimental' package split), all versions if not migrated
gotchaThe `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.
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.
affects: All versions
breakingPortions 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.
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.
affects: All versions
gotchaHistorical 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.
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.
affects: All versions (as a general caution, specific CVEs are version-dependent)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'langchain_experimental'
This error occurs because the `langchain-experimental` package is not installed in your Python environment, or a specific submodule (like `langchain_experimental.agents`) is not found due to a missing installation or incorrect import path.
fix
You need to install the `langchain-experimental` package. Ensure your environment is active if using virtual environments.
```bash
pip install langchain-experimental
```
ImportError: create_python_agent has been moved to langchain_experimental
This error indicates that functions or classes like `create_python_agent` and `PythonREPLTool` have been relocated from the main `langchain` package to the `langchain-experimental` package due to refactoring and modularization.
fix
You need to update your import statement to pull these components from `langchain_experimental` and ensure `langchain-experimental` is installed.
```python
from langchain_experimental.agents.agent_toolkits import create_python_agent
from langchain_experimental.tools.python.tool import PythonREPLTool
```
ModuleNotFoundError: No module named 'langchain.experimental'
This specific `ModuleNotFoundError` happens when you try to import `experimental` as a submodule of `langchain`, but it has been split into its own top-level package, `langchain_experimental`.
fix
You must import directly from the `langchain_experimental` package. First, ensure it's installed, then change your import statement.
```python
# Incorrect (old way)
# from langchain.experimental.autonomous_agents import AutoGPT

# Correct
from langchain_experimental.autonomous_agents import AutoGPT
```
AttributeError: module 'langchain' has no attribute 'verbose'
This `AttributeError` typically arises from significant API changes and refactoring in the LangChain ecosystem, where features like 'verbose' might have been moved, removed, or their access pattern altered in newer versions, often related to the split into `langchain-core`, `langchain-community`, and specific integration packages.
fix
This often requires updating your LangChain related packages and adjusting your code to the newer API. For verbosity in agents/chains, it's usually passed as a parameter during initialization or invocation. Check the official documentation for the specific component you are using. For example, for `AgentExecutor`:
```python
# Old approach (might cause error)
# agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True)

# New approach (pass verbose directly during creation or invoke)
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools)
# To enable verbose logging:
# agent_executor.invoke(inputs, {'verbose': True})
# Or check specific component's docs for how to set verbosity
```
ModuleNotFoundError: No module named 'langchain_experimental.autonomous_agents'
This specific module, which contains components like `AutoGPT`, is either misspelled in the import path, the `langchain-experimental` package isn't correctly installed, or its path may have changed in a different version than anticipated.
fix
Ensure `langchain-experimental` is installed (`pip install langchain-experimental`), and verify the exact import path from the official documentation for your installed version (e.g., `from langchain_experimental.autonomous_agents import AutoGPT`).
Upgrade
Version history
0.4.2latest on PyPI · released May 22, 2026
Audit
Dependencies
langchainrequiredCore LangChain framework, as 'langchain-experimental' extends its capabilities.
langchain-corerequiredFoundational components for the LangChain ecosystem.
langchain-openaioptionalIntegration with OpenAI models, commonly used in examples and quickstarts.
pandasoptionalRequired for specific experimental components like the Pandas DataFrame Agent.
Agent activity
38 hits · last 30 days
node
34
OpenAI (training)
1
Resources
langchain-experimental — pip install langchain-experimental · libregistry