@cl.on_chat_start
async def start():
"""
Initializes the bot when a new chat starts.
This asynchronous function creates a new instance of the retrieval QA bot,
sends a welcome message, and stores the bot instance in the user's session.
"""
chain = qa_bot()
welcome_message = cl.Message(content="Starting the bot...")
await welcome_message.send()
welcome_message.content = (
"Hi, Welcome to Chat With Data."
)
await welcome_message.update()
cl.user_session.set("chain", chain)
return qa_chain
Error Issue
TypeError: Expected a Runnable, callable or dict.Instead got an unsupported type: <class 'NoneType'>
2024-05-06 10:21:04 - Translation file for en-GB not found. Using default translation en-US.
2024-05-06 10:21:05 - Translated markdown file for en-GB not found. Defaulting to chainlit.md.
2024-05-06 10:21:05 - Expected a Runnable, callable or dict.Instead got an unsupported type: <class 'NoneType'>
Traceback (most recent call last):
File "/home/anurag/conda3/envs/botgpt/lib/python3.8/site-packages/chainlit/utils.py", line 39, in wrapper
return await user_function(**params_values)
File "main.py", line 121, in start
chain = qa_bot()
File "main.py", line 110, in qa_bot
qa = retrieval_qa_chain(llm, retriever_instance)
File "main.py", line 99, in retrieval_qa_chain
context=retriever_instance | split_image_text_types_runnable
File "/home/anurag/conda3/envs/botgpt/lib/python3.8/site-packages/langchain_core/runnables/base.py", line 434, in ror
return RunnableSequence(coerce_to_runnable(other), self)
File "/home/anurag/conda3/envs/botgpt/lib/python3.8/site-packages/langchain_core/runnables/base.py", line 4734, in coerce_to_runnable
raise TypeError(
TypeError: Expected a Runnable, callable or dict.Instead got an unsupported type: <class 'NoneType'>
def retrieval_qa_chain(model, retriever_instance):
Convert the functions to runnables using
RunnableLambda
def qa_bot(): llm = load_model() qa = retrieval_qa_chain(llm, retriever_instance) return qa
@cl.on_chat_start async def start(): """ Initializes the bot when a new chat starts.
TypeError: Expected a Runnable, callable or dict.Instead got an unsupported type: <class 'NoneType'> 2024-05-06 10:21:04 - Translation file for en-GB not found. Using default translation en-US. 2024-05-06 10:21:05 - Translated markdown file for en-GB not found. Defaulting to chainlit.md. 2024-05-06 10:21:05 - Expected a Runnable, callable or dict.Instead got an unsupported type: <class 'NoneType'> Traceback (most recent call last): File "/home/anurag/conda3/envs/botgpt/lib/python3.8/site-packages/chainlit/utils.py", line 39, in wrapper return await user_function(**params_values) File "main.py", line 121, in start chain = qa_bot() File "main.py", line 110, in qa_bot qa = retrieval_qa_chain(llm, retriever_instance) File "main.py", line 99, in retrieval_qa_chain context=retriever_instance | split_image_text_types_runnable File "/home/anurag/conda3/envs/botgpt/lib/python3.8/site-packages/langchain_core/runnables/base.py", line 434, in ror return RunnableSequence(coerce_to_runnable(other), self) File "/home/anurag/conda3/envs/botgpt/lib/python3.8/site-packages/langchain_core/runnables/base.py", line 4734, in coerce_to_runnable raise TypeError( TypeError: Expected a Runnable, callable or dict.Instead got an unsupported type: <class 'NoneType'>