@restnfeel/agentc-starter-kit
Version:
한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템
154 lines (151 loc) • 8.01 kB
JavaScript
"use client";
import { APIClient, readEnv, isRunningInBrowser } from './core.js';
import { OpenAIError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError } from './error.js';
import { toFile } from './uploads.js';
import { Batches, BatchesPage } from './resources/batches.js';
import { Completions } from './resources/completions.js';
import { Embeddings } from './resources/embeddings.js';
import { Files, FileObjectsPage } from './resources/files.js';
import { Images } from './resources/images.js';
import { Models, ModelsPage } from './resources/models.js';
import { Moderations } from './resources/moderations.js';
import { Audio } from './resources/audio/audio.js';
import { Beta } from './resources/beta/beta.js';
import { Chat } from './resources/chat/chat.js';
import { Containers, ContainerListResponsesPage } from './resources/containers/containers.js';
import { Evals, EvalListResponsesPage } from './resources/evals/evals.js';
import { FineTuning } from './resources/fine-tuning/fine-tuning.js';
import { Graders } from './resources/graders/graders.js';
import { Responses } from './resources/responses/responses.js';
import { Uploads } from './resources/uploads/uploads.js';
import { VectorStores, VectorStoresPage, VectorStoreSearchResponsesPage } from './resources/vector-stores/vector-stores.js';
import { ChatCompletionsPage } from './resources/chat/completions/completions.js';
import { stringify } from './internal/qs/stringify.js';
import { fileFromPath } from './_shims/registry.js';
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
var _a;
/**
* API Client for interfacing with the OpenAI API.
*/
class OpenAI extends APIClient {
/**
* API Client for interfacing with the OpenAI API.
*
* @param {string | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? undefined]
* @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null]
* @param {string | null | undefined} [opts.project=process.env['OPENAI_PROJECT_ID'] ?? null]
* @param {string} [opts.baseURL=process.env['OPENAI_BASE_URL'] ?? https://api.openai.com/v1] - Override the default base URL for the API.
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
*/
constructor({ baseURL = readEnv('OPENAI_BASE_URL'), apiKey = readEnv('OPENAI_API_KEY'), organization = readEnv('OPENAI_ORG_ID') ?? null, project = readEnv('OPENAI_PROJECT_ID') ?? null, ...opts } = {}) {
if (apiKey === undefined) {
throw new OpenAIError("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");
}
const options = {
apiKey,
organization,
project,
...opts,
baseURL: baseURL || `https://api.openai.com/v1`,
};
if (!options.dangerouslyAllowBrowser && isRunningInBrowser()) {
throw new OpenAIError("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");
}
super({
baseURL: options.baseURL,
timeout: options.timeout ?? 600000 /* 10 minutes */,
httpAgent: options.httpAgent,
maxRetries: options.maxRetries,
fetch: options.fetch,
});
this.completions = new Completions(this);
this.chat = new Chat(this);
this.embeddings = new Embeddings(this);
this.files = new Files(this);
this.images = new Images(this);
this.audio = new Audio(this);
this.moderations = new Moderations(this);
this.models = new Models(this);
this.fineTuning = new FineTuning(this);
this.graders = new Graders(this);
this.vectorStores = new VectorStores(this);
this.beta = new Beta(this);
this.batches = new Batches(this);
this.uploads = new Uploads(this);
this.responses = new Responses(this);
this.evals = new Evals(this);
this.containers = new Containers(this);
this._options = options;
this.apiKey = apiKey;
this.organization = organization;
this.project = project;
}
defaultQuery() {
return this._options.defaultQuery;
}
defaultHeaders(opts) {
return {
...super.defaultHeaders(opts),
'OpenAI-Organization': this.organization,
'OpenAI-Project': this.project,
...this._options.defaultHeaders,
};
}
authHeaders(opts) {
return { Authorization: `Bearer ${this.apiKey}` };
}
stringifyQuery(query) {
return stringify(query, { arrayFormat: 'brackets' });
}
}
_a = OpenAI;
OpenAI.OpenAI = _a;
OpenAI.DEFAULT_TIMEOUT = 600000; // 10 minutes
OpenAI.OpenAIError = OpenAIError;
OpenAI.APIError = APIError;
OpenAI.APIConnectionError = APIConnectionError;
OpenAI.APIConnectionTimeoutError = APIConnectionTimeoutError;
OpenAI.APIUserAbortError = APIUserAbortError;
OpenAI.NotFoundError = NotFoundError;
OpenAI.ConflictError = ConflictError;
OpenAI.RateLimitError = RateLimitError;
OpenAI.BadRequestError = BadRequestError;
OpenAI.AuthenticationError = AuthenticationError;
OpenAI.InternalServerError = InternalServerError;
OpenAI.PermissionDeniedError = PermissionDeniedError;
OpenAI.UnprocessableEntityError = UnprocessableEntityError;
OpenAI.toFile = toFile;
OpenAI.fileFromPath = fileFromPath;
OpenAI.Completions = Completions;
OpenAI.Chat = Chat;
OpenAI.ChatCompletionsPage = ChatCompletionsPage;
OpenAI.Embeddings = Embeddings;
OpenAI.Files = Files;
OpenAI.FileObjectsPage = FileObjectsPage;
OpenAI.Images = Images;
OpenAI.Audio = Audio;
OpenAI.Moderations = Moderations;
OpenAI.Models = Models;
OpenAI.ModelsPage = ModelsPage;
OpenAI.FineTuning = FineTuning;
OpenAI.Graders = Graders;
OpenAI.VectorStores = VectorStores;
OpenAI.VectorStoresPage = VectorStoresPage;
OpenAI.VectorStoreSearchResponsesPage = VectorStoreSearchResponsesPage;
OpenAI.Beta = Beta;
OpenAI.Batches = Batches;
OpenAI.BatchesPage = BatchesPage;
OpenAI.Uploads = Uploads;
OpenAI.Responses = Responses;
OpenAI.Evals = Evals;
OpenAI.EvalListResponsesPage = EvalListResponsesPage;
OpenAI.Containers = Containers;
OpenAI.ContainerListResponsesPage = ContainerListResponsesPage;
export { APIConnectionError, APIConnectionTimeoutError, APIError, APIUserAbortError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, OpenAI, OpenAIError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, OpenAI as default, fileFromPath, toFile };
//# sourceMappingURL=index.js.map