mirror of
https://github.com/langchain-ai/langserve.git
synced 2026-07-18 10:54:29 -04:00
LangServe: 'invoke' Route Returns Empty Output, While Streaming Works #63
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 @VML-Kai on GitHub (Dec 7, 2023).
Originally assigned to: @eyurtsev on GitHub.
I'm building a very simple LangChain application that takes as an input a customer feedback string and categorizes it into the following pydantic class:
Here's how this should work, and it does:
This works very well, all good so far! Let's serve it:
Now comes the strange part, check this out. On the client side, streaming works:
But the regular invoke does not work, it delivers an empty output:
I'm pretty sure the problem is the output parser, as if I remove it from the chain, everything works perfectly fine, the invoke as well.
@VML-Kai commented on GitHub (Dec 8, 2023):
Currently using a workaround using FastAPI directly:
I think somehow .invoke isn't being called differently in langserve.
@eyurtsev commented on GitHub (Dec 8, 2023):
Hello @VML-Kai , thanks for the bug report.
Would you be able to tell me:
I'm wondering is whether the automatic type inference is failing when the parser is present and the chain is doing something weird.
If you're able to:
@eyurtsev commented on GitHub (Dec 8, 2023):
@VML-Kai I noticed that the URLs that you have a trailing slash
@danielcj commented on GitHub (Dec 17, 2023):
@VML-Kai I was experiencing the same thing, but it works as expected when declaring the output type.
Example on your code:
@eyurtsev commented on GitHub (Dec 21, 2023):
@danielcj thank you that's helpful! I'll try to reproduce!
@effusive-ai commented on GitHub (Jan 25, 2024):
I think I'm having this same problem but after some more investigation I'm not sure. Just a simple chain like this
I'm calling the route from the JS RemoteRunable class. I thought it was just invoke that wasn't working. But now I see both invoke and stream sometimes return a result and sometimes an empty string for the same call. I haven't been able to track down a pattern of why one call works and another doesn't. Just installed langserv yesterday so should be the latest version.
@PhillipsHoward commented on GitHub (Feb 14, 2024):
Hello all.
I have the same issue I think :
Defining this on server side :
Then on my "client" side, I try :
The response is always an empty {}, while logs in server indicates that everything works fine on server side. (I can see the output displayed in it)
My pip list about this :
Am I missing something ?
Thanks in advance !
EDIT :
As @VML-Kai suggested, it works fine with this workaround :
@realei commented on GitHub (Apr 29, 2024):
I have the same issue when I wrap Agent as a Langserve endpoint with
invokeendpointmy pip list:
@Aillian commented on GitHub (May 22, 2024):
is this issue solved? i am facing the same problem
@shreyasjha5706 commented on GitHub (May 28, 2024):
i had the same issue, @danielcj 's solution worked for me. Thanks!
@MarkEdmondson1234 commented on GitHub (Jul 10, 2024):
Same issue today with versions:
/stream endpoint works, /invoke to same chain has empty content:
Tried adding Output type, no change:
@manova commented on GitHub (Jul 18, 2024):
I'm having the same issue where stream returns a response but the invoke endpoint returns null. Are there any new findings as to the root cause of this?
@MarkEdmondson1234 commented on GitHub (Jul 18, 2024):
Mine got fixed putting the output class on the app function (eg making the endpoints) not the chain