on_window_message

用于响应来自 Web App 父窗口消息的装饰器。每当收到新的窗口消息时,都会调用被装饰的函数。

参数

message
str

来自 Web App 父窗口的消息。

用法

import chainlit as cl

@cl.on_window_message
def main(message: str):
  # do something

send_window_message

用于向 Web App 父窗口发送消息的函数。

参数

message
str

要发送到 Web App 父窗口的消息。

用法

@cl.on_message
async def message():
  await cl.send_window_message("Server: Hello from Chainlit")