mirror of
https://github.com/langchain-ai/langserve.git
synced 2026-07-01 20:14:01 -04:00
Unable to open playground page when using add_routes() with FastAPI's APIRouter #152
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @StreetLamb on GitHub (Mar 30, 2024).
Originally assigned to: @eyurtsev on GitHub.
I'm using APIRouter to separate my routes like so:
I am able to access
http://localhost /api/v1/chat/invokeproperly. Howeverhttp://localhost/api/v1/chat/playgroundbrings me to a blank page. I get the error:Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.On inspecting network, issue seems to be that the page is incorrectly fetching the playground assets from the base URL
http://localhost/playground/assets/index-dbc96538.jsinstead ofhttp://localhost/api/v1/chat/playground/assets/index-dbc96538.js.My workaround for now is to move all the prefixes into add_routes instead:
Ideally, it should be able to infer the correct path when working with prefixes.
@eyurtsev commented on GitHub (Mar 30, 2024):
Thanks! Will take a look on Monday. Which version of langserve are you on?
@StreetLamb commented on GitHub (Mar 30, 2024):
Thanks for looking into it! I'm using 0.0.51
@eyurtsev commented on GitHub (Mar 30, 2024):
@StreetLamb I am unable to reproduce, would you be kind enough to help me create an MRE with the unit tests?
https://github.com/langchain-ai/langserve/pull/579/files#diff-0796d94e9487fc7c014344ad4a1150ba02c980991a7433ad811f3fef23d843dfR63
@StreetLamb commented on GitHub (Apr 1, 2024):
Hi @eyurtsev, raised a PR to update the playground unit tests as requested.
@SwenRanj commented on GitHub (May 14, 2024):
Hi, I am having the same issue on langserve version 0.1.1.
I noticed that the playground works when you supply a
pathto theadd_routesfunction, but not when you use theprefixininclude_router(like the sample that @StreetLamb provided.Any news on this issue?