export type AISuggestPolicyRequestDto = {instructions: string, chatHistory?: (Array<{role?: ('user' | 'assistant') | undefined, content?: string | undefined}>) | undefined}; export type CreateApiV1PoliciesIdAiChatArgs = {'X-Organization-Id'?: string | undefined, id: string, body: AISuggestPolicyRequestDto}; export type CreateApiV1PoliciesIdAiChatOptions = {baseUrl?: string | undefined, apikey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Chat with AI about a policy * * POST /v1/policies/{id}/ai-chat */ export const createApiV1PoliciesIdAiChat = async (args: CreateApiV1PoliciesIdAiChatArgs, options?: CreateApiV1PoliciesIdAiChatOptions) => { const {baseUrl = "https://api.betayum.com", fetch: fetchFn = fetch, apikey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/event-stream") if (args['X-Organization-Id'] != null) headers.set("X-Organization-Id", String(args['X-Organization-Id'])) if (apikey !== undefined) headers.set("X-API-Key", apikey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/policies/${encodeURIComponent(String(args.id))}/ai-chat${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.text() };