@olane/o-intelligence 0.7.6 → 0.7.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"llm.methods.d.ts","sourceRoot":"","sources":["../../../src/methods/llm.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAkGhD,CAAC"}
1
+ {"version":3,"file":"llm.methods.d.ts","sourceRoot":"","sources":["../../../src/methods/llm.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAwKhD,CAAC"}
@@ -96,4 +96,74 @@ export const LLM_PARAMS = {
96
96
  dependencies: [],
97
97
  parameters: [],
98
98
  },
99
+ embed_documents: {
100
+ name: 'embed_documents',
101
+ description: 'Generate embeddings for multiple documents',
102
+ dependencies: [],
103
+ parameters: [
104
+ {
105
+ name: 'input',
106
+ type: 'array',
107
+ value: 'string[]',
108
+ description: 'Array of text strings to embed',
109
+ required: true,
110
+ },
111
+ {
112
+ name: 'model',
113
+ type: 'string',
114
+ value: 'string',
115
+ description: 'The embedding model to use',
116
+ required: false,
117
+ },
118
+ {
119
+ name: 'apiKey',
120
+ type: 'string',
121
+ value: 'string',
122
+ description: 'OpenAI API key (optional, uses OPENAI_API_KEY env var if not provided)',
123
+ required: false,
124
+ },
125
+ {
126
+ name: 'dimensions',
127
+ type: 'number',
128
+ value: 'number',
129
+ description: 'Number of dimensions for the embedding (only for text-embedding-3 models)',
130
+ required: false,
131
+ },
132
+ ],
133
+ },
134
+ embed_query: {
135
+ name: 'embed_query',
136
+ description: 'Generate embedding for a single query string',
137
+ dependencies: [],
138
+ parameters: [
139
+ {
140
+ name: 'input',
141
+ type: 'string',
142
+ value: 'string',
143
+ description: 'Text string to embed',
144
+ required: true,
145
+ },
146
+ {
147
+ name: 'model',
148
+ type: 'string',
149
+ value: 'string',
150
+ description: 'The embedding model to use',
151
+ required: false,
152
+ },
153
+ {
154
+ name: 'apiKey',
155
+ type: 'string',
156
+ value: 'string',
157
+ description: 'OpenAI API key (optional, uses OPENAI_API_KEY env var if not provided)',
158
+ required: false,
159
+ },
160
+ {
161
+ name: 'dimensions',
162
+ type: 'number',
163
+ value: 'number',
164
+ description: 'Number of dimensions for the embedding (only for text-embedding-3 models)',
165
+ required: false,
166
+ },
167
+ ],
168
+ },
99
169
  };
@@ -28,5 +28,13 @@ export declare class OpenAIIntelligenceTool extends oLaneTool {
28
28
  * Check OpenAI API status
29
29
  */
30
30
  _tool_status(request: oRequest): Promise<ToolResult>;
31
+ /**
32
+ * Generate embeddings for multiple documents
33
+ */
34
+ _tool_embed_documents(request: oRequest): Promise<ToolResult>;
35
+ /**
36
+ * Generate embedding for a single query
37
+ */
38
+ _tool_embed_query(request: oRequest): Promise<ToolResult>;
31
39
  }
32
40
  //# sourceMappingURL=openai-intelligence.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/openai-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmHhD,qBAAa,sBAAuB,SAAQ,SAAS;IACnD,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,MAAM,CAA4C;gBAE9C,MAAM,E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AAC,UAAU,CAAC;IA+C9D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAwC1D;;OAEG;IACG,qBAAqB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAgFnE;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAoFhE"}
@@ -259,4 +259,138 @@ export class OpenAIIntelligenceTool extends oLaneTool {
259
259
  };
260
260
  }
261
261
  }
262
+ /**
263
+ * Generate embeddings for multiple documents
264
+ */
265
+ async _tool_embed_documents(request) {
266
+ try {
267
+ const params = request.params;
268
+ const { input, model = 'text-embedding-3-small', apiKey = this.apiKey, dimensions, ...options } = params;
269
+ if (!apiKey) {
270
+ return {
271
+ success: false,
272
+ error: 'OpenAI API key is required',
273
+ };
274
+ }
275
+ if (!input || !Array.isArray(input)) {
276
+ return {
277
+ success: false,
278
+ error: 'input must be an array of strings',
279
+ };
280
+ }
281
+ const embeddingRequest = {
282
+ input,
283
+ model: model,
284
+ encoding_format: 'float',
285
+ };
286
+ if (dimensions) {
287
+ embeddingRequest.dimensions = dimensions;
288
+ }
289
+ const headers = {
290
+ 'Content-Type': 'application/json',
291
+ Authorization: `Bearer ${apiKey}`,
292
+ };
293
+ if (this.organization) {
294
+ headers['OpenAI-Organization'] = this.organization;
295
+ }
296
+ const response = await fetch(`${this.baseUrl}/embeddings`, {
297
+ method: 'POST',
298
+ headers,
299
+ body: JSON.stringify(embeddingRequest),
300
+ });
301
+ if (!response.ok) {
302
+ const errorText = await response.text();
303
+ return {
304
+ success: false,
305
+ error: `OpenAI API error: ${response.status} - ${errorText}`,
306
+ };
307
+ }
308
+ const result = (await response.json());
309
+ // Extract embeddings in order
310
+ const embeddings = result.data
311
+ .sort((a, b) => a.index - b.index)
312
+ .map((item) => item.embedding);
313
+ return {
314
+ success: true,
315
+ embeddings,
316
+ model: result.model,
317
+ usage: result.usage,
318
+ };
319
+ }
320
+ catch (error) {
321
+ return {
322
+ success: false,
323
+ error: `Failed to generate embeddings: ${error.message}`,
324
+ };
325
+ }
326
+ }
327
+ /**
328
+ * Generate embedding for a single query
329
+ */
330
+ async _tool_embed_query(request) {
331
+ try {
332
+ const params = request.params;
333
+ const { input, model = 'text-embedding-3-small', apiKey = this.apiKey, dimensions, ...options } = params;
334
+ if (!apiKey) {
335
+ return {
336
+ success: false,
337
+ error: 'OpenAI API key is required',
338
+ };
339
+ }
340
+ if (!input || typeof input !== 'string') {
341
+ return {
342
+ success: false,
343
+ error: 'input must be a string',
344
+ };
345
+ }
346
+ const embeddingRequest = {
347
+ input,
348
+ model: model,
349
+ encoding_format: 'float',
350
+ };
351
+ if (dimensions) {
352
+ embeddingRequest.dimensions = dimensions;
353
+ }
354
+ const headers = {
355
+ 'Content-Type': 'application/json',
356
+ Authorization: `Bearer ${apiKey}`,
357
+ };
358
+ if (this.organization) {
359
+ headers['OpenAI-Organization'] = this.organization;
360
+ }
361
+ const response = await fetch(`${this.baseUrl}/embeddings`, {
362
+ method: 'POST',
363
+ headers,
364
+ body: JSON.stringify(embeddingRequest),
365
+ });
366
+ if (!response.ok) {
367
+ const errorText = await response.text();
368
+ return {
369
+ success: false,
370
+ error: `OpenAI API error: ${response.status} - ${errorText}`,
371
+ };
372
+ }
373
+ const result = (await response.json());
374
+ // Return the first (and only) embedding
375
+ const embedding = result.data[0]?.embedding;
376
+ if (!embedding) {
377
+ return {
378
+ success: false,
379
+ error: 'No embedding returned from API',
380
+ };
381
+ }
382
+ return {
383
+ success: true,
384
+ embedding,
385
+ model: result.model,
386
+ usage: result.usage,
387
+ };
388
+ }
389
+ catch (error) {
390
+ return {
391
+ success: false,
392
+ error: `Failed to generate embedding: ${error.message}`,
393
+ };
394
+ }
395
+ }
262
396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-intelligence",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -56,11 +56,11 @@
56
56
  "typescript": "5.4.5"
57
57
  },
58
58
  "peerDependencies": {
59
- "@olane/o-config": "^0.7.5",
60
- "@olane/o-core": "^0.7.5",
61
- "@olane/o-lane": "^0.7.5",
62
- "@olane/o-protocol": "^0.7.5",
63
- "@olane/o-tool": "^0.7.5"
59
+ "@olane/o-config": "^0.7.7",
60
+ "@olane/o-core": "^0.7.7",
61
+ "@olane/o-lane": "^0.7.7",
62
+ "@olane/o-protocol": "^0.7.7",
63
+ "@olane/o-tool": "^0.7.7"
64
64
  },
65
65
  "dependencies": {
66
66
  "debug": "^4.4.1",