@tsailab/xai
Version:
The loto-xai is an openai nodejs sdk compatible extension library.
16 lines • 594 B
JavaScript
/**
* 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
*/
export 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}`;
};
//# sourceMappingURL=url.util.js.map