Chainlit / cookbook

Chainlit's cookbook repo
https://github.com/Chainlit/chainlit
713 stars 270 forks source link

how to write the @cl.on_chat_resume with retrieval? #55

Open wangpengfei2048 opened 8 months ago

wangpengfei2048 commented 8 months ago
I use the code with the example for @cl.on_chat_resume ,   the chat is OK 

but I want to use the retrieval, can you give an example?

I use the code with langchain example ,but fail!

template = """Answer the question based only on the following context: {context}

Question: {question} """ prompt = ChatPromptTemplate.from_template(template) model = ChatOpenAI()

retrieval_chain = ( {"context": retriever, "question": RunnablePassthrough()} | prompt | model | StrOutputParser() )