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:
Nuno Campos
2024-01-18 11:10:59 -08:00
committed by GitHub
4 changed files with 23 additions and 7 deletions
+13 -4
View File
@@ -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:
+1 -2
View File
@@ -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,
),
]
+1 -1
View File
@@ -43,7 +43,7 @@ class ChannelWrite(RunnablePassthrough):
name=CONFIG_KEY_SEND,
description=None,
default=None,
annotation=TYPE_SEND,
annotation=None,
),
]
+8
View File
@@ -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"