panel.chat.langchain module#
The langchain module integrates Langchain support with Panel.
- class panel.chat.langchain.PanelCallbackHandler(instance: ChatFeed | ChatInterface, user: str = 'LangChain', avatar: str = '🦜')[source]#
Bases:
object
The Langchain PanelCallbackHandler itself is not a widget or pane, but is useful for rendering and streaming the chain of thought from Langchain Tools, Agents, and Chains as ChatMessage objects.
Reference: https://panel.holoviz.org/reference/chat/PanelCallbackHandler.html
- Example:
>>> chat_interface = pn.widgets.ChatInterface(callback=callback, callback_user="Langchain") >>> callback_handler = pn.widgets.langchain.PanelCallbackHandler(instance=chat_interface) >>> llm = ChatOpenAI(streaming=True, callbacks=[callback_handler]) >>> chain = ConversationChain(llm=llm)
- on_chat_model_start(serialized: dict[str, Any], messages: list, **kwargs: Any) None [source]#
To prevent the inherited class from raising NotImplementedError, will not call super() here.