UNPKG

@tsailab/xai

Version:

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

20 lines 732 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildHttpUrl = void 0; /** * IF you call chat completion with http mode * this method can build http url * @param baseUrl like https://api.openai.com/v1 * @param urlpath liek chat/completions * @returns https://api.openai.com/v1/chat/completions */ const buildHttpUrl = (baseUrl, urlpath) => { if (!baseUrl?.length || !urlpath.length) return baseUrl ?? urlpath; const base = baseUrl.endsWith('/') ? baseUrl.substring(0, baseUrl.length - 1) : baseUrl; return urlpath.startsWith('/') ? `${base}${urlpath}` : `${base}/${urlpath}`; }; exports.buildHttpUrl = buildHttpUrl; //# sourceMappingURL=url.util.js.map