export enum FinishReason {
  STOP = 'stop',
  LENGTH = 'length',
}

export interface ChoiceBase {
  index: number;
}

export interface FinishableChoiceBase extends ChoiceBase {
  finish_reason: FinishReason | null;
}

export type DataEventId = string;

export type Timestamp = number;

export interface CreatedResource {
  created: Timestamp;
}

export type DoFetchBody = BodyInit | Record<string, unknown>

export type DoFetch = (
  method: string,
  path: string,
  body?: DoFetchBody
) => Promise<Response>;

export type ConsumeStream = (
  response: Response,
) => Promise<void>;

export class PlatformError extends Error {
  constructor(message: string, readonly response: Response) {
    super(message);
    this.name = 'OpenAi.PlatformError';
  }
}

export const enum ApiVersion {
  V1 = 'v1',
}

export interface Configuration {
  organizationId?: string;
  apiVersion: ApiVersion;
  apiKey: string;
  baseUrl?: string;
}
