Skip to content

Conversation

mattf
Copy link
Collaborator

@mattf mattf commented Sep 2, 2025

What does this PR do?

it provides infrastructure for @webmethod endpoints that do not have / should not have a version prefix added, e.g. future openai endpoints.

Test Plan

ci

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 2, 2025
@mattf mattf marked this pull request as ready for review September 2, 2025 13:23
Copy link
Collaborator

@leseb leseb left a comment

Choose a reason for hiding this comment

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

So this essentially allows to call http://127.0.0.1:8321/ directly without v1?

@mattf
Copy link
Collaborator Author

mattf commented Sep 2, 2025

So this essentially allows to call http://127.0.0.1:8321/ directly without v1?

not directly. default is to include the version. on a per-@webmethod basis we can skip the prefix, e.g. @webmethod(route="openai/v1/chat/completions", add_version=False) would allow ...:8321/openai/v1/chat/completions

@@ -60,7 +60,9 @@ def get_all_api_routes(
# The __webmethod__ attribute is dynamically added by the @webmethod decorator
# mypy doesn't know about this dynamic attribute, so we ignore the attr-defined error
webmethod = method.__webmethod__ # type: ignore[attr-defined]
path = f"/{LLAMA_STACK_API_VERSION}/{webmethod.route.lstrip('/')}"
path = webmethod.route.lstrip("/")
Copy link
Contributor

Choose a reason for hiding this comment

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

is allowing v1 to be omitted something that is a norm? If so, I think this is nice as v1/openai/v1 is redundant. However, I am unsure if this Is something that'd play nicely with API stability down the line, or if this is something other project with API contracts regularly do.

Copy link
Contributor

Choose a reason for hiding this comment

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

is the goal of this "prettification" of the URL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what issues do you anticipate?

Copy link
Contributor

Choose a reason for hiding this comment

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

would a flexible prefix be a good option instead of boolean to set it v1 given the stability levels ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants