mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-24 08:32:24 +02:00
Merge pull request #44 from langchain-ai/nc/18jan/config-schema
Filter from config_schema properties provided by Pregel class
This commit is contained in:
@@ -195,10 +195,19 @@ class Pregel(
|
||||
|
||||
@property
|
||||
def config_specs(self) -> list[ConfigurableFieldSpec]:
|
||||
return get_unique_config_specs(
|
||||
[spec for node in self.nodes.values() for spec in node.config_specs]
|
||||
+ (self.checkpointer.config_specs if self.checkpointer is not None else [])
|
||||
)
|
||||
return [
|
||||
spec
|
||||
for spec in get_unique_config_specs(
|
||||
[spec for node in self.nodes.values() for spec in node.config_specs]
|
||||
+ (
|
||||
self.checkpointer.config_specs
|
||||
if self.checkpointer is not None
|
||||
else []
|
||||
)
|
||||
)
|
||||
# these are provided by the Pregel class
|
||||
if spec.id not in [CONFIG_KEY_READ, CONFIG_KEY_SEND]
|
||||
]
|
||||
|
||||
@property
|
||||
def InputType(self) -> Any:
|
||||
|
||||
@@ -19,7 +19,6 @@ from langchain_core.runnables.base import (
|
||||
from langchain_core.runnables.config import merge_configs
|
||||
from langchain_core.runnables.utils import ConfigurableFieldSpec
|
||||
|
||||
from langgraph.channels.base import BaseChannel
|
||||
from langgraph.constants import CONFIG_KEY_READ
|
||||
|
||||
|
||||
@@ -34,7 +33,7 @@ class ChannelRead(RunnableLambda):
|
||||
name=CONFIG_KEY_READ,
|
||||
description=None,
|
||||
default=None,
|
||||
annotation=Callable[[BaseChannel], Any],
|
||||
annotation=None,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class ChannelWrite(RunnablePassthrough):
|
||||
name=CONFIG_KEY_SEND,
|
||||
description=None,
|
||||
default=None,
|
||||
annotation=TYPE_SEND,
|
||||
annotation=None,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import operator
|
||||
import time
|
||||
import warnings
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from contextlib import contextmanager
|
||||
from typing import Annotated, Generator, Optional, TypedDict, Union
|
||||
@@ -43,6 +44,13 @@ def test_invoke_single_process_in_out(mocker: MockerFixture) -> None:
|
||||
|
||||
assert app.input_schema.schema() == {"title": "LangGraphInput", "type": "integer"}
|
||||
assert app.output_schema.schema() == {"title": "LangGraphOutput", "type": "integer"}
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("error") # raise warnings as errors
|
||||
assert app.config_schema().schema() == {
|
||||
"properties": {},
|
||||
"title": "LangGraphConfig",
|
||||
"type": "object",
|
||||
}
|
||||
assert app.invoke(2) == 3
|
||||
assert app.invoke(2, output_keys=["output"]) == {"output": 3}
|
||||
assert repr(app), "does not raise recursion error"
|
||||
|
||||
Reference in New Issue
Block a user