@redocly/theme
Version:
Shared UI components lib
74 lines (65 loc) • 2.58 kB
text/typescript
import { type AiSearchErrorConfig, ToolCallName } from '../types/search';
export enum AiSearchError {
Unauthorized = 'ai_search_unauthorized',
Forbidden = 'ai_search_forbidden',
HttpRequestFailed = 'http_request_in_failed_status',
EmptyResponse = 'empty_response',
ErrorProcessingResponse = 'error_processing_response',
}
export const AiSearchConversationRole = {
USER: 'user',
ASSISTANT: 'assistant',
} as const;
export type AiSearchConversationRole =
(typeof AiSearchConversationRole)[keyof typeof AiSearchConversationRole];
const defaultErrorConfig: AiSearchErrorConfig = {
headerKey: 'search.ai.error.header',
headerDefault: 'Oops! Something went wrong.',
messageKey: 'search.ai.error.description',
messageDefault:
'We encountered an issue while processing your search. Try again later or refine your query. If the problem persists, please contact Redocly support.',
};
export const AI_SEARCH_ERROR_CONFIG: Record<AiSearchError, AiSearchErrorConfig> = {
[]: {
headerKey: 'search.ai.error.header.forbidden',
headerDefault: 'Feature Unavailable',
messageKey: 'search.ai.error.description.forbidden',
messageDefault: 'AI Search is currently unavailable.',
},
[]: {
headerKey: 'search.ai.error.header.unauthorized',
headerDefault: 'Authentication Required',
messageKey: 'search.ai.error.description.unauthorized',
messageDefault: 'You are not authorized to use AI Search.',
},
[]: defaultErrorConfig,
[]: defaultErrorConfig,
[]: defaultErrorConfig,
} as const;
export const AI_SEARCH_MAX_MESSAGE_LENGTH = 45000;
export const SEARCH_DEBOUNCE_TIME_MS = 300;
export const TOOL_CALL_DISPLAY_TEXT: Record<
ToolCallName,
{ inProgressText: string; completedText: string }
> = {
[]: {
inProgressText: 'Searching documentation...',
completedText: 'Search completed',
},
[]: {
inProgressText: 'Browsing APIs...',
completedText: 'Browsed APIs',
},
[]: {
inProgressText: 'Browsing endpoints for API...',
completedText: 'Browsed endpoints for API',
},
[]: {
inProgressText: 'Browsing security schemes for API...',
completedText: 'Browsed security schemes for API',
},
[]: {
inProgressText: 'Reading API description...',
completedText: 'Read API description',
},
};