@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
59 lines (58 loc) • 2.2 kB
TypeScript
import { type Dispatch, type MutableRefObject, type SetStateAction } from 'react';
import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
import type { id } from '../../../types/string_token';
import type { ChatMessage } from '../types/ChatMessage';
import type { LlmChatProps } from './LlmChatProps';
/**
* Minimal task-progress item rendered by `<Chat/>`.
*
* @private function of `useLlmChatMessageHandler`
*/
type LlmChatTaskProgress = {
readonly id: string;
readonly name: string;
readonly progress?: number;
};
/**
* Internal send signature shared across retry and visibility-recovery flows.
*
* @private function of `useLlmChatMessageHandler`
*/
type HandleMessageFn = (messageContent: string, attachments?: ChatMessage['attachments']) => Promise<void>;
/**
* Inputs required by `useLlmChatMessageHandler`.
*
* @private function of `useLlmChatMessageHandler`
*/
type UseLlmChatMessageHandlerProps = {
readonly chatFailMessage: string;
readonly hasUserInteractedRef: MutableRefObject<boolean>;
readonly llmParticipantName: id;
readonly llmTools: LlmExecutionTools;
readonly messages: ReadonlyArray<ChatMessage>;
readonly onError?: LlmChatProps['onError'];
readonly promptParameters: Record<string, string>;
readonly setMessages: Dispatch<SetStateAction<Array<ChatMessage>>>;
readonly setTasksProgress: Dispatch<SetStateAction<Array<LlmChatTaskProgress>>>;
readonly thinkingVariants: ReadonlyArray<string>;
readonly thread?: ReadonlyArray<ChatMessage>;
readonly userParticipantName: id;
};
/**
* State and handlers returned by `useLlmChatMessageHandler`.
*
* @private function of `useLlmChatMessageHandler`
*/
type UseLlmChatMessageHandlerResult = {
readonly clearLastFailedMessage: () => void;
readonly handleMessage: HandleMessageFn;
readonly handleStopStreaming: () => void;
readonly isStreaming: boolean;
};
/**
* Manages send, stream, retry, and background-recovery flows for `<LlmChat/>`.
*
* @private function of `useLlmChatState`
*/
export declare function useLlmChatMessageHandler(props: UseLlmChatMessageHandlerProps): UseLlmChatMessageHandlerResult;
export {};