add arguments to chat agent executor

This commit is contained in:
Harrison Chase
2024-04-29 14:58:25 -07:00
parent 32ac2fdacb
commit d12c2bae6b
5 changed files with 22 additions and 18 deletions
+1 -3
View File
@@ -15,9 +15,7 @@ from typing import (
from langchain_core.runnables import Runnable
from langchain_core.runnables.base import RunnableLike
from langchain_core.runnables.config import RunnableConfig
from langchain_core.runnables.graph import (
Node as RunnableGraphNode,
)
from langchain_core.runnables.graph import Node as RunnableGraphNode
from langgraph.channels.ephemeral_value import EphemeralValue
from langgraph.checkpoint import BaseCheckpointSaver
+14 -3
View File
@@ -1,5 +1,5 @@
import json
from typing import Annotated, Sequence, TypedDict, Union
from typing import Annotated, Optional, Sequence, TypedDict, Union
from langchain_core.language_models import LanguageModelLike
from langchain_core.messages import BaseMessage, FunctionMessage
@@ -7,6 +7,7 @@ from langchain_core.runnables import RunnableLambda
from langchain_core.tools import BaseTool
from langchain_core.utils.function_calling import convert_to_openai_function
from langgraph.checkpoint import BaseCheckpointSaver
from langgraph.graph import END, StateGraph
from langgraph.graph.graph import CompiledGraph
from langgraph.graph.message import add_messages
@@ -134,7 +135,12 @@ def create_function_calling_executor(
def create_tool_calling_executor(
model: LanguageModelLike, tools: Union[ToolExecutor, Sequence[BaseTool]]
model: LanguageModelLike,
tools: Union[ToolExecutor, Sequence[BaseTool]],
checkpointer: Optional[BaseCheckpointSaver] = None,
interrupt_before: Optional[Sequence[str]] = None,
interrupt_after: Optional[Sequence[str]] = None,
debug: bool = False,
) -> CompiledGraph:
"""Creates a graph that works with a chat model that utilizes tool calling.
@@ -231,4 +237,9 @@ def create_tool_calling_executor(
# Finally, we compile it!
# This compiles it into a LangChain Runnable,
# meaning you can use it as you would any other runnable
return workflow.compile()
return workflow.compile(
checkpointer=checkpointer,
interrupt_before=interrupt_before,
interrupt_after=interrupt_after,
debug=debug,
)
+4 -8
View File
@@ -116,8 +116,7 @@ class Channel:
*,
key: Optional[str] = None,
tags: Optional[list[str]] = None,
) -> PregelNode:
...
) -> PregelNode: ...
@overload
@classmethod
@@ -127,8 +126,7 @@ class Channel:
*,
key: None = None,
tags: Optional[list[str]] = None,
) -> PregelNode:
...
) -> PregelNode: ...
@classmethod
def subscribe_to(
@@ -1212,8 +1210,7 @@ def _prepare_next_tasks(
processes: Mapping[str, PregelNode],
channels: Mapping[str, BaseChannel],
for_execution: Literal[False],
) -> tuple[Checkpoint, list[PregelTaskDescription]]:
...
) -> tuple[Checkpoint, list[PregelTaskDescription]]: ...
@overload
@@ -1222,8 +1219,7 @@ def _prepare_next_tasks(
processes: Mapping[str, PregelNode],
channels: Mapping[str, BaseChannel],
for_execution: Literal[True],
) -> tuple[Checkpoint, list[PregelExecutableTask]]:
...
) -> tuple[Checkpoint, list[PregelExecutableTask]]: ...
def _prepare_next_tasks(
+2 -4
View File
@@ -10,8 +10,6 @@ class SerializerProtocol(Protocol):
Valid implementations include the `pickle`, `json` and `orjson` modules.
"""
def dumps(self, obj: Any) -> bytes:
...
def dumps(self, obj: Any) -> bytes: ...
def loads(self, data: bytes) -> Any:
...
def loads(self, data: bytes) -> Any: ...
+1
View File
@@ -1,4 +1,5 @@
"""Main entrypoint into package."""
from importlib import metadata
try: