API Reference
author_rename
Useful to rename the author of a message to display more friendly author names in the UI.
Parameters
orig_author
str
requiredThe original author name.
Returns
author
str
requiredThe renamed author
Usage
Code Example
from langchain import OpenAI, LLMMathChain
import chainlit as cl
@cl.author_rename
def rename(orig_author: str):
rename_dict = {"LLMMathChain": "Albert Einstein", "Chatbot": "Assistant"}
return rename_dict.get(orig_author, orig_author)
@cl.on_message
async def main(message: cl.Message):
llm = OpenAI(temperature=0)
llm_math = LLMMathChain.from_llm(llm=llm)
res = await llm_math.acall(message.content, callbacks=[cl.AsyncLangchainCallbackHandler()])
await cl.Message(content="Hello").send()
Was this page helpful?