langgraph

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Path B — LangGraph graph nodes for automatic memory injection, mirroring the Python langgraph/nodes.py on the main branch. Wire the returned NodeFuncs into the host's own StateGraph (graph.AddNode) over a state with a "messages" channel (channels.MessagesReducer, []messages.Message).

Shared runtime helpers for the LangGraph integration (paths A and B), mirroring Python's langgraph/_runtime.py on the main branch. Keeps Engine lifecycle and workspace resolution in one place so the two paths stay consistent and have a single seam against Engine.

Package langgraph integrates ladyM as a memory layer for langchain-golang LangGraph hosts — the Go port of the Python langgraph module (main branch).

Two paths, mirroring the Python module:

  • Path A (Tools): CreateTools returns LangChain tools wrapping ladyM long-term memory; the LLM decides when to recall / remember (ReAct-style, e.g. via agents.CreateAgent).
  • Path B (Nodes): CreateRecallNode / CreateRetainNode return graph NodeFuncs for automatic per-turn memory injection, wired into the host's own StateGraph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRecallNode

func CreateRecallNode(eng *engine.Engine, topK int, prefix string, wsFn WorkspaceFunc) lcgraph.NodeFunc

CreateRecallNode returns a graph node that recalls against the latest message and prepends a SystemMessage to state["messages"], mirroring Python's create_recall_node. Emits no update when there are no hits.

func CreateRetainNode

func CreateRetainNode(eng *engine.Engine, wsFn WorkspaceFunc) lcgraph.NodeFunc

CreateRetainNode returns a graph node that stores the latest human+AI turn into long-term memory (subject to ladyM's attention gate), mirroring Python's create_retain_node. For per-request multi-user isolation (a resolved workspace different from the engine default) a short-lived workspace-bound Engine is built per call and closed afterwards.

func CreateTools

func CreateTools(eng *engine.Engine, workspace string, defaultTopK int) ([]lctools.Tool, error)

CreateTools builds LangChain tools backed by ladyM memory: [recall_memory, remember_fact, search_code]. Each tool closes over the given Engine; workspace overrides the engine's default workspace (empty keeps the engine default). Mirrors Python's create_ladym_tools.

func ResolveEngine

func ResolveEngine(src any, workspace string) (*engine.Engine, error)

ResolveEngine returns a ready-to-use Engine from flexible factory input, mirroring Python's resolve_engine:

  • *engine.Engine — returned as-is (caller owns lifecycle); workspace is IGNORED — the engine's own Config.Workspace wins. Pass a *config.Config or db path instead if you need a different workspace.
  • *config.Config — new Engine from a shallow copy; a non-empty workspace overrides cfg.Workspace.
  • string — treated as a db path over config.Default(); workspace honored.
  • nil — config.Default() (offline hashing embedding); workspace honored.

Any other type is an error.

Types

type WorkspaceFunc

type WorkspaceFunc func(rt lgruntime.Runtime) string

WorkspaceFunc resolves the ladyM workspace for a node run, mirroring Python's per-request isolation via config["configurable"]["user_id"]. A nil WorkspaceFunc uses the engine's default workspace.

func WorkspaceFromUserID

func WorkspaceFromUserID() WorkspaceFunc

WorkspaceFromUserID returns a WorkspaceFunc that resolves the ladyM workspace from the run-scoped context's "user_id" field, mirroring Python's resolve_workspace reading config["configurable"]["user_id"]. An empty result falls back to the engine's default workspace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL