From bacd7d65bc2a0854397e8a78619725997e19349d Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Fri, 6 Sep 2024 11:26:01 -0400 Subject: [PATCH] x --- langserve/api_handler.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/langserve/api_handler.py b/langserve/api_handler.py index 329e8a76..9f9d75cb 100644 --- a/langserve/api_handler.py +++ b/langserve/api_handler.py @@ -181,9 +181,6 @@ async def _unpack_request_config( credentials to a runnable. The RunnableConfig is presented in its dictionary form. Note that only keys in `config_keys` will be modifiable by this function. - config_keys: keys that are accepted by the server. This is used to - make sure that the server doesn't allow any keys that it doesn't want - to allow. """ config_dicts = [] for config in client_sent_configs: @@ -195,7 +192,6 @@ async def _unpack_request_config( config_dicts.append(model(**config).dict()) else: raise TypeError(f"Expected a string, dict or BaseModel got {type(config)}") - config = merge_configs(*config_dicts) if "configurable" in config and config["configurable"]: if "configurable" not in config_keys: @@ -232,7 +228,7 @@ def _update_config_with_defaults( """Set up some baseline configuration for the underlying runnable.""" # Currently all defaults are non-overridable - overridable_default_config: RunnableConfig = {} + overridable_default_config = RunnableConfig() metadata = { "__useragent": request.headers.get("user-agent"), @@ -260,10 +256,11 @@ def _update_config_with_defaults( } metadata.update(hosted_metadata) - non_overridable_default_config: RunnableConfig = { - "run_name": run_name, - "metadata": metadata, - } + non_overridable_default_config = RunnableConfig( + run_name=run_name, + metadata=metadata, + ) + # merge_configs is last-writer-wins, so we specifically pass in the # overridable configs first, then the user provided configs, then # finally the non-overridable configs @@ -272,6 +269,7 @@ def _update_config_with_defaults( incoming_config, non_overridable_default_config, ) + # run_id may have been set by user (and accepted by server) or # it may have been by the user on the server request path. # If it's not set, we'll generate a new one. @@ -805,8 +803,6 @@ async def invoke( with any other configuration. It's the last to be written, so it will override any other configuration. """ - from langchain_core.runnables.config import var_child_runnable_config - # We do not use the InvokeRequest model here since configurable runnables # have dynamic schema -- so the validation below is a bit more involved. config, input_ = await self._get_config_and_input(