utilitas 1995.2.45 → 1995.2.47

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/lib/alan.mjs CHANGED
@@ -182,8 +182,15 @@ const init = async (options) => {
182
182
  const OpenAI = await need('openai');
183
183
  // const { getEncoding } = await need('js-tiktoken');
184
184
  const openai = new OpenAI(options);
185
+ const chatGpt = options?.chatGptEndpoint || options?.chatGptApiKey
186
+ ? new OpenAI({
187
+ ...options,
188
+ baseURL: options?.chatGptEndpoint || options?.baseURL,
189
+ apiKey: options?.chatGptApiKey || options?.apiKey,
190
+ }) : openai;
185
191
  clients[provider] = {
186
192
  client: openai, clientBeta: openai.beta,
193
+ chatGptClient: chatGpt,
187
194
  // tokeniser: getEncoding(options?.tokenModel || 'cl100k_base'),
188
195
  // countTokens: text => tokenSafe(
189
196
  // clients[provider].tokeniser.encode(text).length
@@ -284,10 +291,10 @@ const packGptResp = (resp, options) => {
284
291
  };
285
292
 
286
293
  const promptChatGPT = async (content, options) => {
287
- const { client } = await getOpenAIClient(options);
294
+ const { chatGptClient } = await getOpenAIClient(options);
288
295
  // https://github.com/openai/openai-node?tab=readme-ov-file#streaming-responses
289
296
  // https://github.com/openai/openai-node?tab=readme-ov-file#streaming-responses-1
290
- let [resp, result, chunk] = [await client.chat.completions.create({
297
+ let [resp, result, chunk] = [await chatGptClient.chat.completions.create({
291
298
  ...messages([...options?.messages || [], buildGptMessage(content)]),
292
299
  model: options?.model || DEFAULT_MODELS[CHATGPT],
293
300
  stream: !!options?.stream,
package/lib/manifest.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const manifest = {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1995.2.45",
4
+ "version": "1995.2.47",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1995.2.45",
4
+ "version": "1995.2.47",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",