Skip to content

Commit

Permalink
Rename (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored Aug 22, 2024
1 parent a196347 commit 8c8d0a9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BaseMessage } from "@langchain/core/messages";
import { Annotation } from "./annotation.js";
import { messagesStateReducer } from "./message.js";

export const MessagesState = Annotation.Root({
export const MessagesAnnotation = Annotation.Root({
messages: Annotation<BaseMessage[]>({
reducer: messagesStateReducer,
default: () => [],
Expand Down
2 changes: 1 addition & 1 deletion langgraph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import { initializeAsyncLocalStorageSingleton } from "./setup/async_local_storag
initializeAsyncLocalStorageSingleton();

export * from "./web.js";
export { MessagesState } from "./graph/messages_state.js";
export { MessagesAnnotation } from "./graph/messages_annotation.js";
4 changes: 2 additions & 2 deletions langgraph/src/prebuilt/react_agent_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { BaseCheckpointSaver } from "../checkpoint/base.js";
import { END, START, StateGraph } from "../graph/index.js";
import { MessagesState } from "../graph/messages_state.js";
import { MessagesAnnotation } from "../graph/messages_annotation.js";
import { CompiledStateGraph, StateGraphArgs } from "../graph/state.js";
import { All } from "../pregel/types.js";
import { ToolNode } from "./tool_node.js";
Expand All @@ -40,7 +40,7 @@ export type N = typeof START | "agent" | "tools";
export type CreateReactAgentParams = {
llm: BaseChatModel;
tools:
| ToolNode<typeof MessagesState.State>
| ToolNode<typeof MessagesAnnotation.State>
| (StructuredToolInterface | RunnableToolLike)[];
messageModifier?:
| SystemMessage
Expand Down
10 changes: 5 additions & 5 deletions langgraph/src/prebuilt/tool_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RunnableConfig, RunnableToolLike } from "@langchain/core/runnables";
import { StructuredToolInterface } from "@langchain/core/tools";
import { RunnableCallable } from "../utils.js";
import { END } from "../graph/graph.js";
import { MessagesState } from "../graph/messages_state.js";
import { MessagesAnnotation } from "../graph/messages_annotation.js";

export type ToolNodeOptions = {
name?: string;
Expand All @@ -17,7 +17,7 @@ export type ToolNodeOptions = {
};

export class ToolNode<
T extends BaseMessage[] | typeof MessagesState.State
T extends BaseMessage[] | typeof MessagesAnnotation.State
> extends RunnableCallable<T, T> {
/**
A node that runs the tools requested in the last AIMessage. It can be used
Expand All @@ -41,9 +41,9 @@ export class ToolNode<
}

private async run(
input: BaseMessage[] | typeof MessagesState.State,
input: BaseMessage[] | typeof MessagesAnnotation.State,
config: RunnableConfig
): Promise<BaseMessage[] | typeof MessagesState.State> {
): Promise<BaseMessage[] | typeof MessagesAnnotation.State> {
const message = Array.isArray(input)
? input[input.length - 1]
: input.messages[input.messages.length - 1];
Expand Down Expand Up @@ -92,7 +92,7 @@ export class ToolNode<
}

export function toolsCondition(
state: BaseMessage[] | typeof MessagesState.State
state: BaseMessage[] | typeof MessagesAnnotation.State
): "tools" | typeof END {
const message = Array.isArray(state)
? state[state.length - 1]
Expand Down

0 comments on commit 8c8d0a9

Please sign in to comment.