@zhengxs/erniebot
Version:
非官方 JS-SDK,可以调用文心大模型的能力,包含文本创作、通用对话、语义向量、AI作图等
31 lines (30 loc) • 1.02 kB
TypeScript
export type HTTPMethods = 'get' | 'post' | 'put' | 'patch' | 'delete';
export type HTTPSearchParams = URLSearchParams | Record<string, string>;
export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
export type HTTPClient = {
fetch: Fetch;
};
export type APIHeaders = Record<string, string>;
export type APIBody = Record<string, any>;
export type APIMultipartBody = {
body?: BodyInit | null;
};
export interface APIRequestInit extends RequestInit {
method: string;
headers: Record<string, string>;
}
export interface APIRequestOptions extends Omit<RequestInit, 'body' | 'headers'> {
path: string;
query?: HTTPSearchParams;
body?: APIBody | APIMultipartBody | null | undefined;
headers?: APIHeaders;
timeout?: number;
stream?: boolean;
maxRetries?: number;
}
export type APIRequestConfig = Omit<APIRequestOptions, 'path'>;
export type APIResponseProps = {
response: Response;
options: APIRequestOptions;
controller: AbortController;
};