chat
Module: @vibex/react/chat
Interfaces
UseXChatOptions
View source
Properties:
| Name | Type | Description |
|---|---|---|
spaceId | string | The space ID to associate messages with |
agentId | string | Optional agent ID to route messages to (optional) |
metadata | Record<string, unknown> | Optional metadata to include with each request (optional) |
api | string | API endpoint (defaults to /api/chat) (optional) |
initialMessages | XChatMessage[] | Initial messages to populate the chat (optional) |
onError | (error: Error) => void | Callback when an error occurs (optional) |
onFinish | (message: XChatMessage) => void | Callback when generation finishes (optional) |
onStatusChange | (status: XChatStatus) => void | Callback when status changes (optional) |
Functions
useXChat
View source
React hook for chat interactions with VibeX agents
const { messages, input, setInput, append, status, isLoading } = useXChat({
spaceId: "my-space",
agentId: "researcher",
});
// Check granular status
if (status === "awaiting-approval") {
// Show approval UI
}function useXChat({
spaceId,
agentId,
metadata,
api = "/api/chat",
initialMessages,
onError,
onFinish,
onStatusChange,
}: UseXChatOptions): XChatState;Parameters:
| Name | Type | Description |
|---|---|---|
options | UseXChatOptions |