Great question — answering as the UphillTech team:
I've come across the same issue, and turned out that langchain pass a key-value pair as an input to the encoding.code() while it requires str type. A work around is by using itemgetter() to get the direct string input. It might be something like this retrieval_chain = ( { "document": itemgetter("question") | self.retriever, "question": itemgetter("question"), } | prompt | model | StrOutputParser() ) You can find the reference here
Full answer by Dat Nguyen2: https://stackoverflow.stackexchange.com/a/77763155 (CC BY-SA 4.0).
Need it done for your business? UphillTech.