langchain-ai / langserve

LangServe 🦜️🏓
Other
1.79k stars 189 forks source link

Add ability to translate exceptions #481

Open eyurtsev opened 4 months ago

eyurtsev commented 4 months ago

Expose exception translation capability to allow users to provide their own logic for translating server side errors into client side errors

https://github.com/langchain-ai/langserve/blob/e1cec832da29173df89bfe50b35be8ce59b1a8b5/langserve/api_handler.py#L1214-L1214

Discussed in https://github.com/langchain-ai/langserve/discussions/473

Originally posted by **yw791772** February 21, 2024 Hi, I'm following the [astream method](https://github.com/langchain-ai/langserve/blob/54725a91edece67a61ac880f9f02239b6d81dd42/langserve/client.py#L617-L668) in the langserve client code, and I have a try catch around the async sse code. For testing purpose, I use an api key that has no quota, and I can see the 429 errors from the langserve app logs. But when I looking at the decoded message from [it](https://github.com/langchain-ai/langserve/blob/54725a91edece67a61ac880f9f02239b6d81dd42/langserve/client.py#L653) on the client side, I only see 500 with internal server error. Any guidance on how I can surface the 429 errors on the client side, so I can build specific around this error
yw791772 commented 4 months ago

2 of the most common use cases I encountered:

eyurtsev commented 4 months ago

https://github.com/langchain-ai/langserve/discussions/545

philbo commented 4 months ago

@eyurtsev do you have any ideas about how to approach implementing this? I can try to contribute a solution

ognjenAct commented 2 weeks ago

hii guys, any updates on this topic? or possible workaround?