mirror of
https://github.com/langchain-ai/langserve.git
synced 2026-07-18 10:54:29 -04:00
Error after stream_log endpoint with MongoDBAtlasVectorSearch (+ how to print the actual prompt?) #136
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 @pprobst on GitHub (Mar 12, 2024).
Hello. Currently, when I'm using MongoDBAtlasVectorSearch as a retriever, I get the following error when using the Playground.
However, when I use
invokedirectly, it works properly and I get the expected result.The chain I have is currently this (only the relevant code excerpts):
Also: I'm okay not using the playground since invoke seems to be working fine, but how can I print the actual, final prompt sent to OpenAI after a POST on
http://localhost:8000/openai/invoke? I need to make sure the prompt I'm sending is correct, but I can't figure out the callback system with LangServe. Back when I was using only LangChain, I had a custom callback that I passed withchain.invoke(), but I don't know if this is possible here -- at least, it's not obvious to me. Is there a way to get the full prompt back with the reply, something like:Thanks.
@pprobst commented on GitHub (Mar 12, 2024):
Furthermore: if I use
invokedirectly in code, this is the error I get (which is strange, as it seems to be working fine with the POST):The invoke works properly if I disable the vectorstore.
@eyurtsev commented on GitHub (Mar 14, 2024):
I suspect issue with the retriever returning non serializable content.
Would you mind sharing an example document with me? Does it contain an objectId attribute? does it appear in the metadata?
The playground relies on the astream_log API rather than the invoke API.
The astream_log API ends up sending information about intermediate steps as well.
What you can do is in
add_routesspecify which steps information should be included from usingyou can assign assign names to runnables using
runnable.with_config({'run_name': 'my_name'})Try using
ainvokeinstead. The endpoint is called "invoke" but the server uses async code so it's actually using theainvokepath@pprobst commented on GitHub (Mar 17, 2024):
Sure. Here's an example of a retrieved document (with full text and embedding omitted for brevity).
ObjectIdappears in the metadata under the key_id, and it's probably what's causing the issue in the playground.@eyurtsev commented on GitHub (Mar 20, 2024):
you can add a runnable lambda and cast the _id to a string that should fix the serialization issue locally.
but should be fixed in the source itself -- no reason to be using an ObjectId there