import {z} from 'zod' export type IntegrationMode = 'TEXT' | 'AVATAR'; export type VoiceStyleNames = 'advertisement_upbeat' | 'affectionate' | 'angry' | 'assistant' | 'calm' | 'chat' | 'cheerful' | 'customerservice' | 'depressed' | 'disgruntled' | 'documentary-narration' | 'embarassed' | 'empathetic' | 'envious' | 'excited' | 'fearful' | 'friendly' | 'gentle' | 'hopeful' | 'lyrical' | 'narration-professional' | 'narration-relaxed' | 'newscast' | 'newscast-casual' | 'newscast-formal' | 'poetry-reading' | 'sad' | 'serious' | 'shouting' | 'sports_commentary' | 'sports_commentary_excited' | 'whispering' | 'terrified' | 'unfriendly'; export type KBInputField = {input_name: string, input_type: string, input_label: string, input_placeholder: string, is_mandatory: boolean}; export type KnowledgeBaseCustomizationPatchPayload = {kb_name?: string | undefined, base_system_prompt?: string | undefined, initial_messages?: Array | undefined, prompt_suggestions?: Array | undefined, display_name?: string | undefined, integration_mode?: IntegrationMode | undefined, avatar_id?: string | undefined, voice_id?: string | undefined, speaking_style?: VoiceStyleNames | undefined, visitor_chat_color?: string | undefined, dante_chat_color?: string | undefined, embed_logo_url?: string | undefined, embed_page_url?: string | undefined, chatbot_profile_pic?: string | undefined, prompts_color?: string | undefined, custom_url?: string | undefined, show_tooltips?: boolean | undefined, remove_dante_logo?: boolean | undefined, custom_url_favicon?: string | undefined, custom_url_title?: string | undefined, custom_url_meta?: string | undefined, custom_url_meta_image?: string | undefined, custom_url_meta_description?: string | undefined, font_name?: string | undefined, font_size?: number | undefined, dante_font_color?: string | undefined, visitor_font_color?: string | undefined, chat_background_color?: string | undefined, custom_css?: string | undefined, hide_microphone_icon?: boolean | undefined, hide_play_icon?: boolean | undefined, password?: string | undefined, public?: boolean | undefined, enabled?: boolean | undefined, max_number_of_credits?: number | undefined, number_of_messages_per_minutes?: number | undefined, number_of_minutes?: number | undefined, max_messages_in_conversations?: number | undefined, temperature?: number | undefined, prompts_font_color?: string | undefined, input_background?: string | undefined, scrollbar_color?: string | undefined, input_placeholder_text?: string | undefined, show_prompt_messages?: boolean | undefined, is_bubble_opened?: boolean | undefined, disclaimer_text?: string | undefined, dante_border_color?: string | undefined, visitor_border_color?: string | undefined, timestamp_color?: string | undefined, close_icon_color?: string | undefined, data_collection_title?: string | undefined, data_collection_fields?: Array | undefined, data_collection?: boolean | undefined, data_collection_as_nlp?: boolean | undefined, data_collection_consent_text?: string | undefined, is_data_collection_optional?: boolean | undefined, show_data_collection_on_conversation_begin?: boolean | undefined, data_collection_rule?: string | undefined, intercom_api_key?: string | undefined, intercom_company_id?: string | undefined, intercom_company_name?: string | undefined, intercom_company_tag?: string | undefined, disclaimer_text_color?: string | undefined, intercom_enabled?: boolean | undefined, intercom_connection_state?: boolean | undefined, talk_to_live_agent?: boolean | undefined, live_agent_email_prompt?: string | undefined, live_agent_name_prompt?: string | undefined, live_agent_always_active?: boolean | undefined, live_agent_list_of_schedules?: Array> | undefined, live_agent_user_timezone?: string | undefined, show_live_agent_on_conversation_begin?: boolean | undefined, show_live_agent_rule?: string | undefined, hide_email_button?: boolean | undefined, calendly_integration_enabled?: boolean | undefined, calendly_url?: string | undefined, show_calendly_at_the_start?: boolean | undefined, show_calendly_rule?: string | undefined, personalities_template?: string | undefined, suggested_prompts_appearance?: string | undefined, whitelisted_domains?: Array | undefined, finished_steps?: Array | undefined, open_to_internet_knowledge?: boolean | undefined, realtime_voice_access?: boolean | undefined, custom_url_enabled?: boolean | undefined, remove_watermark?: boolean | undefined, show_welcome_message_as_tooltip?: boolean | undefined, show_email_details?: boolean | undefined, show_microphone?: boolean | undefined, show_play_button?: boolean | undefined, open_chat_by_default?: boolean | undefined, brand_color?: string | undefined, element_color?: string | undefined, surface_color?: string | undefined, alert_color?: string | undefined, positive_color?: string | undefined, negative_color?: string | undefined, disclaimer_enabled?: boolean | undefined, brand_website?: string | undefined, chatbot_icon?: string | undefined, calendly_btn_text?: string | undefined, suggested_prompts_enabled?: boolean | undefined}; export type PatchApiKnowledgeBasesCustomizationKbIdArgs = {kb_id: string, team_id?: string | undefined, body: KnowledgeBaseCustomizationPatchPayload}; export type PatchApiKnowledgeBasesCustomizationKbIdOptions = {baseUrl: string, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiKnowledgeBasesCustomizationKbIdResponse = z.object({}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Patch Knowledge Base Customization * * PATCH /knowledge-bases/customization/{kb_id} * * Also accepts auth: OAuth2PasswordBearer */ export const patchApiKnowledgeBasesCustomizationKbId = async (args: PatchApiKnowledgeBasesCustomizationKbIdArgs, options: PatchApiKnowledgeBasesCustomizationKbIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.team_id != null) query.append("team_id", String(args.team_id)) if (APIKeyHeader !== undefined) headers.set("x-api-key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/knowledge-bases/customization/${encodeURIComponent(String(args.kb_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(patchApiKnowledgeBasesCustomizationKbIdResponse, await res.json()) };