Skip to main content

A LangChain agent middleware that provides a plain-text scratchpad/notepad.

Project description

LangChain Notepad Middleware

A production-grade LangChain middleware that provides a plain-text persistent "scratchpad" (notepad) for agents to store intermediate state across multi-hop tasks.

Installation

pip install langchain-notepad-middleware

Usage

from langchain.agents import create_agent
from langchain_middleware_notepad import NotePadMiddleware

# Create an agent with the middleware
agent = create_agent(
    model="openai:gpt-4o",
    tools=[...],  # Your other tools
    middleware=[NotePadMiddleware()],
)

How it Works

The middleware injects a system prompt instructing the model to use the notepad for scratchpad memory. It also registers 5 tools for manipulating the notepad state:

  1. notepad_append(text): Append text to the note.
  2. notepad_replace(text): Overwrite the entire note.
  3. notepad_read(): Read the current note content.

The state is stored in a simple string field notepad within the agent state.

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_notepad_middleware-0.1.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

langchain_notepad_middleware-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_notepad_middleware-0.1.1.tar.gz.

File metadata

File hashes

Hashes for langchain_notepad_middleware-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aa12bfe05d6dc05c171359105f98adf3ba31bebc49f895212d921b7aabad6711
MD5 d73f9c38b4ed740dd0cf15afb6085b67
BLAKE2b-256 6ce2481a2c5bdb3783b707e29f657eb28b3b451a972cb269190a563db667ba5b

See more details on using hashes here.

File details

Details for the file langchain_notepad_middleware-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_notepad_middleware-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60a0a8b7ad9ac9004571333cc534f7a28d92d763c66eaceb7e5266f57696f3d8
MD5 2a416c97d7fbd2ab3fd827e2edc3501e
BLAKE2b-256 fc3f478f6dc336d34fed184a4c6b05ebf87b9b311e3cd05221be8751e2119acd

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