How to add playground while using APIHandler? #467
-
I am trying similar use case with https://github.com/langchain-ai/langserve/blob/main/examples/api_handler_examples/server.py |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
When you use the APIHandler you are responsible for creating the endpoints. It provides flexibility to control the request path completely, but at the cost of extra work to create the endpoints manually.
https://github.com/langchain-ai/langserve/blob/main/langserve/server.py#L231 Take a look at the code to see how it registers the playground endpoint. Make sure to assign a correct path to the runnable when using APIHandler since that's needed to server playground assets. |
Beta Was this translation helpful? Give feedback.
When you use the APIHandler you are responsible for creating the endpoints. It provides flexibility to control the request path completely, but at the cost of extra work to create the endpoints manually.
add_routes
is a wrapper around APIHandler to automatically register all the needed endpoints.https://github.com/langchain-ai/langserve/blob/main/langserve/server.py#L231
Take a look at the code to see how it registers the playground endpoint.
Make sure to assign a correct path to the runnable when using APIHandler since that's needed to server playground assets.