export type RoleContentChatChoiceContentImageUrl = {url: string}; export type RoleContentChatChoiceContent = {type: 'text' | 'image_url', text?: (string | null) | undefined, image_url?: (RoleContentChatChoiceContentImageUrl | null) | undefined}; export type FunctionCallArguments = {arguments: string, name: string}; export type ToolCall = {function: FunctionCallArguments, id: string, type?: 'function' | undefined}; export type RoleContentChatChoiceInput = {role: 'user' | 'assistant' | 'system', content: string | Array | null, tool_calls?: (Array | null) | undefined}; export type PlaygroundCommandRequest = {messages?: Array | undefined, system: string, app_id: string}; export type CreateApiV1PlaygroundCommandArgs = {body: PlaygroundCommandRequest}; export type CreateApiV1PlaygroundCommandOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Command Request * * POST /v1/playground/command */ export const createApiV1PlaygroundCommand = async (args: CreateApiV1PlaygroundCommandArgs, options: CreateApiV1PlaygroundCommandOptions) => { 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/command${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 };