export type GetApiApiV1WWIdAssistantConversationsCIdEventsArgs = {wId: string, cId: string, lastEventId?: string | undefined}; export type GetApiApiV1WWIdAssistantConversationsCIdEventsOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the events for a conversation * * GET /api/v1/w/{wId}/assistant/conversations/{cId}/events */ export const getApiApiV1WWIdAssistantConversationsCIdEvents = async (args: GetApiApiV1WWIdAssistantConversationsCIdEventsArgs, options?: GetApiApiV1WWIdAssistantConversationsCIdEventsOptions) => { const {baseUrl = "https://dust.tt", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/event-stream") if (args.lastEventId != null) query.append("lastEventId", String(args.lastEventId)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/w/${encodeURIComponent(String(args.wId))}/assistant/conversations/${encodeURIComponent(String(args.cId))}/events${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };