export type PlaygroundCompletionRequest = {prompt: string, model?: (string | null) | undefined, temperature?: (number | null) | undefined, max_tokens?: (number | null) | undefined, app_id: string, assistant_id?: (string | null) | undefined, assistant_version_id?: (string | null) | undefined, conversation_id?: (string | null) | undefined, parent_request_id?: (string | null) | undefined, plugins?: Array | undefined, images?: (Array | null) | undefined, files?: (Array | null) | undefined}; export type CreateApiV1PlaygroundChatArgs = {body: PlaygroundCompletionRequest}; export type CreateApiV1PlaygroundChatOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Playground Prompt Request * * POST /v1/playground/chat */ export const createApiV1PlaygroundChat = async (args: CreateApiV1PlaygroundChatArgs, options: CreateApiV1PlaygroundChatOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/playground/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 undefined };