utilitas 1999.1.11 → 1999.1.12

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
@@ -70,7 +70,8 @@ const [
70
70
  name, user, system, assistant, MODEL, JSON_OBJECT, TOOL, silent,
71
71
  GEMINI_EMBEDDING_M, INVALID_FILE, tokenSafeRatio, GPT_QUERY_LIMIT,
72
72
  CONTENT_IS_REQUIRED, OPENAI_HI_RES_SIZE, k, kT, m, minute, hour,
73
- gb, trimTailing, EBD, GEMINI_20_FLASH_EXP, IMAGE
73
+ gb, trimTailing, EBD, GEMINI_20_FLASH_EXP, IMAGE, JINA_DEEPSEARCH,
74
+ JINA_DEEPSEARCH_M, JINA_EMBEDDING, JINA_CLIP,
74
75
  ] = [
75
76
  'OpenAI', 'Gemini', 'OPENAI_EMBEDDING', 'GEMINI_EMEDDING',
76
77
  'OPENAI_TRAINING', 'Ollama', 'gpt-4o-mini', 'gpt-4o', 'o1', 'o3-mini',
@@ -88,7 +89,8 @@ const [
88
89
  'Content is required.', 2000 * 768, x => 1024 * x, x => 1000 * x,
89
90
  x => 1024 * 1024 * x, x => 60 * x, x => 60 * 60 * x,
90
91
  x => 1024 * 1024 * 1024 * x, x => x.replace(/[\.\s]*$/, ''),
91
- { embedding: true }, 'gemini-2.0-flash-exp', 'image',
92
+ { embedding: true }, 'gemini-2.0-flash-exp', 'image', 'Jina Deepsearch',
93
+ 'jina-deepsearch-v1', 'JINA_EMBEDDING', 'jina-clip-v2',
92
94
  ];
93
95
 
94
96
  const [tool, messages, text]
@@ -168,6 +170,12 @@ const MODELS = {
168
170
  supportedMimeTypes: [png, jpeg, gif],
169
171
  fast: true, json: true, vision: true,
170
172
  },
173
+ [JINA_DEEPSEARCH_M]: {
174
+ contextWindow: Infinity, maxInputTokens: Infinity,
175
+ maxOutputTokens: Infinity, imageCostTokens: 0, maxImageSize: Infinity,
176
+ supportedMimeTypes: [png, jpeg, mimeText, webp, pdf],
177
+ reasoning: true, json: true, vision: true,
178
+ },
171
179
  [DEEPSEEK_R1]: {
172
180
  contextWindow: kT(128), maxOutputTokens: k(32),
173
181
  reasoning: true,
@@ -175,6 +183,9 @@ const MODELS = {
175
183
  [TEXT_EMBEDDING_3_LARGE]: { ...OPENAI_EBD, dimension: k(3) },
176
184
  [TEXT_EMBEDDING_3_SMALL]: { ...OPENAI_EBD, dimension: k(1.5) },
177
185
  [GEMINI_EMBEDDING_M]: { ...EBD, maxInputTokens: k(8), dimension: k(3) },
186
+ [JINA_CLIP]: {
187
+ maxInputTokens: k(8), maxImageSize: 512 * 512, dimension: k(1),
188
+ },
178
189
  [CLOUD_37_SONNET]: { // 100 pages: https://docs.anthropic.com/en/docs/build-with-claude/pdf-support
179
190
  contextWindow: kT(200), maxOutputTokens: kT(64),
180
191
  documentCostTokens: 3000 * 100, maxDocumentFile: m(32),
@@ -183,7 +194,6 @@ const MODELS = {
183
194
  supportedMimeTypes: [png, jpeg, gif, webp, pdf],
184
195
  json: true, reasoning: true, tools: true, vision: true,
185
196
  }, // https://docs.anthropic.com/en/docs/build-with-claude/vision
186
-
187
197
  };
188
198
 
189
199
  // Unifiy model configurations
@@ -215,10 +225,12 @@ const DEFAULT_MODELS = {
215
225
  [GEMINI]: GEMINI_20_FLASH,
216
226
  [ANTHROPIC]: CLOUD_37_SONNET,
217
227
  [VERTEX_ANTHROPIC]: CLOUD_37_SONNET,
228
+ [JINA_DEEPSEARCH]: JINA_DEEPSEARCH_M,
218
229
  [OLLAMA]: GEMMA327B,
219
230
  [OPENAI_VOICE]: NOVA,
220
231
  [OPENAI_EMBEDDING]: TEXT_EMBEDDING_3_SMALL,
221
232
  [GEMINI_EMEDDING]: GEMINI_EMBEDDING_M,
233
+ [JINA_EMBEDDING]: JINA_CLIP,
222
234
  [OPENAI_TRAINING]: GPT_4O_MINI, // https://platform.openai.com/docs/guides/fine-tuning
223
235
  };
224
236
  DEFAULT_MODELS[CHAT] = DEFAULT_MODELS[GEMINI];
@@ -239,7 +251,7 @@ let tokeniser;
239
251
  const unifyProvider = provider => {
240
252
  assert(provider = (provider || '').trim(), 'AI provider is required.');
241
253
  for (let type of [OPENAI, AZURE_OPENAI, AZURE, GEMINI, ANTHROPIC,
242
- VERTEX_ANTHROPIC, OLLAMA]) {
254
+ VERTEX_ANTHROPIC, JINA_DEEPSEARCH, OLLAMA]) {
243
255
  if (insensitiveCompare(provider, type)) { return type; }
244
256
  }
245
257
  throwError(`Invalid AI provider: ${provider}.`);
@@ -410,6 +422,19 @@ const init = async (options = {}) => {
410
422
  prompt: async (cnt, opts) => await promptAnthropic(id, cnt, opts),
411
423
  });
412
424
  break;
425
+ case JINA_DEEPSEARCH:
426
+ assertApiKey(provider, options);
427
+ ais.push({
428
+ id, provider, model, priority: 0, initOrder: ais.length,
429
+ client: await OpenAI({
430
+ baseURL: 'https://deepsearch.jina.ai/v1/', ...options,
431
+ }),
432
+ prompt: async (cnt, opts) => await promptOpenAI(id, cnt, opts),
433
+ embedding: async (i, o) => await createJinaEmbedding(await OpenAI({
434
+ baseURL: 'https://api.jina.ai/v1/', ...options,
435
+ }), i, o),
436
+ });
437
+ break;
413
438
  case OLLAMA:
414
439
  // https://github.com/ollama/ollama/blob/main/docs/openai.md
415
440
  const baseURL = 'http://localhost:11434/v1/';
@@ -1152,7 +1177,7 @@ const checkEmbeddingInput = async (input, model) => {
1152
1177
  return getInput();
1153
1178
  };
1154
1179
 
1155
- const createOpenAIEmbedding = async (aiId, input, options) => {
1180
+ const createOpenAIEmbedding = async (client, input, options) => {
1156
1181
  // args from vertex embedding may be useful uere
1157
1182
  // https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings
1158
1183
  // task_type Description
@@ -1161,7 +1186,7 @@ const createOpenAIEmbedding = async (aiId, input, options) => {
1161
1186
  // SEMANTIC_SIMILARITY Specifies the given text will be used for Semantic Textual Similarity(STS).
1162
1187
  // CLASSIFICATION Specifies that the embeddings will be used for classification.
1163
1188
  // CLUSTERING Specifies that the embeddings will be used for clustering.
1164
- const { client } = await getAi(aiId);
1189
+ String.isString(client) && (client = (await getAi(client)).client);
1165
1190
  const model = options?.model || DEFAULT_MODELS[OPENAI_EMBEDDING];
1166
1191
  const resp = await client.embeddings.create({
1167
1192
  model, input: await checkEmbeddingInput(input, model),
@@ -1169,6 +1194,11 @@ const createOpenAIEmbedding = async (aiId, input, options) => {
1169
1194
  return options?.raw ? resp : resp?.data[0].embedding;
1170
1195
  };
1171
1196
 
1197
+ const createJinaEmbedding = async (client, input, options) =>
1198
+ await createOpenAIEmbedding(client, input, {
1199
+ model: DEFAULT_MODELS[JINA_EMBEDDING], ...options || {}
1200
+ });
1201
+
1172
1202
  const createGeminiEmbedding = async (aiId, input, options) => {
1173
1203
  const { client } = await getAi(aiId);
1174
1204
  const model = options?.model || DEFAULT_MODELS[GEMINI_EMEDDING];
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": "1999.1.11",
4
+ "version": "1999.1.12",
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": "1999.1.11",
4
+ "version": "1999.1.12",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",