mirror of
https://github.com/langchain-ai/langgraphjs.git
synced 2026-07-22 17:15:25 -04:00
chore(prebuilt): deprecate createReactAgent (#1576)
This commit is contained in:
committed by
GitHub
parent
c9b0c79ef0
commit
5f9b5a0f41
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@langchain/langgraph-swarm": patch
|
||||
"@langchain/langgraph": patch
|
||||
---
|
||||
|
||||
chore(prebuilt): deprecate createReactAgent
|
||||
@@ -16,52 +16,6 @@ npm install @langchain/langgraph @langchain/core
|
||||
|
||||
To learn more about how to use LangGraph, check out [the docs](https://langchain-ai.github.io/langgraphjs/). We show a simple example below of how to create a ReAct agent.
|
||||
|
||||
```ts
|
||||
// npm install @langchain-anthropic
|
||||
import { createReactAgent } from "@langchain/langgraph/prebuilt";
|
||||
import { ChatAnthropic } from "@langchain/anthropic";
|
||||
import { tool } from "@langchain/core/tools";
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
const search = tool(
|
||||
async ({ query }) => {
|
||||
if (
|
||||
query.toLowerCase().includes("sf") ||
|
||||
query.toLowerCase().includes("san francisco")
|
||||
) {
|
||||
return "It's 60 degrees and foggy.";
|
||||
}
|
||||
return "It's 90 degrees and sunny.";
|
||||
},
|
||||
{
|
||||
name: "search",
|
||||
description: "Call to surf the web.",
|
||||
schema: z.object({
|
||||
query: z.string().describe("The query to use in your search."),
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
const model = new ChatAnthropic({
|
||||
model: "claude-3-7-sonnet-latest",
|
||||
});
|
||||
|
||||
const agent = createReactAgent({
|
||||
llm: model,
|
||||
tools: [search],
|
||||
});
|
||||
|
||||
const result = await agent.invoke({
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: "what is the weather in sf",
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
## Full-stack Quickstart
|
||||
|
||||
Get started quickly by building a full-stack LangGraph application using the [`create-agent-chat-app`](https://www.npmjs.com/package/create-agent-chat-app) CLI:
|
||||
|
||||
@@ -28,9 +28,8 @@ export OPENAI_API_KEY=<your_api_key>
|
||||
```ts
|
||||
import { z } from "zod";
|
||||
import { ChatOpenAI } from "@langchain/openai";
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import { tool, createReactAgent } from "langchain";
|
||||
import { MemorySaver } from "@langchain/langgraph";
|
||||
import { createReactAgent } from "@langchain/langgraph/prebuilt";
|
||||
import { createSwarm, createHandoffTool } from "@langchain/langgraph-swarm";
|
||||
|
||||
const model = new ChatOpenAI({ modelName: "gpt-4o" });
|
||||
|
||||
@@ -25,6 +25,8 @@ export type AgentNameMode = "inline";
|
||||
* If you're using an agent built with createReactAgent, name is automatically set.
|
||||
* If you're building a custom agent, make sure to set the name on the AI message returned by the LLM.
|
||||
*
|
||||
* @deprecated migrated to `langchain` package.
|
||||
*
|
||||
* @param message - Message to add agent name formatting to
|
||||
* @returns Message with agent name formatting
|
||||
*
|
||||
@@ -93,6 +95,8 @@ export function _addInlineAgentName<T extends BaseMessageLike>(
|
||||
|
||||
/**
|
||||
* Remove explicit name and content XML tags from the AI message content.
|
||||
*
|
||||
* @deprecated migrated to `langchain` package.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
@@ -180,6 +184,8 @@ export function _removeInlineAgentName<T extends BaseMessage>(message: T): T {
|
||||
* Attach formatted agent names to the messages passed to and from a language model.
|
||||
*
|
||||
* This is useful for making a message history with multiple agents more coherent.
|
||||
*
|
||||
* * @deprecated migrated to `langchain` package.
|
||||
*
|
||||
* NOTE: agent name is consumed from the message.name field.
|
||||
* If you're using an agent built with createReactAgent, name is automatically set.
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
* Configuration interface that defines what actions are allowed for a human interrupt.
|
||||
* This controls the available interaction options when the graph is paused for human input.
|
||||
*
|
||||
* @deprecated Use `HumanInterruptConfig` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
||||
* Update your import to `import { HumanInterruptConfig } from "langchain";`
|
||||
*
|
||||
* @property {boolean} allow_ignore - Whether the human can choose to ignore/skip the current step
|
||||
* @property {boolean} allow_respond - Whether the human can provide a text response/feedback
|
||||
* @property {boolean} allow_edit - Whether the human can edit the provided content/state
|
||||
@@ -18,6 +21,9 @@ export interface HumanInterruptConfig {
|
||||
* Represents a request for human action within the graph execution.
|
||||
* Contains the action type and any associated arguments needed for the action.
|
||||
*
|
||||
* @deprecated Use `ActionRequest` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
||||
* Update your import to `import { ActionRequest } from "langchain/prebuilt/interrupt";`
|
||||
*
|
||||
* @property {string} action - The type or name of action being requested (e.g., "Approve XYZ action")
|
||||
* @property {Record<string, any>} args - Key-value pairs of arguments needed for the action
|
||||
*/
|
||||
@@ -31,6 +37,9 @@ export interface ActionRequest {
|
||||
* Represents an interrupt triggered by the graph that requires human intervention.
|
||||
* This is passed to the `interrupt` function when execution is paused for human input.
|
||||
*
|
||||
* @deprecated Use `HumanInterrupt` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
||||
* Update your import to `import { HumanInterrupt } from "langchain/prebuilt/interrupt";`
|
||||
*
|
||||
* @property {ActionRequest} action_request - The specific action being requested from the human
|
||||
* @property {HumanInterruptConfig} config - Configuration defining what actions are allowed
|
||||
* @property {string} [description] - Optional detailed description of what input is needed
|
||||
@@ -44,6 +53,9 @@ export interface HumanInterrupt {
|
||||
/**
|
||||
* The response provided by a human to an interrupt, which is returned when graph execution resumes.
|
||||
*
|
||||
* @deprecated Use `HumanResponse` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
||||
* Update your import to `import { HumanResponse } from "langchain/prebuilt/interrupt";`
|
||||
*
|
||||
* @property {("accept"|"ignore"|"response"|"edit")} type - The type of response:
|
||||
* - "accept": Approves the current state without changes
|
||||
* - "ignore": Skips/ignores the current step
|
||||
|
||||
@@ -46,6 +46,10 @@ import { END, Send, START } from "../constants.js";
|
||||
import { withAgentName } from "./agentName.js";
|
||||
import type { InteropZodToStateDefinition } from "../graph/zod/meta.js";
|
||||
|
||||
/**
|
||||
* @deprecated `AgentState` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
||||
* Update your import to `import { AgentState } from "langchain";`
|
||||
*/
|
||||
export interface AgentState<
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
StructuredResponseType extends Record<string, any> = Record<string, any>
|
||||
@@ -474,6 +478,10 @@ type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> =
|
||||
? AnnotationRoot<InteropZodToStateDefinition<A>>
|
||||
: never;
|
||||
|
||||
/**
|
||||
* @deprecated `CreateReactAgentParams` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
||||
* Update your import to `import { CreateReactAgentParams } from "langchain";`
|
||||
*/
|
||||
export type CreateReactAgentParams<
|
||||
A extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -614,6 +622,9 @@ export type CreateReactAgentParams<
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated `createReactAgent` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
||||
* Update your import to `import { createReactAgent } from "langchain";`
|
||||
*
|
||||
* Creates a StateGraph agent that relies on a chat model utilizing tool calling.
|
||||
*
|
||||
* @example
|
||||
|
||||
@@ -33,6 +33,9 @@ const isSendInput = (input: unknown): input is { lg_tool_call: ToolCall } =>
|
||||
typeof input === "object" && input != null && "lg_tool_call" in input;
|
||||
|
||||
/**
|
||||
* @deprecated `ToolNode` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
||||
* Update your import to `import { ToolNode } from "langchain";`
|
||||
*
|
||||
* A node that runs the tools requested in the last AIMessage. It can be used
|
||||
* either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
||||
* tool calls are requested, they will be run in parallel. The output will be
|
||||
@@ -301,6 +304,9 @@ export class ToolNode<T = any> extends RunnableCallable<T, T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use new `ToolNode` from {@link https://www.npmjs.com/package/langchain langchain} package instead.
|
||||
*/
|
||||
export function toolsCondition(
|
||||
state: BaseMessage[] | typeof MessagesAnnotation.State
|
||||
): "tools" | typeof END {
|
||||
|
||||
Reference in New Issue
Block a user