Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
eyurtsev committed Sep 6, 2024
1 parent 387f82a commit bacd7d6
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions langserve/api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit bacd7d6

Please sign in to comment.