### CLI Commands for LangChain Build System Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/internal/build/README.md Provides examples of common CLI commands for the LangChain build system, including getting help, building all packages, using watch mode, building specific packages, and excluding packages. ```bash # Get help pnpm build:new --help ``` ```bash # Build all packages in the workspace pnpm build:new ``` ```bash # Build with watch mode for development pnpm build:new --watch ``` ```bash # Build specific packages pnpm build:new @langchain/core pnpm build:new @langchain/core langchain @langchain/openai ``` ```bash # Exclude packages from build pnpm build:new --exclude @langchain/community pnpm build:new -e @langchain/aws -e @langchain/openai ``` ```bash # Skip various build steps pnpm build:new --no-emit # Skip type declarations pnpm build:new --skip-unused # Skip unused dependency check pnpm build:new --skip-clean # Skip cleaning build directory pnpm build:new --skip-sourcemap # Skip sourcemap generation ``` -------------------------------- ### Install LangGraph Swarm Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/multi-agent.md Install the `langgraph-swarm` library using npm. ```bash npm install @langchain/langgraph-swarm ``` -------------------------------- ### Install dependencies Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/CONTRIBUTING.md Install project dependencies using pnpm. ```bash pnpm install ``` -------------------------------- ### Install PDE package Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/libs/prompt-decomposition-engine/README.md Install the core package using npm or yarn. ```bash npm install ava-langgraph-prompt-decomposition-engine # or yarn add ava-langgraph-prompt-decomposition-engine ``` -------------------------------- ### Install LangGraph Supervisor Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/multi-agent.md Install the `langgraph-supervisor` library using npm. ```bash npm install @langchain/langgraph-supervisor ``` -------------------------------- ### Install optional dependencies Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/libs/narrative-intelligence/README.md Install additional packages for LangGraph integration or Redis persistence. ```bash # For LangGraph integration npm install @langchain/langgraph # For Redis persistence npm install ioredis ``` -------------------------------- ### Install MCP Adapters Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/mcp.md Install the required library to enable MCP tool support in LangGraph. ```bash npm install @langchain/mcp-adapters ``` -------------------------------- ### Install LangGraph.js CLI with npx Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/langgraph_cli.md Install the LangGraph.js CLI using npx. This is a quick way to run the CLI without a global installation. ```bash npx @langchain/langgraph-cli ``` -------------------------------- ### Install AvaLangGraph Libraries Source: https://context7.com/avadisabelle/ava-langgraphjs/llms.txt Install the core AvaLangGraph libraries using npm or pnpm. ```bash # Using npm npm install ava-langgraph-prompt-decomposition-engine npm install ava-langgraph-inquiry-routing-engine npm install ava-langgraph-narrative-intelligence # Using pnpm pnpm add ava-langgraph-prompt-decomposition-engine pnpm add ava-langgraph-inquiry-routing-engine pnpm add ava-langgraph-narrative-intelligence ``` -------------------------------- ### Install Dependencies Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/tutorials/langgraph-platform/local-server.md Install project dependencies using yarn. ```bash $ yarn ``` -------------------------------- ### Install LangGraph SDKs Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/tutorials/langgraph-platform/local-server.md Commands to install the necessary SDKs for Python and JavaScript environments. ```shell $ pip install langgraph-sdk ``` ```shell $ yarn add @langchain/langgraph-sdk ``` -------------------------------- ### Launch LangGraph Server Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/tutorials/langgraph-platform/local-server.md Start the LangGraph API server in development mode. ```bash $ npx @langchain/langgraph-cli@latest dev ``` -------------------------------- ### Install Python MCP Library Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/mcp.md Install the Python MCP SDK to build custom tool servers. ```bash pip install mcp ``` -------------------------------- ### Install package dependencies Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/libs/narrative-intelligence/README.md Install the core package using npm or yarn. ```bash npm install ava-langgraph-narrative-intelligence # or yarn add ava-langgraph-narrative-intelligence ``` -------------------------------- ### Install package dependencies Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/libs/inquiry-routing-engine/README.md Install the core engine and its required peer dependencies. ```bash npm install ava-langgraph-inquiry-routing-engine ``` ```bash npm install ava-langchain-prompt-decomposition ava-langchain-inquiry-routing ``` -------------------------------- ### Run Next.js Development Server Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/internal/environment_tests/test-exports-vercel/README.md Commands to start the local development server using different package managers. ```bash npm run dev # or yarn dev # or pnpm dev ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/tutorials/langgraph-platform/local-server.md Example content for the .env file required for API authentication. ```bash LANGSMITH_API_KEY=lsv2... TAVILY_API_KEY=tvly-... ANTHROPIC_API_KEY=sk- OPENAI_API_KEY=sk-... ``` -------------------------------- ### Connect to Authenticated Deployments Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/how-tos/auth/custom_auth.md Examples of how to include authorization headers when connecting to the platform from various clients. ```python from langgraph_sdk import get_client my_token = "your-token" # In practice, you would generate a signed token with your auth provider client = get_client( url="http://localhost:2024", headers={"Authorization": f"Bearer {my_token}"} ) threads = await client.threads.search() ``` ```python from langgraph.pregel.remote import RemoteGraph my_token = "your-token" # In practice, you would generate a signed token with your auth provider remote_graph = RemoteGraph( "agent", url="http://localhost:2024", headers={"Authorization": f"Bearer {my_token}"} ) threads = await remote_graph.ainvoke(...) ``` ```javascript import { Client } from "@langchain/langgraph-sdk"; const my_token = "your-token"; // In practice, you would generate a signed token with your auth provider const client = new Client({ apiUrl: "http://localhost:2024", headers: { Authorization: `Bearer ${my_token}` }, }); const threads = await client.threads.search(); ``` ```javascript import { RemoteGraph } from "@langchain/langgraph/remote"; const my_token = "your-token"; // In practice, you would generate a signed token with your auth provider const remoteGraph = new RemoteGraph({ graphId: "agent", url: "http://localhost:2024", headers: { Authorization: `Bearer ${my_token}` }, }); const threads = await remoteGraph.invoke(...); ``` ```bash curl -H "Authorization: Bearer ${your-token}" http://localhost:2024/threads ``` -------------------------------- ### Launch local development server Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/deployment.md Start the LangGraph API server for local development and debugging. ```bash npx @langchain/langgraph-cli dev ``` -------------------------------- ### Install LangGraph.js CLI with bun Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/langgraph_cli.md Install the LangGraph.js CLI as a project dependency using bun. ```bash bun add @langchain/langgraph-cli ``` -------------------------------- ### Install LangGraph CLI Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/tutorials/langgraph-platform/local-server.md Install the LangGraph CLI tool via npx or globally via npm. ```bash $ npx @langchain/langgraph-cli@latest # Or install globally, will be available as `langgraphjs` $ npm install -g @langchain/langgraph-cli ``` -------------------------------- ### Install AgentEvals and LangChain Core Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/evals.md Install the necessary packages for using prebuilt evaluators. This includes agentevals and @langchain/core. ```bash npm install agentevals @langchain/core ``` -------------------------------- ### Install LangGraph.js CLI with pnpm Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/langgraph_cli.md Install the LangGraph.js CLI as a project dependency using pnpm. ```bash pnpm add @langchain/langgraph-cli ``` -------------------------------- ### Install LangGraph.js CLI with npm Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/langgraph_cli.md Install the LangGraph.js CLI as a project dependency using npm. ```bash npm install @langchain/langgraph-cli ``` -------------------------------- ### Run AvaLangGraph Example Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/README.md Conceptual example demonstrating how an AvaLangGraph component, specifically the InquiryRoutingGraph, might be invoked with a sample decomposition result. Full LangGraph integration requires defining StateGraph nodes and edges. ```typescript import { InquiryRoutingGraph } from "inquiry-routing-engine"; import { DecompositionResult } from "ava-langchain-prompt-decomposition"; // Assuming this comes from ChainStack async function runAvaLangGraphExample() { const sampleDecomposition: DecompositionResult = { primary: { action: "build", target: "knowledge graph", urgency: "high", confidence: 0.9 }, secondary: [], directions: { east: [], south: [], west: [], north: [] }, // Simplified for example actionStack: [], balance: 0.8, leadDirection: "north", neglectedDirections: [], ambiguities: [] }; const inquiryGraph = new InquiryRoutingGraph({ enforceCeremony: true }); const finalState = await inquiryGraph.invoke(sampleDecomposition); console.log("Inquiry Routing Final State:", finalState.status); if (finalState.ceremonyRequired) { console.log("Ceremony required. Human review initiated."); } else { console.log("Dispatched inquiries:", finalState.dispatchedInquiries); } } runAvaLangGraphExample(); ``` -------------------------------- ### Run AvaLangGraph Conceptual Example Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/getting-started.md Demonstrates initializing the InquiryRoutingGraph and invoking it with a decomposition result. ```typescript // This is a conceptual example for AvaLangGraph, showing how its engines work. // Full LangGraph integration would involve defining StateGraph nodes and edges. import { InquiryRoutingGraph } from "inquiry-routing-engine"; import { DecompositionResult } from "ava-langchain-prompt-decomposition"; // Assuming this comes from ChainStack async function runAvaLangGraphExample() { const sampleDecomposition: DecompositionResult = { primary: { action: "build", target: "knowledge graph", urgency: "high", confidence: 0.9 }, secondary: [], directions: { east: [], south: [], west: [], north: [] }, // Simplified for example actionStack: [], balance: 0.8, leadDirection: "north", neglectedDirections: [], ambiguities: [] }; const inquiryGraph = new InquiryRoutingGraph({ enforceCeremony: true }); const finalState = await inquiryGraph.invoke(sampleDecomposition); console.log("Inquiry Routing Final State:", finalState.status); if (finalState.ceremonyRequired) { console.log("Ceremony required. Human review initiated."); } else { console.log("Dispatched inquiries:", finalState.dispatchedInquiries); } } runAvaLangGraphExample(); ``` -------------------------------- ### Import entrypoint Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/CONTRIBUTING.md Example of importing a module from a LangGraph subpath. ```typescript import { Pregel } from "@langchain/langgraph/pregel"; ``` -------------------------------- ### Install LangGraph.js CLI with yarn Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/langgraph_cli.md Install the LangGraph.js CLI as a project dependency using yarn. ```bash yarn add @langchain/langgraph-cli ``` -------------------------------- ### Install AvaLangGraph Packages Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/README.md Commands for installing AvaLangGraph packages using npm, pnpm, or yarn. ```bash # Using npm npm install inquiry-routing-engine npm install prompt-decomposition-engine npm install narrative-intelligence # Using pnpm pnpm add inquiry-routing-engine pnpm add prompt-decomposition-engine pnpm add narrative-intelligence # Using yarn yarn add inquiry-routing-engine yarn add prompt-decomposition-engine yarn add narrative-intelligence ``` -------------------------------- ### Install project dependencies Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/deployment.md Install required packages for the LangGraph application and chat model support. ```shell yarn # install these to use initChatModel with Anthropic yarn add langchain yarn add @langchain/anthropic ``` -------------------------------- ### Full interrupt workflow example Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/human_in_the_loop.md A complete example showing graph construction, interrupt usage, and resuming with Command. ```typescript import { MemorySaver, Annotation, interrupt, Command, StateGraph } from "@langchain/langgraph"; // Define the graph state const StateAnnotation = Annotation.Root({ some_text: Annotation() }); function humanNode(state: typeof StateAnnotation.State) { const value = interrupt( // Any JSON serializable value to surface to the human. // For example, a question or a piece of text or a set of keys in the state { text_to_revise: state.some_text } ); return { // Update the state with the human's input some_text: value }; } // Build the graph const workflow = new StateGraph(StateAnnotation) // Add the human-node to the graph .addNode("human_node", humanNode) .addEdge("__start__", "human_node") // A checkpointer is required for `interrupt` to work. const checkpointer = new MemorySaver(); const graph = workflow.compile({ checkpointer }); // Using stream() to directly surface the `__interrupt__` information. for await (const chunk of await graph.stream( { some_text: "Original text" }, threadConfig )) { console.log(chunk); } // Resume using Command for await (const chunk of await graph.stream( new Command({ resume: "Edited text" }), threadConfig )) { console.log(chunk); } ``` ```typescript { __interrupt__: [ { value: { question: 'Please revise the text', some_text: 'Original text' }, resumable: true, ns: ['human_node:10fe492f-3688-c8c6-0d0a-ec61a43fecd6'], when: 'during' } ] } { human_node: { some_text: 'Edited text' } } ``` -------------------------------- ### Start LangGraph Development Server Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/langgraph_cli.md The `langgraph dev` command starts a lightweight development server without Docker. It supports hot reloading and in-memory state with local persistence, ideal for rapid local development and testing. ```bash langgraph dev ``` -------------------------------- ### Install LangGraph and LangChain Dependencies Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/agents.md Install the necessary LangGraph and LangChain packages using npm. ```bash npm install langchain @langchain/langgraph @langchain/anthropic ``` -------------------------------- ### Start LangGraph API Server with Docker Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/langgraph_cli.md Run the `langgraph up` command to start a local instance of the LangGraph API server in a Docker container. This requires Docker to be running and a LangSmith or license key. ```bash langgraph up ``` -------------------------------- ### Run documentation locally Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/CONTRIBUTING.md Commands to set up and serve the documentation site. ```bash cd docs ``` ```bash pip install -r docs-requirements.txt ``` ```bash make serve-docs ``` -------------------------------- ### Initialize LangGraph Project Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/how-tos/http/custom_middleware.md Command to scaffold a new LangGraph project using the CLI. ```bash npm create langgraph ``` -------------------------------- ### Build project Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/CONTRIBUTING.md Compile the project source code. ```bash pnpm build ``` -------------------------------- ### Install peer dependencies Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/libs/prompt-decomposition-engine/README.md Install required peer dependencies for full functionality. ```bash npm install ava-langchain-relational-intelligence ava-langgraph-narrative-intelligence # or yarn add ava-langchain-relational-intelligence ava-langgraph-narrative-intelligence ``` -------------------------------- ### Connect Studio Web UI to Custom Port Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/tutorials/langgraph-platform/local-server.md Example URL format for connecting the Studio Web UI to a server running on a non-default port. ```text https://smith.langchain.com/studio/baseUrl=http://localhost:8000 ``` -------------------------------- ### Navigate to project directory Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/CONTRIBUTING.md Change the current working directory to the project root. ```bash cd langgraph ``` -------------------------------- ### Install Hono Dependency Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/how-tos/http/custom_routes.md Install the `hono` package as a project dependency using npm. ```bash npm install hono ``` -------------------------------- ### Initialize a React Agent with Web Search Tool Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/tools.md Configures a LangGraph agent using the OpenAI GPT-4o-mini model and the web_search_preview prebuilt tool. ```ts import { createReactAgent } from "@langchain/langgraph/prebuilt"; import { initChatModel } from "langchain/chat_models/universal"; const llm = await initChatModel("openai:gpt-4o-mini"); const agent = createReactAgent({ llm, tools: [{ type: "web_search_preview" }], }); const response = await agent.invoke({ messages: ["What was a positive news story from today?"], }); ``` -------------------------------- ### Workflow stream output examples Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/functional_api.md Example outputs from the workflow stream during execution and interruption. ```typescript { write_essay: 'An essay about topic: cat' } ``` ```typescript { __interrupt__: [{ value: { essay: 'An essay about topic: cat', action: 'Please approve/reject the essay' }, resumable: true, ns: ['workflow:f7b8508b-21c0-8b4c-5958-4e8de74d2684'], when: 'during' }] } ``` -------------------------------- ### Build System Directory Structure Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/internal/build/README.md Illustrates the directory structure of the LangChain build system, showing the location of core files and plugins. ```tree infra/build/ ├── index.ts # Main build orchestrator ├── cli.ts # Command-line interface ├── types.ts # TypeScript type definitions ├── utils.ts # Utility functions ├── plugins/ │ ├── README.md # Plugin documentation │ ├── lc-secrets.ts # LangChain secrets scanning plugin │ ├── import-map.ts # Import map generation plugin │ └── import-constants.ts # Import constants generation plugin ├── package.json # Build system dependencies └── README.md # This documentation ``` -------------------------------- ### Scaffold a new LangGraph project Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/agents/deployment.md Use the CLI tool to initialize a new project directory structure. ```bash npm install -g create-langgraph create-langgraph path/to/your/app ``` -------------------------------- ### Install LangGraph CLI Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/how-tos/deploy-self-hosted.md Install the CLI tool required to build the Docker image for your LangGraph application. ```shell pip install -U langgraph-cli ``` -------------------------------- ### Install LangGraphJS Dependencies Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/tutorials/workflows/index.md Install the necessary LangGraphJS packages using yarn. Ensure you are using a compatible version of @langchain/langgraph. ```bash yarn add @langchain/langgraph @langchain/anthropic @langchain/core ``` -------------------------------- ### Initialize and run the decomposition pipeline Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/libs/prompt-decomposition-engine/README.md Demonstrates initializing the graph, analyzer, and gate, then executing the pipeline and evaluating the results. ```typescript import { DecompositionGraph, PerspectiveAnalyzer, CeremonyGate, } from "ava-langgraph-prompt-decomposition-engine"; const graph = new DecompositionGraph(); const analyzer = new PerspectiveAnalyzer(); const gate = new CeremonyGate(); // Run the full pipeline const state = await graph.invoke("Build a relational intelligence system..."); console.log("Decomposition Status:", state.status); // Analyze through three perspectives if (state.decomposition) { const perspectives = analyzer.analyze(state.decomposition); console.log("Lead Universe:", perspectives.leadUniverse); // Evaluate if ceremony is needed const verdict = gate.evaluate(state.decomposition, perspectives); if (verdict.decision === "hold") { console.log("Ceremony needed:", verdict.reasons); } else { console.log("Can proceed:", verdict.decision); } } ``` -------------------------------- ### Create LangGraph App Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/tutorials/langgraph-platform/local-server.md Initialize a new LangGraph project using the interactive CLI. ```shell $ npm create langgraph ``` -------------------------------- ### Install LangGraph SDK for Python Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/sdk.md Install the Python SDK using pip. This package is required to interact with the LangGraph Platform. ```bash pip install langgraph-sdk ``` -------------------------------- ### Install LangGraph SDK for JavaScript Source: https://github.com/avadisabelle/ava-langgraphjs/blob/main/docs/content/concepts/sdk.md Install the JavaScript SDK using yarn. This package is required for Node.js environments to interact with the LangGraph Platform. ```bash yarn add @langchain/langgraph-sdk ```