UNPKG

@tsailab/xai

Version:

The loto-xai is an openai nodejs sdk compatible extension library.

65 lines (64 loc) 2.06 kB
import { RequestOptions } from 'https'; declare const fetch: typeof globalThis.fetch; export { fetch }; export type XFetch = typeof fetch; export type XSSEMethod = 'GET' | 'POST'; export interface RequestInit { /** * A BodyInit object or null to set request's body. */ body?: BodyInit | null; /** * A Headers object, an object literal, or an array of two-item arrays to set request's headers. */ headers?: HeadersInit; /** * A string to set request's method. */ method?: XSSEMethod; /** * A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */ redirect?: RequestRedirect; /** * An AbortSignal to set request's signal. */ signal?: AbortSignal | null; /** * A string whose value is a same-origin URL, "about:client", or the empty string, to set request’s referrer. */ referrer?: string; /** * A referrer policy to set request’s referrerPolicy. */ referrerPolicy?: ReferrerPolicy; agent?: RequestOptions['agent'] | ((parsedUrl: URL) => RequestOptions['agent']); compress?: boolean; counter?: number; follow?: number; hostname?: string; port?: number; protocol?: string; size?: number; highWaterMark?: number; insecureHTTPParser?: boolean; } export type XSSEConnectedOptions = { connectedAt?: number; body?: any; [k: string]: any; }; /** * @public SSE Fetch optison * @param eventType 'message' | 'result' | string * this relation server side ,default message */ export interface XSSERequestOptions extends RequestInit { method?: XSSEMethod; eventType?: 'message' | 'result' | string; onconnected?: (options?: XSSEConnectedOptions) => void; onmessage: (data: string) => void; onerror?: (err?: Error) => void; onend?: (result?: string) => void; logwarn?: (message?: any, ...optionalParams: [...any, string?]) => void; }