Replies: 2 comments
-
I have found a workaround as the input_type is not recognized, we can specify the input schema using a pydantic model using the There is the trick, the pydantic model needs to inherit from a custom model from langserve and not the default from langserve import CustomUserType
...
class Question(CustomUserType):
question: str
query_chain = (
prompt_for_query
| {"question": RunnablePassthrough()}
| RunnablePassthrough.assign(table_name=get_available_table)
| RunnablePassthrough.assign(schema=get_table_schema)
| model
| StrOutputParser()
).with_types(input_type=Question) Edit: I am not closing the issue on purpose, as this behavior is not optimal and documentation is hard to found :( |
Beta Was this translation helpful? Give feedback.
-
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.
|
Beta Was this translation helpful? Give feedback.
-
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_query
is 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 !
Beta Was this translation helpful? Give feedback.
All reactions