Skip to main content

An integration package connecting Bodo and LangChain

Project description

LangChain-Bodo

This package contains the LangChain integration with Bodo DataFrames, an open source, high performance DataFrame library that functions as a drop-in replacement for Pandas.

With just a single-line-of-code change, Bodo DataFrames automatically accelerates and scales Pandas code;

simply replace:

import pandas as pd

with:

import bodo.pandas as pd

Under the hood, Bodo DataFrames uses lazy evaluation to optimize sequences of Pandas operations, streams data through operators to enable processing larger-than-memory datasets, and leverages MPI-based high-performance computing technology for efficient parallel execution that can easily scale from laptop to large cluster.

Installation

pip install -U langchain-bodo

No additional credentials/configurations are required.

Agent Toolkits

[!NOTE] Bodo DataFrames agents call the Python agent under the hood, which executes LLM generated Python code. Use with caution.

Bodo DataFrames agents are similar to Pandas agents except agent-generated code operates on Bodo DataFrames to answer questions on larger datasets. Because Bodo DataFrames is mostly compatible with Pandas, it is an ideal target for LLM code generation that's easy to verify, efficient, and scalable beyond the typical limitations of Pandas.

This example uses the Titanic dataset which can be found at https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv.

import bodo.pandas as pd
from langchain_bodo import create_bodo_dataframes_agent
from langchain_openai import OpenAI

df = pd.read_csv("titanic.csv")

agent = create_bodo_dataframes_agent(OpenAI(temperature=0), df, verbose=True)

agent.invoke("What was the average age of the male passengers?")

Sample Output:

> Entering new AgentExecutor chain...
Thought: I need to filter the dataframe to only include male passengers and then calculate the average age.
Action: python_repl_ast
Action Input: df[df['Sex'] == 'male']['Age'].mean()30.72664459161148I now know the final answer
Final Answer: The average age of the male passengers is 30.73 years old.

> Finished chain.

You can also pass one or more Pandas DataFrames to agents:

from langchain_bodo import create_bodo_dataframes_agent
from langchain_openai import OpenAI
import pandas

df = pandas.read_csv("titanic.csv")
df2 = df.copy()

agent = create_bodo_dataframes_agent(OpenAI(temperature=0), [df, df2], verbose=True)

For more details refer to Bodo DataFrames API documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_bodo-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_bodo-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file langchain_bodo-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_bodo-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.12.6 Darwin/22.5.0

File hashes

Hashes for langchain_bodo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 18d7614e42a358cfc05dd9fe500a68fdb2b354a2891b9e61e730c3b02d1cb629
MD5 283d2cc4e8c0f4bf6361a71ef2d48733
BLAKE2b-256 adff3bed5a2d462b7fb1e087aeae0c398df140197435faa50d8712faae5efb82

See more details on using hashes here.

File details

Details for the file langchain_bodo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: langchain_bodo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.12.6 Darwin/22.5.0

File hashes

Hashes for langchain_bodo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 608165f90e56fe99bd97efe6db4864444e2badb590591983baca9e0254f46d15
MD5 33f702f3fa56724f2f2ea3d7273fac2f
BLAKE2b-256 52e50a54bb3794f85123d6ff62f751001b863f7a8405f9fadf90fab9bfcff356

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page