export type AmigoLibPydanticBaseModelStrippedNonemptyString1 = string; export type AmigoLibPydanticBaseModelStrippedNonemptyString4 = string; export type SrcAppEndpointsConversationCreateConversationRequest = {service_id: string, service_version_set_name?: string | undefined, initial_message?: (AmigoLibPydanticBaseModelStrippedNonemptyString1 | null) | undefined, initial_message_type?: ('user-message' | 'external-event' | null) | undefined, tags?: ({[key: string]: AmigoLibPydanticBaseModelStrippedNonemptyString4 | null}) | undefined, is_test?: boolean | undefined}; export type CreateApiV1OrganizationConversationArgs = {organization: string, response_format: 'text' | 'voice', current_agent_action_type?: string | undefined, 'x-mongo-cluster-name'?: (string | null) | undefined, 'Sec-WebSocket-Protocol'?: Array | undefined, body: SrcAppEndpointsConversationCreateConversationRequest}; export type CreateApiV1OrganizationConversationOptions = {baseUrl?: string | undefined, BearerAuthorization?: string | undefined, BearerAuthorizationOrganization?: string | undefined, Basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Create a conversation * * POST /v1/{organization}/conversation/ */ export const createApiV1OrganizationConversation = async (args: CreateApiV1OrganizationConversationArgs, options?: CreateApiV1OrganizationConversationOptions) => { const {baseUrl = "https://api.amigo.ai", fetch: fetchFn = fetch, BearerAuthorization, BearerAuthorizationOrganization, Basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/x-ndjson") 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['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/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 res.blob() };