### Install Dependencies Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/CONTRIBUTING.md Installs the necessary project dependencies using Yarn. ```bash yarn install ``` -------------------------------- ### Install LangGraph.js CLI Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/README.md Installs or runs the LangGraph.js CLI using npx. This is the primary method for accessing the CLI tools. ```bash npx @langchain/langgraph-cli ``` -------------------------------- ### Installing Project Dependencies with Yarn - Bash Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/README.md This command installs all required project dependencies using Yarn, ensuring that all necessary packages are available for building and running the LangGraph.js API and CLI. ```bash yarn install ``` -------------------------------- ### Langchain OpenAI Integration Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/tests/packaging_tests/faux/my_agent/requirements.txt Details on integrating Langchain with OpenAI models (like GPT-3.5, GPT-4) within LangGraphJS. Covers setup and usage in graph nodes for text generation and reasoning. ```javascript import { ChatOpenAI } from "langchain_openai"; const llm = new ChatOpenAI({ temperature: 0.7 }); const graph = new Graph() .addNode("generate_text", async () => { const response = await llm.invoke("Write a short poem about AI."); return response.content; }); console.log(graph.run()); ``` -------------------------------- ### LangGraph.js CLI Commands Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/README.md Provides a summary of the core commands available in the LangGraph.js CLI for managing applications. ```bash npx @langchain/langgraph-cli dev # Run LangGraph.js API server in development mode with hot reloading. ``` ```bash npx @langchain/langgraph-cli build # Build a Docker image for your LangGraph.js application. ``` ```bash npx @langchain/langgraph-cli up # Run LangGraph.js API server in Docker. ``` ```bash npx @langchain/langgraph-cli dockerfile # Generate a Dockerfile for custom deployments ``` -------------------------------- ### Build Project Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/CONTRIBUTING.md Builds the project using Yarn. ```bash yarn build ``` -------------------------------- ### Cloning LangGraph.js API Repository - Bash Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/README.md This command sequence clones the LangGraph.js API repository from GitHub and navigates into the newly cloned directory, preparing the environment for further development. ```bash git clone https://github.com/langchain-ai/langgraphjs-api.git cd langgraphjs-api ``` -------------------------------- ### LangGraphJS API Reference Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/tests/packaging_tests/faux/my_agent/requirements.txt Comprehensive API documentation for the LangGraphJS library. Includes details on Graph class methods, node definitions, edge configurations, and execution control. ```APIDOC Graph: __init__(config?: GraphConfig) Initializes a new Graph instance. config: Optional configuration object for the graph. addNode(nodeName: string, action: NodeAction, config?: NodeConfig) Adds a node to the graph. nodeName: The unique name for the node. action: The function or async function to execute for this node. config: Optional configuration for the node, e.g., { next: ['node1', 'node2'] }. addEdge(source: string, target: string, config?: EdgeConfig) Adds a directed edge between two nodes. source: The name of the source node. target: The name of the target node. config: Optional configuration for the edge. addConditionalEdges(source: string, condition: Condition, config?: EdgeConfig) Adds conditional edges from a source node. source: The name of the source node. condition: A function that returns the name of the next node. config: Optional configuration for the edges. run(inputs?: any, config?: RunConfig) Executes the graph. inputs: The initial inputs to the graph. config: Optional configuration for the run, e.g., { recursionLimit: 10 }. NodeAction: (state: any) => string | object | Promise Represents the action performed by a node. Condition: (state: any) => string Represents a function that determines the next node based on the current state. ``` -------------------------------- ### Langchain Community Integrations Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/tests/packaging_tests/faux/my_agent/requirements.txt Overview of various community-contributed integrations available for LangGraphJS, including tools, data sources, and custom LLMs. ```javascript // Example: Using a custom tool from langchain_community import { tool } from "langgraph/graph"; import { SomeCustomTool } from "langchain_community/tools"; const customTool = new SomeCustomTool(); const graph = new Graph() .addNode("use_tool", tool(customTool.invoke)); console.log(graph.run()); ``` -------------------------------- ### LangGraph.js CLI Configuration Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/README.md Illustrates the structure and key settings for the `langgraph.json` configuration file used by the CLI. ```json5 { // Required: Graph definitions graphs: { graph: "./src/graph.ts:graph", }, // Optional: Node version (20 only at the moment) node_version: "20", // Optional: Environment variables env: ".env", // Optional: Additional Dockerfile commands dockerfile_lines: [], } ``` -------------------------------- ### Building LangGraph.js API Project with Yarn - Bash Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/README.md This command initiates the build process for the LangGraph.js API and CLI project using Yarn, compiling the source code into distributable artifacts. ```bash yarn run build ``` -------------------------------- ### LangGraph.js CLI Configuration File (JSON) Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/README.md This JSON configuration file (`langgraph.json`) defines key settings for the LangGraph.js CLI. It includes required graph definitions, optional Node.js version, environment variable file path, and additional Dockerfile commands for custom builds. ```json { "graphs": { "graph": "./src/graph.ts:graph" }, "node_version": "20", "env": ".env", "dockerfile_lines": [] } ``` -------------------------------- ### LangGraphJS Core Concepts Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/tests/packaging_tests/faux/my_agent/requirements.txt Introduction to the fundamental building blocks of LangGraphJS, including graphs, nodes, and edges. This section explains how to define and structure agentic workflows. ```javascript import { Graph } from "langgraph"; const graph = new Graph(); graph.addNode("start", () => "Hello"); graph.addEdge("start", "end"); console.log(graph.run()); ``` -------------------------------- ### Generating Dockerfile for Custom Deployments (CLI) Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/README.md This command generates a Dockerfile, allowing for custom configurations and deployments of the LangGraph.js application. The `` parameter specifies the directory where the generated Dockerfile will be saved, enabling tailored container builds. ```bash npx @langchain/langgraph-cli dockerfile ``` -------------------------------- ### Langchain Anthropic Integration Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/tests/packaging_tests/faux/my_agent/requirements.txt Demonstrates how to integrate Langchain with Anthropic's Claude models within LangGraphJS. This includes setting up the Anthropic LLM and using it in graph nodes. ```javascript import { ChatAnthropic } from "langchain_anthropic"; const llm = new ChatAnthropic({ temperature: 0.8 }); const graph = new Graph() .addNode("agent", async () => { const response = await llm.invoke("What is LangGraph?"); return response.content; }); console.log(graph.run()); ``` -------------------------------- ### Running LangGraph.js API Tests with Yarn - Bash Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/README.md This command executes the test suite for the LangGraph.js API and CLI project using Yarn, verifying the functionality and stability of the codebase. ```bash yarn test ``` -------------------------------- ### Running LangGraph.js API Server in Docker (CLI) Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/README.md This command runs the LangGraph.js API server within a Docker container, leveraging the previously built Docker image. It provides an isolated and consistent environment for the application, suitable for testing or production deployment. ```bash npx @langchain/langgraph-cli up ``` -------------------------------- ### Tavily Search Tool Integration (Python) Source: https://github.com/langchain-ai/langgraphjs-api/blob/main/libs/langgraph-cli/tests/packaging_tests/faux/my_agent/requirements.txt Shows how to integrate the Tavily search tool with LangGraphJS using Python. This enables agents to perform web searches as part of their workflow. ```python from tavily import TavilyClient from langgraph.graph import Graph tavily = TavilyClient(api_key="YOUR_API_KEY") def search_tool(query: str): response = tavily.search(query=query) return response['results'] graph = Graph() graph.add_node("search", search_tool) graph.add_edge("search", "end") print(graph.run("What is LangGraph?")) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.