rust-kgdb 0.5.10 → 0.5.11

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +42 -18
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to the rust-kgdb TypeScript SDK will be documented in this file.
4
4
 
5
+ ## [0.5.11] - 2025-12-15
6
+
7
+ ### Documentation Clarification
8
+
9
+ - Clarified that embedding providers (OpenAI, Voyage AI) are third-party libraries, not built into rust-kgdb
10
+ - Updated examples to show `fetch` API for Voyage AI instead of non-existent SDK
11
+ - Added "bring your own embeddings" messaging to make provider abstraction clear
12
+ - rust-kgdb's EmbeddingService stores/searches vectors; users provide embeddings from their preferred provider
13
+
5
14
  ## [0.5.10] - 2025-12-15
6
15
 
7
16
  ### Documentation Cleanup
package/README.md CHANGED
@@ -309,11 +309,13 @@ const voteResults = service.findSimilarComposite('CLM001', 10, 0.7, 'voting') //
309
309
 
310
310
  ### Provider Configuration
311
311
 
312
- Configure your embedding providers with API keys:
312
+ rust-kgdb's `EmbeddingService` stores and searches vectors - you bring your own embeddings from any provider. Here are examples using popular third-party libraries:
313
313
 
314
314
  ```javascript
315
- // Example: Using OpenAI embeddings
316
- const { OpenAI } = require('openai')
315
+ // ============================================================
316
+ // EXAMPLE: Using OpenAI embeddings (requires: npm install openai)
317
+ // ============================================================
318
+ const { OpenAI } = require('openai') // Third-party library
317
319
  const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY })
318
320
 
319
321
  async function getOpenAIEmbedding(text) {
@@ -325,17 +327,31 @@ async function getOpenAIEmbedding(text) {
325
327
  return response.data[0].embedding
326
328
  }
327
329
 
328
- // Example: Using Anthropic (via their embedding partner)
329
- // Note: Anthropic doesn't provide embeddings directly; use Voyage AI
330
- const { VoyageAIClient } = require('voyageai')
331
- const voyage = new VoyageAIClient({ apiKey: process.env.VOYAGE_API_KEY })
332
-
330
+ // ============================================================
331
+ // EXAMPLE: Using Voyage AI (requires: npm install voyageai)
332
+ // Note: Anthropic recommends Voyage AI for embeddings
333
+ // ============================================================
333
334
  async function getVoyageEmbedding(text) {
334
- const response = await voyage.embed({
335
- input: text,
336
- model: 'voyage-2'
335
+ // Using fetch directly (no SDK required)
336
+ const response = await fetch('https://api.voyageai.com/v1/embeddings', {
337
+ method: 'POST',
338
+ headers: {
339
+ 'Authorization': `Bearer ${process.env.VOYAGE_API_KEY}`,
340
+ 'Content-Type': 'application/json'
341
+ },
342
+ body: JSON.stringify({ input: text, model: 'voyage-2' })
337
343
  })
338
- return response.embeddings[0].slice(0, 384) // Truncate to 384-dim
344
+ const data = await response.json()
345
+ return data.data[0].embedding.slice(0, 384) // Truncate to 384-dim
346
+ }
347
+
348
+ // ============================================================
349
+ // EXAMPLE: Mock embeddings for testing (no external deps)
350
+ // ============================================================
351
+ function getMockEmbedding(text) {
352
+ return new Array(384).fill(0).map((_, i) =>
353
+ Math.sin(text.charCodeAt(i % text.length) * 0.1) * 0.5 + 0.5
354
+ )
339
355
  }
340
356
  ```
341
357
 
@@ -1224,11 +1240,12 @@ const db = new GraphDB('http://insurance.org/fraud-kb')
1224
1240
  const embeddings = new EmbeddingService()
1225
1241
 
1226
1242
  // ============================================================
1227
- // STEP 3: Configure Embedding Provider
1243
+ // STEP 3: Configure Embedding Provider (bring your own)
1228
1244
  // ============================================================
1229
1245
  async function getEmbedding(text) {
1230
1246
  switch (EMBEDDING_PROVIDER) {
1231
1247
  case 'openai':
1248
+ // Requires: npm install openai
1232
1249
  const { OpenAI } = require('openai')
1233
1250
  const openai = new OpenAI({ apiKey: OPENAI_API_KEY })
1234
1251
  const resp = await openai.embeddings.create({
@@ -1239,12 +1256,19 @@ async function getEmbedding(text) {
1239
1256
  return resp.data[0].embedding
1240
1257
 
1241
1258
  case 'voyage':
1242
- const { VoyageAIClient } = require('voyageai')
1243
- const voyage = new VoyageAIClient({ apiKey: VOYAGE_API_KEY })
1244
- const vResp = await voyage.embed({ input: text, model: 'voyage-2' })
1245
- return vResp.embeddings[0].slice(0, EMBEDDING_DIM)
1259
+ // Using fetch directly (no SDK required)
1260
+ const vResp = await fetch('https://api.voyageai.com/v1/embeddings', {
1261
+ method: 'POST',
1262
+ headers: {
1263
+ 'Authorization': `Bearer ${VOYAGE_API_KEY}`,
1264
+ 'Content-Type': 'application/json'
1265
+ },
1266
+ body: JSON.stringify({ input: text, model: 'voyage-2' })
1267
+ })
1268
+ const vData = await vResp.json()
1269
+ return vData.data[0].embedding.slice(0, EMBEDDING_DIM)
1246
1270
 
1247
- default: // Mock embeddings for testing
1271
+ default: // Mock embeddings for testing (no external deps)
1248
1272
  return new Array(EMBEDDING_DIM).fill(0).map((_, i) =>
1249
1273
  Math.sin(text.charCodeAt(i % text.length) * 0.1) * 0.5 + 0.5
1250
1274
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rust-kgdb",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "description": "Production-grade Neuro-Symbolic AI Framework: +86.4% accuracy improvement over vanilla LLMs. High-performance knowledge graph (2.78µs lookups, 35x faster than RDFox). Features fraud detection, underwriting agents, WASM sandbox, type/category/proof theory, and W3C SPARQL 1.1 compliance.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",