cozy-search
Version:
UI components about search bar and IA assistant
32 lines (31 loc) • 1.2 kB
TypeScript
/**
* CozyRealtimeChatAdapter implements assistant-ui's ChatModelAdapter interface
* to integrate with the Cozy backend's AI chat API.
*
* This adapter:
* 1. POSTs to /ai/chat/conversations/{conversationId} to start a conversation
* 2. Uses StreamBridge to receive streaming content from WebSocket events
* 3. Yields content progressively as it arrives
*/
import type { ChatModelAdapter } from '@assistant-ui/react';
import { StreamBridge } from './StreamBridge';
type CozyClient = {
stackClient: {
fetchJSON: (method: string, path: string, body?: object) => Promise<unknown>;
};
};
export interface CozyRealtimeChatAdapterOptions {
client: CozyClient;
conversationId: string;
assistantId?: string;
websearchEnabled?: boolean;
}
/**
* Creates a ChatModelAdapter that integrates with Cozy's backend.
* The adapter posts messages to the backend and yields streaming responses
* from the WebSocket via StreamBridge.
*/
export declare const createCozyRealtimeChatAdapter: (options: CozyRealtimeChatAdapterOptions, t: (key: string, options?: Record<string, unknown>) => string, streamBridgeRef: {
current: StreamBridge;
}) => ChatModelAdapter;
export {};