-
Notifications
You must be signed in to change notification settings - Fork 237
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
add default configs for all served runnables #209
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks
langserve/server.py
Outdated
@@ -554,6 +562,38 @@ def _route_name_with_config(name: str) -> str: | |||
InvokeResponse = create_invoke_response_model(model_namespace, output_type_) | |||
BatchResponse = create_batch_response_model(model_namespace, output_type_) | |||
|
|||
def _update_config_with_defaults(incomingConfig: RunnableConfig) -> RunnableConfig: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move it into a standalone function?
langserve/server.py
Outdated
is_hosted = os.environ.get("HOSTED_LANGSERVE_ENABLED", "false").lower() == "true" | ||
if is_hosted: | ||
hosted_metadata = { | ||
"Commit SHA": os.environ.get("HOSTED_LANGSERVE_GIT_COMMIT", ""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the keys follow a particular format for rendering purposes / name collision purposes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, I started a thread internally to discuss the rendering questions. My worry on naming collision proof names is that they will be hard to read and thus hard to filter on
langserve/server.py
Outdated
@@ -684,6 +725,7 @@ async def batch( | |||
{k: v for k, v in config_.items() if k in config_keys} | |||
for config_ in get_config_list(configs, len(inputs_)) | |||
] | |||
print(configs_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(configs_) |
This looks pretty reasonable to me |
langserve/server.py
Outdated
@@ -122,6 +123,45 @@ def _unpack_request_config( | |||
) | |||
|
|||
|
|||
def _update_config_with_defaults( | |||
path: str, incomingConfig: RunnableConfig, endpoint: Optional[str] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path: str, incomingConfig: RunnableConfig, endpoint: Optional[str] = None | |
path: str, incomingConfig: RunnableConfig, *, endpoint: Optional[str] = None |
langserve/server.py
Outdated
is_hosted = os.environ.get("HOSTED_LANGSERVE_ENABLED", "false").lower() == "true" | ||
if is_hosted: | ||
hosted_metadata = { | ||
"Commit SHA": os.environ.get("HOSTED_LANGSERVE_GIT_COMMIT", ""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming convention for these is different from langserve version etc. Should we use the same style? (I don't care which style is used)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the current convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just __langserve
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah but whatever you prefer -- i just chose arbitrarily
langserve/server.py
Outdated
@@ -735,7 +787,7 @@ async def stream( | |||
err_event = {} | |||
validation_exception: Optional[BaseException] = None | |||
try: | |||
config, input_ = await _get_config_and_input(request, config_hash) | |||
config, input_ = await _get_config_and_input(request, config_hash, "stream") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config, input_ = await _get_config_and_input(request, config_hash, "stream") | |
config, input_ = await _get_config_and_input(request, config_hash, endpoint="stream") |
@@ -474,6 +515,11 @@ def add_routes( | |||
f"If specifying path please start it with a `/`" | |||
) | |||
|
|||
if "run_name" in config_keys: | |||
raise ValueError( | |||
"Cannot configure run_name. Please remove it from config_keys." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we care about key collisions arising from identical path on 2 different API routers? (I think it's fine actually)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh this is a good point... we probably should?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We derive it from request.url.path
and always get the config based on the request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might limit future support for complex paths tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with whatever you choose here -- just wanted to surface that collisions could potentially appear
30cb986
to
1ee54e8
Compare
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
@@ -132,6 +133,56 @@ def _unpack_request_config( | |||
) | |||
|
|||
|
|||
def _update_config_with_defaults( | |||
path: str, | |||
incomingConfig: RunnableConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incomingConfig: RunnableConfig, | |
incoming_config: RunnableConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(python naming convention)
@@ -794,7 +840,9 @@ async def stream( | |||
err_event = {} | |||
validation_exception: Optional[BaseException] = None | |||
try: | |||
config, input_ = await _get_config_and_input(request, config_hash) | |||
config, input_ = await _get_config_and_input( | |||
request, config_hash, endpoint="stream" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we missing a similar config override for stream_log endpoint?
This reverts commit b60b52d.
Configures the run name to be the path, and some information about the associated repo to be in the metadata of the traced run