utilitas 1998.2.63 → 1998.2.64

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
@@ -515,6 +515,7 @@ const init = async (options = {}) => {
515
515
  ais[id] = {
516
516
  id, provider, model, client: await OpenAI(options),
517
517
  prompt: async (cnt, opts) => await promptOpenAI(id, cnt, opts),
518
+ embedding: async (i, o) => await createOpenAIEmbedding(id, i, o),
518
519
  };
519
520
  break;
520
521
  case AZURE_OPENAI:
@@ -544,6 +545,7 @@ const init = async (options = {}) => {
544
545
  id, provider, model,
545
546
  client: new GoogleGenerativeAI(options.apiKey),
546
547
  prompt: async (cnt, opts) => await promptGemini(id, cnt, opts),
548
+ embedding: async (i, o) => await createGeminiEmbedding(id, i, o),
547
549
  };
548
550
  break;
549
551
  case ANTHROPIC:
@@ -700,7 +702,7 @@ const buildGeminiHistory = (text, options) => buildGeminiMessage(
700
702
  text, { ...options || {}, history: true }
701
703
  );
702
704
 
703
- const [getOpenAIClient, getGeminiClient] = [OPENAI, GEMINI].map(
705
+ const [getOpenAIClient] = [OPENAI].map(
704
706
  x => async options => await init({ ...provider(x), ...options })
705
707
  );
706
708
 
@@ -1255,7 +1257,7 @@ const checkEmbeddingInput = async (input, model) => {
1255
1257
  return getInput();
1256
1258
  };
1257
1259
 
1258
- const createOpenAIEmbedding = async (input, options) => {
1260
+ const createOpenAIEmbedding = async (aiId, input, options) => {
1259
1261
  // args from vertex embedding may be useful uere
1260
1262
  // https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings
1261
1263
  // task_type Description
@@ -1264,7 +1266,7 @@ const createOpenAIEmbedding = async (input, options) => {
1264
1266
  // SEMANTIC_SIMILARITY Specifies the given text will be used for Semantic Textual Similarity(STS).
1265
1267
  // CLASSIFICATION Specifies that the embeddings will be used for classification.
1266
1268
  // CLUSTERING Specifies that the embeddings will be used for clustering.
1267
- const { client } = await getOpenAIClient(options);
1269
+ const { client } = await getAi(aiId);
1268
1270
  const model = options?.model || DEFAULT_MODELS[OPENAI_EMBEDDING];
1269
1271
  const resp = await client.embeddings.create({
1270
1272
  model, input: await checkEmbeddingInput(input, model),
@@ -1272,8 +1274,8 @@ const createOpenAIEmbedding = async (input, options) => {
1272
1274
  return options?.raw ? resp : resp?.data[0].embedding;
1273
1275
  };
1274
1276
 
1275
- const createGeminiEmbedding = async (input, options) => {
1276
- const { client } = await getGeminiClient(options);
1277
+ const createGeminiEmbedding = async (aiId, input, options) => {
1278
+ const { client } = await getAi(aiId);
1277
1279
  const model = options?.model || DEFAULT_MODELS[GEMINI_EMEDDING];
1278
1280
  const resp = await client.getGenerativeModel({ model }).embedContent(
1279
1281
  await checkEmbeddingInput(input, model)
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": "1998.2.63",
4
+ "version": "1998.2.64",
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": "1998.2.63",
4
+ "version": "1998.2.64",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",