mirror of
https://github.com/langchain-ai/langserve.git
synced 2026-07-18 10:54:29 -04:00
Input Not Automatically Recognized in Playground #76
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 @TomDarmon on GitHub (Dec 26, 2023).
Originally assigned to: @eyurtsev on GitHub.
Problem Description
I am currently working with LangChain and Langserve and have encountered an issue with the input recognition in the Langserve playground. I've constructed a query chain as follows:
However, when I attempt to use the playground feature of Langserve, the input "question" is not automatically recognized. This is illustrated in the screenshot below:
The chain functions correctly outside of the playground and or when requesting the API. The issue seems to be specific to the playground environment, where I am unable to specify the input.
Suspected Cause
I suspect the issue arises because
prompt_for_queryis not positioned as the first Runnable in the chain.I changed the order of the chain with the prompt as the first Runnable and the "questions" input is recognized :
But the chain fails because the order of Runnables is not viable anymore.
Questions
Any insights or solutions to this problem would be greatly appreciated, thanks !
@TomDarmon commented on GitHub (Dec 27, 2023):
I have found a workaround as the input_type is not recognized, we can specify the input schema using a pydantic model using the
with_typesmethod of the chain.There is the trick, the pydantic model needs to inherit from a custom model from langserve and not the default
BaseModel, else it won't be recognized. The working code for my use case is as follow:Edit: I am not closing the issue on purpose, as this behavior is not optimal and documentation is hard to found :(
@eyurtsev commented on GitHub (Dec 28, 2023):
Thanks for reporting!
Our type inference isn't clever enough to determine what the type of the input should be if using RunnablePassthrough. So whenever you use RunnablePassthrough define an input type explicitly.
BaseModelshould work fine. If you're able to include a minimally reproducible script that shows otherwise, I'll be able to investigate further, but I wasn't able to reproduce any issues with BaseModel.