utilitas 1995.2.45 → 1995.2.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +4 -3
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -181,9 +181,10 @@ const init = async (options) => {
|
|
|
181
181
|
if (options?.apiKey) {
|
|
182
182
|
const OpenAI = await need('openai');
|
|
183
183
|
// const { getEncoding } = await need('js-tiktoken');
|
|
184
|
-
const openai = new OpenAI(options);
|
|
184
|
+
const openai = new OpenAI({ ...options, baseURL: undefined });
|
|
185
185
|
clients[provider] = {
|
|
186
186
|
client: openai, clientBeta: openai.beta,
|
|
187
|
+
chatGptClient: options?.baseURL ? new OpenAI(options) : openai,
|
|
187
188
|
// tokeniser: getEncoding(options?.tokenModel || 'cl100k_base'),
|
|
188
189
|
// countTokens: text => tokenSafe(
|
|
189
190
|
// clients[provider].tokeniser.encode(text).length
|
|
@@ -284,10 +285,10 @@ const packGptResp = (resp, options) => {
|
|
|
284
285
|
};
|
|
285
286
|
|
|
286
287
|
const promptChatGPT = async (content, options) => {
|
|
287
|
-
const {
|
|
288
|
+
const { chatGptClient } = await getOpenAIClient(options);
|
|
288
289
|
// https://github.com/openai/openai-node?tab=readme-ov-file#streaming-responses
|
|
289
290
|
// https://github.com/openai/openai-node?tab=readme-ov-file#streaming-responses-1
|
|
290
|
-
let [resp, result, chunk] = [await
|
|
291
|
+
let [resp, result, chunk] = [await chatGptClient.chat.completions.create({
|
|
291
292
|
...messages([...options?.messages || [], buildGptMessage(content)]),
|
|
292
293
|
model: options?.model || DEFAULT_MODELS[CHATGPT],
|
|
293
294
|
stream: !!options?.stream,
|
package/lib/manifest.mjs
CHANGED