mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-22 07:32:25 +02:00
Lint
This commit is contained in:
@@ -110,12 +110,9 @@ ChannelTypePlaceholder = object()
|
||||
|
||||
class ManagedValueMapping(dict[str, ManagedValue]):
|
||||
def replace_runtime_values(self, step: int, values: Union[dict[str, Any], Any]):
|
||||
print("replace_runtime_values", values)
|
||||
if isinstance(values, dict):
|
||||
for key, value in values.items():
|
||||
for chan, mv in self.items():
|
||||
print("chan", chan, "mv", mv, "v", mv(step), "value", value)
|
||||
print(mv, mv.runtime, mv(step) is value)
|
||||
if mv.runtime and mv(step) is value:
|
||||
values[key] = {RUNTIME_PLACEHOLDER: chan}
|
||||
elif hasattr(values, "__dir__") and callable(values.__dir__):
|
||||
|
||||
@@ -4106,6 +4106,7 @@ def test_state_graph_packets(
|
||||
)
|
||||
|
||||
def agent(data: AgentState) -> AgentState:
|
||||
assert isinstance(data["session"], httpx.Client)
|
||||
return {
|
||||
"messages": model.invoke(data["messages"]),
|
||||
"something_extra": "hi there",
|
||||
@@ -4113,6 +4114,7 @@ def test_state_graph_packets(
|
||||
|
||||
# Define decision-making logic
|
||||
def should_continue(data: AgentState) -> str:
|
||||
assert isinstance(data["session"], httpx.Client)
|
||||
assert (
|
||||
data["something_extra"] == "hi there"
|
||||
), "nodes can pass extra data to their cond edges, which isn't saved in state"
|
||||
@@ -4130,6 +4132,7 @@ def test_state_graph_packets(
|
||||
my_session: httpx.Client
|
||||
|
||||
def tools_node(input: ToolInput, config: RunnableConfig) -> AgentState:
|
||||
assert isinstance(input["my_session"], httpx.Client)
|
||||
tool_call = input["call"]
|
||||
time.sleep(tool_call["args"].get("idx", 0) / 10)
|
||||
output = tools_by_name[tool_call["name"]].invoke(tool_call["args"], config)
|
||||
|
||||
@@ -3892,7 +3892,7 @@ async def test_state_graph_packets() -> None:
|
||||
|
||||
class AgentState(TypedDict):
|
||||
messages: Annotated[list[BaseMessage], add_messages]
|
||||
session: Annotated[httpx.Client, Context(httpx.Client)]
|
||||
session: Annotated[httpx.AsyncClient, Context(httpx.AsyncClient)]
|
||||
|
||||
@tool()
|
||||
def search_api(query: str) -> str:
|
||||
@@ -3937,6 +3937,7 @@ async def test_state_graph_packets() -> None:
|
||||
|
||||
# Define decision-making logic
|
||||
def should_continue(data: AgentState) -> str:
|
||||
assert isinstance(data["session"], httpx.AsyncClient)
|
||||
# Logic to decide whether to continue in the loop or exit
|
||||
if tool_calls := data["messages"][-1].tool_calls:
|
||||
return [
|
||||
@@ -3951,6 +3952,7 @@ async def test_state_graph_packets() -> None:
|
||||
my_session: httpx.Client
|
||||
|
||||
async def tools_node(input: ToolInput, config: RunnableConfig) -> AgentState:
|
||||
assert isinstance(input["my_session"], httpx.AsyncClient)
|
||||
tool_call = input["call"]
|
||||
await asyncio.sleep(tool_call["args"].get("idx", 0) / 10)
|
||||
output = await tools_by_name[tool_call["name"]].ainvoke(
|
||||
|
||||
Reference in New Issue
Block a user