-
Notifications
You must be signed in to change notification settings - Fork 218
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
Temporary workaround for generating unique model names #47
Conversation
@@ -85,8 +107,17 @@ def _resolve_model(type_: Union[Type, BaseModel], default_name: str) -> Type[Bas | |||
|
|||
hash_ = model.schema_json() | |||
|
|||
if model.__name__ in _SEEN_NAMES and hash_ not in _MODEL_REGISTRY: | |||
# If the model name has been seen before, but the model itself is different |
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.
is the order models get loaded in deterministic? Could this result in an indeterministic openapi spec depending on that order?
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.
Depends on order of add_routes
invocation so I think deterministic in this case. [This is because we're only registering top level model names (which is also why we can't resolve the full issue)]
langserve/server.py
Outdated
@@ -192,18 +208,22 @@ def add_routes( | |||
"Use `pip install sse_starlette` to install." | |||
) | |||
|
|||
namespace = path or "" | |||
|
|||
model_namespace = path.strip("/").replace("/", "_") |
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 there restrictions on pydantic names?
- if so, there are more characters in paths that we might need to handle
- if not, can we skip this and pass around the
path
instead? Might be more straightforward than a newnamespace
concept
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.
Good points. Will check wasn't being methodlogical here
Co-authored-by: Erick Friis <[email protected]>
If two schema different schemas share the same name, fastapi openapi documentation fails.
This is a temporary work-around for openapi spec generation purposes. It will work only for top level model names.
We've bumped into this issue while hosting 2 runnables that start with a PromptTemplate (same name for the schema), but have different template variables (so the schema are different).
We'll need to find a better solution to handle nested models. This should be good for now as it'll allow users to deploy the common case correctly.