Remove existing route functionality (opposite to add_routes method) #189

Open
opened 2026-02-16 00:19:16 -05:00 by yindo · 1 comment
Owner

Originally created by @ghost on GitHub (May 28, 2024).

Hello. Sorry if this is duplicate issue, but I didn't find anything relevant inside a code / existing issues / documentation.

I would need to replace an existing route and create a new one (using add_routes) with the same name (because of different runnable), but it's not possible and ends up with the following error:

A runnable already exists at path: {path}. If adding multiple runnables make sure they have different paths.

https://github.com/langchain-ai/langserve/blob/1b389f075187395e4eb71dc7067bff812dc68269/langserve/server.py#L195

Is there any possibility to delete it first and add again with the same name ? Langserve keeps track of the paths internally , so my attempts to delete it manually from app routes didn't help in this case.

Thanks a lot!

Originally created by @ghost on GitHub (May 28, 2024). Hello. Sorry if this is duplicate issue, but I didn't find anything relevant inside a code / existing issues / documentation. I would need to replace an existing route and create a new one (using [add_routes](https://github.com/langchain-ai/langserve/blob/1b389f075187395e4eb71dc7067bff812dc68269/langserve/server.py#L258C5-L258C15)) with the same name (because of different runnable), but it's not possible and ends up with the following error: `A runnable already exists at path: {path}. If adding multiple runnables make sure they have different paths.` https://github.com/langchain-ai/langserve/blob/1b389f075187395e4eb71dc7067bff812dc68269/langserve/server.py#L195 Is there any possibility to delete it first and add again with the same name ? Langserve keeps track of the paths [internally ](https://github.com/langchain-ai/langserve/blob/1b389f075187395e4eb71dc7067bff812dc68269/langserve/server.py#L53), so my attempts to delete it manually from app routes didn't help in this case. Thanks a lot!
Author
Owner

@eyurtsev commented on GitHub (Jun 4, 2024):

This is not possible by design -- what's your use case?

If you need to do something more flexible you can use the underlying APIhandler

@eyurtsev commented on GitHub (Jun 4, 2024): This is not possible by design -- what's your use case? If you need to do something more flexible you can use the underlying `APIhandler`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langserve#189