Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use typing_extensions typeddict #1869

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions libs/langgraph/langgraph/prebuilt/chat_agent_executor.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
from typing import (
Annotated,
Callable,
Literal,
Optional,
Sequence,
Type,
TypedDict,
TypeVar,
Union,
)
from typing import Callable, Literal, Optional, Sequence, Type, TypeVar, Union

Check notice on line 1 in libs/langgraph/langgraph/prebuilt/chat_agent_executor.py

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

......................................... fanout_to_subgraph_10x: Mean +- std dev: 59.2 ms +- 1.6 ms ......................................... WARNING: the benchmark result may be unstable * the standard deviation (6.40 ms) is 11% of the mean (56.4 ms) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. fanout_to_subgraph_10x_sync: Mean +- std dev: 56.4 ms +- 6.4 ms ......................................... fanout_to_subgraph_10x_checkpoint: Mean +- std dev: 77.0 ms +- 1.3 ms ......................................... fanout_to_subgraph_10x_checkpoint_sync: Mean +- std dev: 81.4 ms +- 0.8 ms ......................................... fanout_to_subgraph_100x: Mean +- std dev: 552 ms +- 8 ms ......................................... fanout_to_subgraph_100x_sync: Mean +- std dev: 502 ms +- 5 ms ......................................... fanout_to_subgraph_100x_checkpoint: Mean +- std dev: 765 ms +- 27 ms ......................................... fanout_to_subgraph_100x_checkpoint_sync: Mean +- std dev: 790 ms +- 6 ms ......................................... react_agent_10x: Mean +- std dev: 41.5 ms +- 3.2 ms ......................................... react_agent_10x_sync: Mean +- std dev: 29.8 ms +- 0.3 ms ......................................... react_agent_10x_checkpoint: Mean +- std dev: 53.2 ms +- 1.4 ms ......................................... react_agent_10x_checkpoint_sync: Mean +- std dev: 43.0 ms +- 3.3 ms ......................................... react_agent_100x: Mean +- std dev: 414 ms +- 8 ms ......................................... react_agent_100x_sync: Mean +- std dev: 331 ms +- 2 ms ......................................... react_agent_100x_checkpoint: Mean +- std dev: 926 ms +- 10 ms ......................................... react_agent_100x_checkpoint_sync: Mean +- std dev: 827 ms +- 11 ms ......................................... wide_state_25x300: Mean +- std dev: 20.4 ms +- 0.3 ms ......................................... wide_state_25x300_sync: Mean +- std dev: 12.8 ms +- 0.1 ms ......................................... wide_state_25x300_checkpoint: Mean +- std dev: 240 ms +- 8 ms ......................................... wide_state_25x300_checkpoint_sync: Mean +- std dev: 235 ms +- 14 ms ......................................... wide_state_15x600: Mean +- std dev: 23.7 ms +- 0.3 ms ......................................... wide_state_15x600_sync: Mean +- std dev: 14.8 ms +- 0.2 ms ......................................... wide_state_15x600_checkpoint: Mean +- std dev: 417 ms +- 12 ms ......................................... wide_state_15x600_checkpoint_sync: Mean +- std dev: 421 ms +- 17 ms ......................................... wide_state_9x1200: Mean +- std dev: 23.7 ms +- 0.4 ms ......................................... wide_state_9x1200_sync: Mean +- std dev: 14.8 ms +- 0.1 ms ......................................... wide_state_9x1200_checkpoint: Mean +- std dev: 269 ms +- 8 ms ......................................... wide_state_9x1200_checkpoint_sync: Mean +- std dev: 267 ms +- 15 ms

Check notice on line 1 in libs/langgraph/langgraph/prebuilt/chat_agent_executor.py

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+----------------------------------------+---------+-----------------------+ | Benchmark | main | changes | +========================================+=========+=======================+ | wide_state_15x600_checkpoint | 420 ms | 417 ms: 1.01x faster | +----------------------------------------+---------+-----------------------+ | react_agent_100x_sync | 333 ms | 331 ms: 1.01x faster | +----------------------------------------+---------+-----------------------+ | react_agent_10x_sync | 30.0 ms | 29.8 ms: 1.01x faster | +----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_sync | 503 ms | 502 ms: 1.00x faster | +----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint_sync | 81.6 ms | 81.4 ms: 1.00x faster | +----------------------------------------+---------+-----------------------+ | wide_state_15x600_sync | 14.8 ms | 14.8 ms: 1.00x slower | +----------------------------------------+---------+-----------------------+ | wide_state_9x1200 | 23.6 ms | 23.7 ms: 1.00x slower | +----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint | 76.6 ms | 77.0 ms: 1.00x slower | +----------------------------------------+---------+-----------------------+ | Geometric mean | (ref) | 1.00x faster | +----------------------------------------+---------+-----------------------+ Benchmark hidden because not significant (20): wide_state_25x300_checkpoint_sync, fanout_to_subgraph_10x_sync, fanout_to_subgraph_10x, fanout_to_subgraph_100x, wide_state_9x1200_sync, wide_state_9x1200_checkpoint_sync, react_agent_10x_checkpoint_sync, react_agent_100x, react_agent_100x_checkpoint, react_agent_10x, wide_state_25x300_checkpoint, wide_state_25x300, react_agent_10x_checkpoint, fanout_to_subgraph_100x_checkpoint_sync, wide_state_25x300_sync, wide_state_15x600, wide_state_15x600_checkpoint_sync, fanout_to_subgraph_100x_checkpoint, wide_state_9x1200_checkpoint, react_agent_100x_checkpoint_sync

from langchain_core.language_models import BaseChatModel
from langchain_core.messages import AIMessage, BaseMessage, SystemMessage, ToolMessage
from langchain_core.runnables import Runnable, RunnableConfig, RunnableLambda
from langchain_core.tools import BaseTool
from typing_extensions import Annotated, TypedDict

from langgraph._api.deprecation import deprecated_parameter
from langgraph.graph import StateGraph
Expand Down
Loading