I downloaded the repo: https://github.com/menloparklab/falcon-langchain
I created a virtualenv
for this one to install the requirments.txt
and run the application.
After I run the application using the following command.
chainlit run app.py -w
But I am getting the error:
module 'chainlit' has no attribute 'langchain_factory'
In the earlier versions of Chainlit, the factory
concept was included as part of the API. However, after receiving feedback and evaluating its usefulness, the developers decided to remove it in order to simplify the API and avoid confusion among users.
In the latest version of Chainlit, you will no longer find the following APIs: langchain_factory
, langchain_run
, langchain_postprocess
, llama_index_factory
, and langflow_factory
.
If your code looks like below,
@cl.langchain_factory
def factory():
prompt = PromptTemplate(template=template, input_variables=["question"])
llm_chain = LLMChain(prompt=prompt, llm=llm, verbose=True)
return llm_chain
Use the following code to use chainlit if you have installed a latest version of chainlit in your machine,
@cl.on_chat_start
def main():
# Instantiate the chain for that user session
prompt = PromptTemplate(template=template, input_variables=["question"])
llm_chain = LLMChain(prompt=prompt, llm=llm, verbose=True)
# Store the chain in the user session
cl.user_session.set("llm_chain", llm_chain)
@cl.on_message
async def main(message: str):
# Retrieve the chain from the user session
llm_chain = cl.user_session.get("llm_chain") # type: LLMChain
# Call the chain asynchronously
res = await llm_chain.acall(message, callbacks=[cl.AsyncLangchainCallbackHandler()])
# Do any post processing here
# Send the response
await cl.Message(content=res["text"]).send()
For more: Migration Guide to Chainlit v0.6.0