Monday, July 10, 2023

What is Chainlit?

Chainlit lets you create ChatGPT-like UIs on top of any Python code in minutes! Some of the key features include intermediary steps visualisation, element management & display (images, text, carousel, etc.) as well as cloud deployment.


Installation


$ pip install chainlit

$ chainlit hello


Sample 


import chainlit as cl

@cl.on_message  # this function will be called every time a user inputs a message in the UI

async def main(message: str):

    # this is an intermediate step

    await cl.Message(author="Tool 1", content=f"Response from tool1", indent=1).send()


    # send back the final answer

    await cl.Message(content=f"This is the final answer").send()



Doing this just below two helped to get the sample chat page up and running 


$ pip install chainlit

$ chainlit hello


References:

https://github.com/Chainlit/chainlit

No comments:

Post a Comment