@ulifeai/agentb-ui
The @ulifeai/agentb-ui
package provides React hooks and components to rapidly build interactive chat interfaces for your AgentB agents. It handles SSE stream consumption, message state management, and rendering of various agent events.
Installation:
npm install @ulifeai/agentb-ui react-icons uuid tailwind-merge clsx
# or
yarn add @ulifeai/agentb-ui react-icons uuid tailwind-merge clsx
Peer dependencies like react
, react-dom
are assumed to be present in your React project.
Main Exports
Hooks:
useChat
: The core hook for managing chat state and backend communication.
Components:
AgentBChat
: An all-in-one chat UI component.MessageList
: Component for rendering a list of messages.MessageItem
: Component for rendering a single message.MessageInput
: Component for user message input.
Types:
AgentEvent
(and specific event types likeAgentEventMessageDelta
): Mirrored types from the backend for SSE payloads.ChatMessage
: UI-specific representation of a message for display.UseChatOptions
,UseChatReturn
: Option and return types for theuseChat
hook.
Utilities:
parseSSEStream
: Async generator for parsing SSE streams (used internally byuseChat
).
Navigate to the specific sub-pages for detailed API information on each component and hook.
Last updated