Skip to content
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

Merged
merged 6 commits into from
Nov 20, 2023

Conversation

jakerachleff
Copy link
Contributor

@jakerachleff jakerachleff commented Nov 10, 2023

Configures the run name to be the path, and some information about the associated repo to be in the metadata of the traced run

@cla-bot cla-bot bot added the cla-signed label Nov 10, 2023
Copy link
Collaborator

@eyurtsev eyurtsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks

@@ -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:
Copy link
Collaborator

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?

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", ""),
Copy link
Collaborator

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?

Copy link
Contributor Author

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

@@ -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_)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(configs_)

@eyurtsev
Copy link
Collaborator

This looks pretty reasonable to me

@@ -122,6 +123,45 @@ def _unpack_request_config(
)


def _update_config_with_defaults(
path: str, incomingConfig: RunnableConfig, endpoint: Optional[str] = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
path: str, incomingConfig: RunnableConfig, endpoint: Optional[str] = None
path: str, incomingConfig: RunnableConfig, *, endpoint: Optional[str] = None

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", ""),
Copy link
Collaborator

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)

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just __langserve?

Copy link
Collaborator

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

@@ -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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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."
Copy link
Collaborator

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)

Copy link
Contributor Author

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Copy link
Collaborator

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

@jakerachleff jakerachleff force-pushed the 2023-11-10-format-langsmith-runs branch from 30cb986 to 1ee54e8 Compare November 20, 2023 21:45
jakerachleff and others added 2 commits November 20, 2023 13:50
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
incomingConfig: RunnableConfig,
incoming_config: RunnableConfig,

Copy link
Collaborator

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"
Copy link
Collaborator

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?

@jakerachleff jakerachleff merged commit b60b52d into main Nov 20, 2023
@jakerachleff jakerachleff deleted the 2023-11-10-format-langsmith-runs branch November 20, 2023 21:59
jakerachleff added a commit that referenced this pull request Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants