export type MP3UserMessageAudioConfig = {type?: 'mp3' | undefined}; export type PCMUserMessageAudioConfig = {type?: 'pcm' | undefined, frame_rate: number, n_channels: 1, sample_width: 2 | 4}; export type UserMessageAudioConfig = MP3UserMessageAudioConfig | PCMUserMessageAudioConfig; export type CreateApiV1OrganizationConversationConversationIdInteractArgs = {conversation_id: string, organization: string, request_format: 'text' | 'voice', response_format: 'text' | 'voice', current_agent_action_type?: string | undefined, request_audio_config?: (UserMessageAudioConfig | null) | undefined, 'content-type': string, 'x-mongo-cluster-name'?: (string | null) | undefined, 'Sec-WebSocket-Protocol'?: Array | undefined, body: BodyInit}; export type CreateApiV1OrganizationConversationConversationIdInteractOptions = {baseUrl?: string | undefined, BearerAuthorization?: string | undefined, BearerAuthorizationOrganization?: string | undefined, Basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Interact with a conversation * * POST /v1/{organization}/conversation/{conversation_id}/interact */ export const createApiV1OrganizationConversationConversationIdInteract = async (args: CreateApiV1OrganizationConversationConversationIdInteractArgs, options?: CreateApiV1OrganizationConversationConversationIdInteractOptions) => { const {baseUrl = "https://api.amigo.ai", fetch: fetchFn = fetch, BearerAuthorization, BearerAuthorizationOrganization, Basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/x-ndjson") if (args.request_format != null) query.append("request_format", String(args.request_format)) if (args.response_format != null) query.append("response_format", String(args.response_format)) if (args.current_agent_action_type != null) query.append("current_agent_action_type", String(args.current_agent_action_type)) if (args.request_audio_config != null) query.append("request_audio_config", String(args.request_audio_config)) if (args['content-type'] != null) headers.set("content-type", String(args['content-type'])) if (args['x-mongo-cluster-name'] != null) headers.set("x-mongo-cluster-name", String(args['x-mongo-cluster-name'])) if (args['Sec-WebSocket-Protocol'] != null) headers.set("Sec-WebSocket-Protocol", args['Sec-WebSocket-Protocol'].join(',')) if (BearerAuthorization !== undefined) headers.set('authorization', `Bearer ${BearerAuthorization}`) if (BearerAuthorizationOrganization !== undefined) headers.set("X-ORG-ID", BearerAuthorizationOrganization) if (Basic !== undefined) headers.set('authorization', `Basic ${btoa(`${Basic.username}:${Basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/${encodeURIComponent(String(args.organization))}/conversation/${encodeURIComponent(String(args.conversation_id))}/interact${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };