I get this error message
<code><ipython-input-141-b8110c573881> in <cell line: 1>()
----> 1 final_chain.invoke({"question":"Count of Agencies?"})
25 frames
/usr/local/lib/python3.10/dist-packages/tiktoken/core.py in encode_ordinary(self, text)
67 """
68 try:
---> 69 return self._core_bpe.encode_ordinary(text)
70 except UnicodeEncodeError:
71 # See comment in encode
TypeError: argument 'text': 'dict' object cannot be converted to 'PyString'
</code>
<code><ipython-input-141-b8110c573881> in <cell line: 1>()
----> 1 final_chain.invoke({"question":"Count of Agencies?"})
25 frames
/usr/local/lib/python3.10/dist-packages/tiktoken/core.py in encode_ordinary(self, text)
67 """
68 try:
---> 69 return self._core_bpe.encode_ordinary(text)
70 except UnicodeEncodeError:
71 # See comment in encode
TypeError: argument 'text': 'dict' object cannot be converted to 'PyString'
</code>
<ipython-input-141-b8110c573881> in <cell line: 1>()
----> 1 final_chain.invoke({"question":"Count of Agencies?"})
25 frames
/usr/local/lib/python3.10/dist-packages/tiktoken/core.py in encode_ordinary(self, text)
67 """
68 try:
---> 69 return self._core_bpe.encode_ordinary(text)
70 except UnicodeEncodeError:
71 # See comment in encode
TypeError: argument 'text': 'dict' object cannot be converted to 'PyString'
while invoking retriever_chain.invoke(“actual question string”). The response is generated without error,but while invoking it from final_chain.invoke({“question”:”actual question”}). Getting an typeerror.
This is the code:
<code>vectorstore = Chroma.from_documents(documents, embedding_function)
retriever = vectorstore.as_retriever()
retriever_chain = (
{"context": retriever, "question": RunnablePassthrough()}
| retriever_prompt
| llm
| StrOutputParser()
)
final_chain = (RunnablePassthrough.assign(context=retriever_chain, table_names_to_assign = table_chain) | generate_sql_query)
</code>
<code>vectorstore = Chroma.from_documents(documents, embedding_function)
retriever = vectorstore.as_retriever()
retriever_chain = (
{"context": retriever, "question": RunnablePassthrough()}
| retriever_prompt
| llm
| StrOutputParser()
)
final_chain = (RunnablePassthrough.assign(context=retriever_chain, table_names_to_assign = table_chain) | generate_sql_query)
</code>
vectorstore = Chroma.from_documents(documents, embedding_function)
retriever = vectorstore.as_retriever()
retriever_chain = (
{"context": retriever, "question": RunnablePassthrough()}
| retriever_prompt
| llm
| StrOutputParser()
)
final_chain = (RunnablePassthrough.assign(context=retriever_chain, table_names_to_assign = table_chain) | generate_sql_query)
I tried to pass question to a retrieval chain and question is passed as a dict, but it must be a string.
New contributor
Tharun Manogaran is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.