Skip to content

Conversation

parteeksingh24
Copy link
Contributor

@parteeksingh24 parteeksingh24 commented Aug 25, 2025

Summary by CodeRabbit

  • Documentation
    • Vector DB guide and SDK docs updated: upsert now requires explicit document keys across JS/Python; deletes use keys.
    • Search results now expose similarity (0.0–1.0) as the primary metric; JavaScript retains distance for compatibility.
    • New/rewritten examples: Simple RAG, Semantic Search with metadata filtering, Product Search (with product ID validation).
    • Expanded guidance: pitfalls, best practices, performance, memory patterns, and API reference links.

- Add Vector DB guide examples (`search`)
- Update JS examples to include required "key" field for `upsert`
- Update Vector DB guide to reflect both SDKs return `similarity` field
- Remove unnecessary distance-to-similarity conversions
- Add note about JS backwards compatibility with `distance` parameter
Copy link
Contributor

coderabbitai bot commented Aug 25, 2025

Walkthrough

Documentation and examples update Vector DB APIs: upsert now requires a per-document key, deletions operate by key, and search results expose similarity (0.0–1.0) as the primary metric. Guides and JS SDK examples updated with RAG and filtering patterns, best practices, and API-reference links.

Changes

Cohort / File(s) Summary
Guides: Vector DB concepts & examples
content/Guides/vector-db.mdx
Upsert examples now include a key per document; deletion examples remove by key; search examples return result.similarity (0.0–1.0) and retain distance in JS for backward compatibility. Added end-to-end examples (RAG, semantic filtering, product search), Practical Examples, Key Points, Common Pitfalls, Best Practices, performance guidance, and API-reference links.
JS SDK API reference: Vector upsert params
content/SDKs/javascript/api-reference.mdx
Vector upsert examples updated to include key fields (e.g., chair-001, embed-123), indicating VectorUpsertParams supports a key?: string property in examples; function signatures in docs unchanged.
JS SDK examples: Indexing & search
content/SDKs/javascript/examples/index.mdx
Added validation to require non-empty product IDs; documents created with key: String(product.id); result output now includes id and key and reads similarity from result.similarity instead of computing from distance.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App
  participant VectorDB

  rect rgba(230,245,255,0.6)
  note over App,VectorDB: Upsert with explicit per-document keys
  App->>VectorDB: upsert([{ key, document|embeddings, metadata }...])
  VectorDB-->>App: ack { status, inserted_count }
  end

  rect rgba(240,255,230,0.6)
  note over App,VectorDB: Search returns similarity scores
  App->>VectorDB: search({ query|embedding, filters? })
  VectorDB-->>App: results[{ id, key?, similarity, ...metadata }]
  note right of App: Use result.similarity directly (JS may also include result.distance)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jhaynie
  • mcongrove

Poem

I tuck my keys in tidy rows,
Similarities hum where the vector goes,
No distance fences in my way,
RAG and filters help me play.
Hare-hop docs — index, search, and sway. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch parteek/update-docs-examples

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

cloudflare-workers-and-pages bot commented Aug 25, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
docs e72fc7f Commit Preview URL

Branch Preview URL
Aug 28 2025, 10:55 PM

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
content/SDKs/javascript/examples/index.mdx (1)

359-361: request.trigger is a property, not a function

Elsewhere in the API docs, trigger is shown as a getter (get trigger(): string). Update this example to avoid confusion.

-      span.setAttribute('trigger', request.trigger());
+      span.setAttribute('trigger', request.trigger);
content/SDKs/javascript/api-reference.mdx (1)

206-214: Make key required in Upsert docs to match new behavior across SDKs

The Guides state that upsert now requires a key for each document in both SDKs. Here, examples use a key (good), but the textual contract still reads as if a key is optional. Please make the requirement explicit so developers don’t ship non-idempotent upserts.

 #### upsert
 `upsert(name: string, ...documents: VectorUpsertParams[]): Promise<string[]>`

 Inserts or updates vectors in the vector storage.

 **Parameters**
 
 - `name`: The name of the vector storage
-- `documents`: One or more documents to upsert, each with either embeddings or text
+- `documents`: One or more documents to upsert. Each document must include a unique `key` and either `document` (text) or `embeddings`.

Add a concrete type snippet nearby for clarity:

// VectorUpsertParams (JavaScript)
interface VectorUpsertParams {
  key: string; // required, idempotency key for the vector
  document?: string; // mutually exclusive with embeddings
  embeddings?: number[];
  metadata?: Record<string, Json>;
}

Also applies to: 216-221

content/Guides/vector-db.mdx (1)

169-185: Correct the JS delete description: delete by key, not by internal ID

The paragraph currently says JavaScript deletes “by IDs.” Per the API reference, JavaScript delete accepts keys. Please align the wording to prevent accidental use of internal IDs that won’t match.

-Remove specific vectors from storage using their IDs (JavaScript) or keys (Python).
+Remove specific vectors from storage using their keys in both SDKs.
🧹 Nitpick comments (6)
content/SDKs/javascript/examples/index.mdx (2)

112-122: Good addition: stable per-document key; add light validation and stringify for safety

Using key: product.id aligns with the new upsert requirements. Consider guarding for missing/empty IDs and normalizing to a string to avoid accidental number/UUID/object keys slipping in from upstream payloads.

-      // Prepare documents for vector storage
-      const documents = products.map(product => ({
-        key: product.id,
+      // Prepare documents for vector storage
+      if (products.some(p => !p?.id)) {
+        return response.json({ error: 'All products must include a non-empty id' });
+      }
+      const documents = products.map(product => ({
+        key: String(product.id),
         document: product.description,
         metadata: {
           id: product.id,
           name: product.name,
           price: product.price,
           category: product.category
         }
       }));

147-151: Switch to result.similarity looks correct; consider returning key/id for callers

Reading result.similarity directly is consistent with the updated API. Small UX upgrade: pass through result id and/or key so consumers can act on a specific vector without digging into metadata.

-      const formattedResults = results.map(result => ({
-        ...result.metadata,
-        similarity: result.similarity
-      }));
+      const formattedResults = results.map(result => ({
+        id: result.id,
+        key: result.key,
+        ...result.metadata,
+        similarity: result.similarity,
+      }));
content/SDKs/javascript/api-reference.mdx (1)

291-306: Use “key” terminology consistently in delete examples

Delete takes keys, not internal IDs. The examples use 'id1' etc., which can be misread as internal vector IDs. Rename placeholders to “key” to match the parameter name and the upsert contract.

-// Delete a single vector
-const deletedCount = await context.vector.delete('product-descriptions', 'id1');
+// Delete a single vector (by key)
+const deletedCount = await context.vector.delete('product-descriptions', 'key1');
 console.log(`Deleted ${deletedCount} vector(s)`); // Output: Deleted 1 vector(s)

 // Delete multiple vectors in bulk (more efficient than individual calls)
-const deletedCount = await context.vector.delete('product-descriptions', 'id1', 'id2', 'id3');
+const deletedCount = await context.vector.delete('product-descriptions', 'key1', 'key2', 'key3');
 console.log(`Deleted ${deletedCount} vector(s)`); // Output: Deleted 3 vector(s)

 // Delete with array spread
-const keysToDelete = ['id1', 'id2', 'id3'];
+const keysToDelete = ['key1', 'key2', 'key3'];
 const deletedCount = await context.vector.delete('product-descriptions', ...keysToDelete);

 // Handle cases where some vectors might not exist
-const deletedCount = await context.vector.delete('product-descriptions', 'existing-id', 'non-existent-id');
+const deletedCount = await context.vector.delete('product-descriptions', 'existing-key', 'non-existent-key');
 console.log(`Deleted ${deletedCount} vector(s)`); // Output: Deleted 1 vector(s)
content/Guides/vector-db.mdx (3)

47-50: Minor wording tweak for the API links block

Tighten phrasing and punctuation to address the lint warnings and improve readability.

-For complete API documentation, see:
-- [JavaScript SDK Vector API Reference](/SDKs/javascript/api-reference#vector-storage)
-- [Python SDK Vector API Reference](/SDKs/python/api-reference#vector-storage)
+For complete API documentation, see:
+- [JavaScript SDK Vector API Reference](/SDKs/javascript/api-reference#vector-storage)
+- [Python SDK Vector API Reference](/SDKs/python/api-reference#vector-storage)

206-264: RAG example: handle missing metadata text more defensively and include keys

Some datasets won’t store raw content in metadata. Suggest defaulting to an empty string and including id/key in the returned sources to improve traceability.

-    const contextTexts = searchResults.map(result => 
-      result.metadata.content || result.metadata.text
-    );
+    const contextTexts = searchResults.map(result =>
+      result.metadata?.content ?? result.metadata?.text ?? ''
+    );
@@
-      sources: searchResults.map(r => ({
-        id: r.id,
-        title: r.metadata.title,
-        similarity: r.similarity
-      }))
+      sources: searchResults.map(r => ({
+        id: r.id,
+        key: r.key,
+        title: r.metadata?.title,
+        similarity: r.similarity,
+      }))

339-386: Product search example is solid; small scoring nit

Multiplying by 1.2 for exact category matches is clear. Consider clamping the final score to [0, 1.2] if downstream assumes a 0–1 range.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 48f2244 and f919cb4.

📒 Files selected for processing (3)
  • content/Guides/vector-db.mdx (5 hunks)
  • content/SDKs/javascript/api-reference.mdx (1 hunks)
  • content/SDKs/javascript/examples/index.mdx (2 hunks)
🧰 Additional context used
🪛 LanguageTool
content/Guides/vector-db.mdx

[grammar] ~47-~47: There might be a mistake here.
Context: ...PI For complete API documentation, see: - [JavaScript SDK Vector API Reference](/SD...

(QB_NEW_EN)


[grammar] ~48-~48: There might be a mistake here.
Context: ...: - JavaScript SDK Vector API Reference - [Python SDK Vector API Reference](/SDKs/p...

(QB_NEW_EN)


[grammar] ~55-~55: There might be a mistake here.
Context: ...omputed embeddings. SDK Requirements: - Both SDKs: Require key field for eac...

(QB_NEW_EN)


[grammar] ~141-~141: There might be a mistake here.
Context: ...log(Similarity: ${result.similarity}); }); python # Python # Semantic s...

(QB_NEW_EN)


[grammar] ~198-~198: There might be a mistake here.
Context: ...l Examples For more code examples, see: - [JavaScript SDK Examples](/SDKs/javascrip...

(QB_NEW_EN)


[grammar] ~199-~199: There might be a mistake here.
Context: ...xamples, see: - JavaScript SDK Examples - [Python SDK Examples](/SDKs/python/exampl...

(QB_NEW_EN)


[grammar] ~206-~206: There might be a mistake here.
Context: ...t/TypeScript - Simple RAG implementation import { AgentHandler } from '@agentuity...

(QB_NEW_EN)


[grammar] ~209-~209: There might be a mistake here.
Context: ... async (request, response, context) => { const { question } = await request.data....

(QB_NEW_EN)


[grammar] ~256-~256: There might be a mistake here.
Context: ... })) }); } catch (error) { context.logger.error('RAG query failed:'...

(QB_NEW_EN)


[grammar] ~262-~262: There might be a mistake here.
Context: ... details: error.message }); } }; export default handler;} py={# Pyt...

(QB_NEW_EN)


[grammar] ~265-~265: There might be a mistake here.
Context: ...y={`# Python - Simple RAG implementation from agentuity import AgentRequest, Agen...

(QB_NEW_EN)


[grammar] ~268-~268: There might be a mistake here.
Context: ...: AgentResponse, context: AgentContext): data = await request.data.json() que...

(QB_NEW_EN)


[grammar] ~328-~328: There might be a mistake here.
Context: ...": str(e) })`} /> Key Points: - Semantic search finds relevant documen...

(QB_NEW_EN)


[grammar] ~339-~339: There might be a mistake here.
Context: ...TypeScript - Product search with filters import { AgentHandler } from '@agentuity...

(QB_NEW_EN)


[grammar] ~342-~342: There might be a mistake here.
Context: ... async (request, response, context) => { const { query, maxPrice, category, inSto...

(QB_NEW_EN)


[grammar] ~345-~345: There might be a mistake here.
Context: ... = await request.data.json(); try { // Build metadata filters based on crite...

(QB_NEW_EN)


[grammar] ~378-~378: There might be a mistake here.
Context: ...results }); } catch (error) { context.logger.error('Product search fai...

(QB_NEW_EN)


[grammar] ~384-~384: There might be a mistake here.
Context: ...failed', products: [] }); } }; export default handler;} py={# Pyt...

(QB_NEW_EN)


[grammar] ~387-~387: There might be a mistake here.
Context: ...{`# Python - Product search with filters from agentuity import AgentRequest, Agen...

(QB_NEW_EN)


[grammar] ~390-~390: There might be a mistake here.
Context: ...: AgentResponse, context: AgentContext): data = await request.data.json() que...

(QB_NEW_EN)


[grammar] ~446-~446: There might be a mistake here.
Context: ...": [] })`} /> Key Techniques: - Metadata filters are applied at the ve...

(QB_NEW_EN)


[grammar] ~454-~454: There might be a mistake here.
Context: ...ls & Solutions ### Empty Search Results Problem: Your search returns empty res...

(QB_NEW_EN)


[grammar] ~457-~457: There might be a mistake here.
Context: ...gh relevant data exists. Solutions: - Lower the similarity threshold: Start ...

(QB_NEW_EN)


[grammar] ~478-~478: There might be a mistake here.
Context: ....5 }); } ``` ### Duplicate Documents Problem: Same content appears multiple...

(QB_NEW_EN)


[grammar] ~481-~481: There might be a mistake here.
Context: ...t is idempotent when using the same key: - Always use consistent key values for y...

(QB_NEW_EN)


[grammar] ~486-~486: There might be a mistake here.
Context: ...ur storage clean ### Performance Issues Problem: Vector operations take too lo...

(QB_NEW_EN)


[grammar] ~489-~489: There might be a mistake here.
Context: ...perations take too long. Solutions: - Batch operations: Upsert 100-500 docum...

(QB_NEW_EN)


[grammar] ~494-~494: There might be a mistake here.
Context: ...d focused ### Irrelevant Search Results Problem: Search returns irrelevant or ...

(QB_NEW_EN)


[grammar] ~497-~497: There might be a mistake here.
Context: ...or unexpected documents. Solutions: - Check similarity scores: Results with ...

(QB_NEW_EN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Workers Builds: docs
🔇 Additional comments (3)
content/Guides/vector-db.mdx (3)

70-90: Keys added in upsert examples are correct and make operations idempotent

Using explicit key values in both text and embedding upserts is aligned with the API and the idempotency guidance below.


138-142: Result processing uses similarity directly — good

Switching logs to result.similarity removes confusion and avoids client-side transformations from distance.


196-201: Cross-links to example sections are helpful

Links to example sections for JS/Python are a nice touch and make the flow discoverable.

@parteeksingh24 parteeksingh24 changed the title parteek/update docs examples Update docs examples Aug 25, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
content/Guides/vector-db.mdx (1)

167-170: Good fix: clarified distance as a legacy result field

This resolves the earlier ambiguity. It now clearly states that distance is returned (not a query parameter) and that similarity is preferred.

🧹 Nitpick comments (9)
content/Guides/vector-db.mdx (9)

55-56: Minor grammar: add an article for clarity

“Require key field” → “Require a key field”.

Apply this diff:

-**SDK Requirements:**
-- **Both SDKs**: Require `key` field for each document
+**SDK Requirements:**
+- **Both SDKs**: Require a `key` field for each document

65-77: Confirm JS upsert parameter shape; prefer array for multiple documents

The JS example passes multiple document objects as separate arguments. If the SDK expects an array (which is common and matches the Python example), this will mislead users.

If the SDK accepts an array, update to this:

-const ids = await context.vector.upsert(
-  'knowledge-base',
-  { 
-    key: 'doc-1',
-    document: 'Agentuity is an agent-native cloud platform', 
-    metadata: { category: 'platform', source: 'docs' } 
-  },
-  { 
-    key: 'doc-2',
-    document: 'Vector storage enables semantic search capabilities', 
-    metadata: { category: 'features', source: 'docs' } 
-  }
-);
+const ids = await context.vector.upsert(
+  'knowledge-base',
+  [
+    { 
+      key: 'doc-1',
+      document: 'Agentuity is an agent-native cloud platform', 
+      metadata: { category: 'platform', source: 'docs' } 
+    },
+    { 
+      key: 'doc-2',
+      document: 'Vector storage enables semantic search capabilities', 
+      metadata: { category: 'features', source: 'docs' } 
+    }
+  ]
+);

If varargs are intentionally supported, consider adding a brief note: “You can pass one or more document objects or an array of documents.”


79-87: Consistency nit: key naming style differs across examples

JS uses hyphens (embedding-1) while Python uses underscores (embedding_1). Mixing styles can distract readers.

Consider standardizing on one style (hyphens or underscores) across all examples in this guide.


167-170: Document result identifiers alongside similarity

Examples below use result.id and result.key, but the “Search Results” bullets don’t mention them. Add these to set reader expectations.

Apply this diff:

 **Search Results:**
-- **Both SDKs**: Return results with `similarity` field (1.0 = perfect match, 0.0 = no match)
+- **Both SDKs**: Return results with `similarity` field (1.0 = perfect match, 0.0 = no match)
+- **Both SDKs**: Include `id` (internal vector ID) and `key` (your document key) on each result
 - **Note**: The JavaScript SDK also returns a `distance` field for backward compatibility; prefer `similarity`

173-186: Clarify delete signatures; consider array form for bulk delete

The JS bulk delete shows multiple string arguments. Verify if the SDK prefers an array (common in REST/SDKs). If arrays are accepted, use them for clarity and parity with upsert examples.

 // Delete single vector
-const deletedCount = await context.vector.delete('knowledge-base', 'doc-1');
+const deletedCount = await context.vector.delete('knowledge-base', 'doc-1');

 // Delete multiple vectors
-const bulkDeleteCount = await context.vector.delete(
-  'knowledge-base', 
-  'doc-1', 'doc-2', 'doc-3'
-);
+const bulkDeleteCount = await context.vector.delete(
+  'knowledge-base',
+  ['doc-1', 'doc-2', 'doc-3']
+);

Also consider documenting the return value precisely: “delete returns the number of deleted vectors.”


231-236: Defensive context assembly: include document fallback and avoid empty entries

Some results may lack metadata.content/text; include result.document as a fallback and drop empty strings. Optionally cap the assembled context length.

-    const contextTexts = searchResults.map(result => 
-      result.metadata?.content ?? result.metadata?.text ?? ''
-    );
-    const assembledContext = contextTexts.join('\n\n');
+    const contextTexts = searchResults
+      .map(r => r.metadata?.content ?? r.metadata?.text ?? r.document ?? '')
+      .filter(Boolean);
+    const assembledContext = contextTexts.join('\n\n').slice(0, 4000);

252-257: Minor: results schema consistency

You return id, key, title, similarity. If title may be absent, consider defaulting to metadata.source or omitting undefined fields to keep payload tidy.

-        title: r.metadata?.title,
+        title: r.metadata?.title ?? r.metadata?.source,

Alternatively, filter falsy properties before returning.


460-471: Unify instance name: use “knowledge-base” consistently

Earlier examples use 'knowledge-base'; this snippet uses 'kb'. Consistency helps readers.

-let results = await context.vector.search('kb', { 
+let results = await context.vector.search('knowledge-base', { 
   query, 
   similarity: 0.8 
 });
 
 if (results.length === 0) {
   // Try again with lower threshold
-  results = await context.vector.search('kb', { 
+  results = await context.vector.search('knowledge-base', { 
     query, 
     similarity: 0.5 
   });
 }

95-115: Minor consistency: key naming style across languages

JS uses doc-1, Python uses doc_1. Consider aligning the naming to reduce cognitive friction.

No code changes required; a brief note near the first upsert example is sufficient: “Keys can include hyphens or underscores; this guide uses hyphens consistently.”

Also applies to: 111-114

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f919cb4 and 4e6d5bc.

📒 Files selected for processing (3)
  • content/Guides/vector-db.mdx (6 hunks)
  • content/SDKs/javascript/api-reference.mdx (2 hunks)
  • content/SDKs/javascript/examples/index.mdx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • content/SDKs/javascript/api-reference.mdx
  • content/SDKs/javascript/examples/index.mdx
🧰 Additional context used
🪛 LanguageTool
content/Guides/vector-db.mdx

[grammar] ~47-~47: There might be a mistake here.
Context: ...PI For complete API documentation, see: - [JavaScript SDK Vector API Reference](/SD...

(QB_NEW_EN)


[grammar] ~48-~48: There might be a mistake here.
Context: ...: - JavaScript SDK Vector API Reference - [Python SDK Vector API Reference](/SDKs/p...

(QB_NEW_EN)


[grammar] ~55-~55: There might be a mistake here.
Context: ...omputed embeddings. SDK Requirements: - Both SDKs: Require key field for eac...

(QB_NEW_EN)


[grammar] ~139-~139: There might be a mistake here.
Context: ...log(Similarity: ${result.similarity}); }); python # Python # Semantic s...

(QB_NEW_EN)


[grammar] ~167-~167: There might be a mistake here.
Context: ...adata key-value pairs Search Results: - Both SDKs: Return results with `simila...

(QB_NEW_EN)


[grammar] ~182-~182: There might be a mistake here.
Context: ..., 'doc-1'); // Delete multiple vectors const bulkDeleteCount = await context.ve...

(QB_NEW_EN)


[grammar] ~183-~183: There might be a mistake here.
Context: ...leteCount = await context.vector.delete( 'knowledge-base', 'doc-1', 'doc-2', '...

(QB_NEW_EN)


[grammar] ~185-~185: There might be a mistake here.
Context: ...edge-base', 'doc-1', 'doc-2', 'doc-3' ); python # Python # Delete sing...

(QB_NEW_EN)


[grammar] ~201-~201: There might be a mistake here.
Context: ...l Examples For more code examples, see: - [JavaScript SDK Examples](/SDKs/javascrip...

(QB_NEW_EN)


[grammar] ~202-~202: There might be a mistake here.
Context: ...xamples, see: - JavaScript SDK Examples - [Python SDK Examples](/SDKs/python/exampl...

(QB_NEW_EN)


[grammar] ~209-~209: There might be a mistake here.
Context: ...t/TypeScript - Simple RAG implementation import { AgentHandler } from '@agentuity...

(QB_NEW_EN)


[grammar] ~212-~212: There might be a mistake here.
Context: ... async (request, response, context) => { const { question } = await request.data....

(QB_NEW_EN)


[grammar] ~260-~260: There might be a mistake here.
Context: ... })) }); } catch (error) { context.logger.error('RAG query failed:'...

(QB_NEW_EN)


[grammar] ~266-~266: There might be a mistake here.
Context: ... details: error.message }); } }; export default handler;} py={# Pyt...

(QB_NEW_EN)


[grammar] ~269-~269: There might be a mistake here.
Context: ...y={`# Python - Simple RAG implementation from agentuity import AgentRequest, Agen...

(QB_NEW_EN)


[grammar] ~272-~272: There might be a mistake here.
Context: ...: AgentResponse, context: AgentContext): data = await request.data.json() que...

(QB_NEW_EN)


[grammar] ~332-~332: There might be a mistake here.
Context: ...": str(e) })`} /> Key Points: - Semantic search finds relevant documen...

(QB_NEW_EN)


[grammar] ~343-~343: There might be a mistake here.
Context: ...TypeScript - Product search with filters import { AgentHandler } from '@agentuity...

(QB_NEW_EN)


[grammar] ~346-~346: There might be a mistake here.
Context: ... async (request, response, context) => { const { query, maxPrice, category, inSto...

(QB_NEW_EN)


[grammar] ~349-~349: There might be a mistake here.
Context: ... = await request.data.json(); try { // Build metadata filters based on crite...

(QB_NEW_EN)


[grammar] ~379-~379: There might be a mistake here.
Context: ...results }); } catch (error) { context.logger.error('Product search fai...

(QB_NEW_EN)


[grammar] ~385-~385: There might be a mistake here.
Context: ...failed', products: [] }); } }; export default handler;} py={# Pyt...

(QB_NEW_EN)


[grammar] ~388-~388: There might be a mistake here.
Context: ...{`# Python - Product search with filters from agentuity import AgentRequest, Agen...

(QB_NEW_EN)


[grammar] ~391-~391: There might be a mistake here.
Context: ...: AgentResponse, context: AgentContext): data = await request.data.json() que...

(QB_NEW_EN)


[grammar] ~443-~443: There might be a mistake here.
Context: ...": [] })`} /> Key Techniques: - Metadata filters are applied at the ve...

(QB_NEW_EN)


[grammar] ~450-~450: There might be a mistake here.
Context: ...ls & Solutions ### Empty Search Results Problem: Your search returns empty res...

(QB_NEW_EN)


[grammar] ~453-~453: There might be a mistake here.
Context: ...gh relevant data exists. Solutions: - Lower the similarity threshold: Start ...

(QB_NEW_EN)


[grammar] ~474-~474: There might be a mistake here.
Context: ....5 }); } ``` ### Duplicate Documents Problem: Same content appears multiple...

(QB_NEW_EN)


[grammar] ~477-~477: There might be a mistake here.
Context: ...t is idempotent when using the same key: - Always use consistent key values for y...

(QB_NEW_EN)


[grammar] ~482-~482: There might be a mistake here.
Context: ...ur storage clean ### Performance Issues Problem: Vector operations take too lo...

(QB_NEW_EN)


[grammar] ~485-~485: There might be a mistake here.
Context: ...perations take too long. Solutions: - Batch operations: Upsert 100-500 docum...

(QB_NEW_EN)


[grammar] ~490-~490: There might be a mistake here.
Context: ...d focused ### Irrelevant Search Results Problem: Search returns irrelevant or ...

(QB_NEW_EN)


[grammar] ~493-~493: There might be a mistake here.
Context: ...or unexpected documents. Solutions: - Check similarity scores: Results with ...

(QB_NEW_EN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Workers Builds: docs
🔇 Additional comments (3)
content/Guides/vector-db.mdx (3)

524-524: Cross-guide links validated

The referenced guide files both exist with correct casing:

  • content/Guides/key-value.mdx
  • content/Guides/agent-communication.mdx

No broken links detected.


47-50: Please verify API Reference pages and “Vector Storage” anchors

I ran the grep across your content directory and saw the API Reference links in the SDK index files, but I wasn’t able to locate the actual api-reference page files or a “## Vector Storage” heading within them. Before merging, broken doc links could confuse users, so please double-check:

  • That a file exists at
    content/SDKs/javascript/api-reference/index.mdx (or content/SDKs/javascript/api-reference.mdx)
    and contains a third-level heading exactly matching ## Vector Storage (to generate the #vector-storage anchor).
  • That a file exists at
    content/SDKs/python/api-reference/index.mdx (or content/SDKs/python/api-reference.mdx)
    and likewise includes a ## Vector Storage heading for the #vector-storage anchor.

Once you’ve confirmed (or corrected) the file paths and headings, you can resolve this comment.


199-204: Example links validated

Both SDK example pages include the expected sections and matching anchors:

  • JavaScript SDK Examples
    The file content/SDKs/javascript/examples/index.mdx contains a heading ## Vector Storage Usage, which slugifies to vector-storage-usage and matches the link /SDKs/javascript/examples#vector-storage-usage.
  • Python SDK Examples
    The file content/SDKs/python/examples/index.mdx includes a heading ## Vector Storage, which slugifies to vector-storage and matches the link /SDKs/python/examples#vector-storage.

All links are present and correct.

Comment on lines +364 to +371
const filteredResults = searchResults
.filter(result => !maxPrice || result.metadata.price <= maxPrice)
.map(result => ({
...result.metadata,
similarity: result.similarity
}))
.sort((a, b) => b.similarity - a.similarity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix maxPrice filter edge case (0 and falsy values)

The current check uses !maxPrice, which treats 0 as “no filter” and may include overpriced items. Also guard against missing price.

Apply:

-    const filteredResults = searchResults
-      .filter(result => !maxPrice || result.metadata.price <= maxPrice)
+    const filteredResults = searchResults
+      .filter(r => maxPrice == null || (typeof r.metadata?.price === 'number' && r.metadata.price <= maxPrice))
       .map(result => ({
         ...result.metadata,
         similarity: result.similarity
       }))
       .sort((a, b) => b.similarity - a.similarity);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const filteredResults = searchResults
.filter(result => !maxPrice || result.metadata.price <= maxPrice)
.map(result => ({
...result.metadata,
similarity: result.similarity
}))
.sort((a, b) => b.similarity - a.similarity);
const filteredResults = searchResults
.filter(r => maxPrice == null || (typeof r.metadata?.price === 'number' && r.metadata.price <= maxPrice))
.map(result => ({
...result.metadata,
similarity: result.similarity
}))
.sort((a, b) => b.similarity - a.similarity);
🤖 Prompt for AI Agents
In content/Guides/vector-db.mdx around lines 364 to 371, the maxPrice check uses
!maxPrice which treats 0 as "no filter" and doesn't guard against missing price;
change the filter logic to treat undefined/null maxPrice as "no filter" but
apply the numeric comparison when maxPrice is provided, and also ensure items
with missing price are excluded when a maxPrice is specified (e.g., check
maxPrice == null to allow zero, and require result.metadata.price != null before
comparing).

Comment on lines +419 to +421
if max_price and result.metadata.get("price", 0) > max_price:
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Python: same max_price falsy bug as JS; use explicit None check

If max_price is 0, the current condition skips filtering. Use is not None.

-            if max_price and result.metadata.get("price", 0) > max_price:
+            if max_price is not None and result.metadata.get("price", 0) > max_price:
                 continue
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if max_price and result.metadata.get("price", 0) > max_price:
continue
if max_price is not None and result.metadata.get("price", 0) > max_price:
continue
🤖 Prompt for AI Agents
In content/Guides/vector-db.mdx around lines 419 to 421, the price filter uses a
falsy check ("if max_price and ...") which incorrectly ignores a valid max_price
of 0; replace the truthy check with an explicit None check so the condition
reads: if max_price is not None and result.metadata.get("price", 0) > max_price:
continue, ensuring zero is treated as a valid limit.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
content/Guides/vector-db.mdx (2)

363-371: Fix JS price filter: handle 0 and missing/null prices correctly.

Current !maxPrice treats 0 as “no filter” and doesn’t guard missing price.

Apply:

-    const filteredResults = searchResults
-      .filter(result => !maxPrice || result.metadata.price <= maxPrice)
+    const filteredResults = searchResults
+      .filter(r => maxPrice == null || (typeof r.metadata?.price === 'number' && r.metadata.price <= maxPrice))
       .map(result => ({
         ...result.metadata,
         similarity: result.similarity
       }))
       .sort((a, b) => b.similarity - a.similarity);

419-424: Fix Python price filter: treat 0 as valid and guard non-numeric/missing price.

Truthiness check skips filtering when max_price=0; also compare only when price is numeric.

Apply:

-            if max_price and result.metadata.get("price", 0) > max_price:
-                continue
+            price = result.metadata.get("price")
+            if max_price is not None:
+                if not isinstance(price, (int, float)):
+                    continue
+                if price > max_price:
+                    continue
🧹 Nitpick comments (4)
content/Guides/vector-db.mdx (4)

136-140: Harden result logging against missing metadata.

Accessing result.metadata.source can throw if metadata is absent.

Apply:

-  console.log(`Found: ${result.metadata.source}`);
-  console.log(`Similarity: ${result.similarity}`);
+  console.log(`Found: ${result.metadata?.source ?? 'unknown'}`);
+  console.log(`Similarity: ${result.similarity}`);

95-103: Unify key style across JS/Python examples.

Docs mix doc-1 (JS) and doc_1 (Python). Use one style to reduce confusion.

Apply:

-        "key": "doc_1",  # Required: unique identifier for this vector
+        "key": "doc-1",  # Required: unique identifier for this vector
...
-        "key": "doc_2",  # Required: unique identifier for this vector
+        "key": "doc-2",  # Required: unique identifier for this vector
...
-        "key": "embedding_1",  # Required: unique identifier for this vector
+        "key": "embedding-1",  # Required: unique identifier for this vector

Also applies to: 100-103, 111-114


58-60: Call out key uniqueness scope (per storage instance).

Readers benefit from knowing the uniqueness boundary for idempotency.

Apply:

 The upsert operation is idempotent - upserting with an existing key updates the existing vector rather than creating a duplicate. The same internal vector ID is reused, ensuring your vector storage remains clean and efficient.
+Keys must be unique within a given vector storage instance; reusing a key in the same instance updates that vector.

246-248: Optional: reduce ambiguity around placeholder LLM calls.

Add a one-line stub or comment so readers know generateAnswer/generate_answer are placeholders.

Apply (JS shown; mirror in Python):

-    // Use your preferred LLM here (OpenAI, Anthropic, etc.)
-    const llmResponse = await generateAnswer(prompt);
+    // Placeholder: implement with your preferred LLM client
+    const llmResponse = await generateAnswer(prompt); // user-defined

Also applies to: 308-310

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4e6d5bc and e72fc7f.

📒 Files selected for processing (1)
  • content/Guides/vector-db.mdx (6 hunks)
🧰 Additional context used
🪛 LanguageTool
content/Guides/vector-db.mdx

[grammar] ~47-~47: There might be a mistake here.
Context: ...PI For complete API documentation, see: - [JavaScript SDK Vector API Reference](/SD...

(QB_NEW_EN)


[grammar] ~48-~48: There might be a mistake here.
Context: ...: - JavaScript SDK Vector API Reference - [Python SDK Vector API Reference](/SDKs/p...

(QB_NEW_EN)


[grammar] ~55-~55: There might be a mistake here.
Context: ...omputed embeddings. SDK Requirements: - Both SDKs: Require a key field for e...

(QB_NEW_EN)


[grammar] ~139-~139: There might be a mistake here.
Context: ...log(Similarity: ${result.similarity}); }); python # Python # Semantic s...

(QB_NEW_EN)


[grammar] ~167-~167: There might be a mistake here.
Context: ...adata key-value pairs Search Results: - Both SDKs: Return results with `simila...

(QB_NEW_EN)


[grammar] ~182-~182: There might be a mistake here.
Context: ..., 'doc-1'); // Delete multiple vectors const bulkDeleteCount = await context.ve...

(QB_NEW_EN)


[grammar] ~183-~183: There might be a mistake here.
Context: ...leteCount = await context.vector.delete( 'knowledge-base', 'doc-1', 'doc-2', '...

(QB_NEW_EN)


[grammar] ~185-~185: There might be a mistake here.
Context: ...edge-base', 'doc-1', 'doc-2', 'doc-3' ); python # Python # Delete sing...

(QB_NEW_EN)


[grammar] ~201-~201: There might be a mistake here.
Context: ...l Examples For more code examples, see: - [JavaScript SDK Examples](/SDKs/javascrip...

(QB_NEW_EN)


[grammar] ~202-~202: There might be a mistake here.
Context: ...xamples, see: - JavaScript SDK Examples - [Python SDK Examples](/SDKs/python/exampl...

(QB_NEW_EN)


[grammar] ~209-~209: There might be a mistake here.
Context: ...t/TypeScript - Simple RAG implementation import { AgentHandler } from '@agentuity...

(QB_NEW_EN)


[grammar] ~212-~212: There might be a mistake here.
Context: ... async (request, response, context) => { const { question } = await request.data....

(QB_NEW_EN)


[grammar] ~260-~260: There might be a mistake here.
Context: ... })) }); } catch (error) { context.logger.error('RAG query failed:'...

(QB_NEW_EN)


[grammar] ~266-~266: There might be a mistake here.
Context: ... details: error.message }); } }; export default handler;} py={# Pyt...

(QB_NEW_EN)


[grammar] ~269-~269: There might be a mistake here.
Context: ...y={`# Python - Simple RAG implementation from agentuity import AgentRequest, Agen...

(QB_NEW_EN)


[grammar] ~272-~272: There might be a mistake here.
Context: ...: AgentResponse, context: AgentContext): data = await request.data.json() que...

(QB_NEW_EN)


[grammar] ~332-~332: There might be a mistake here.
Context: ...": str(e) })`} /> Key Points: - Semantic search finds relevant documen...

(QB_NEW_EN)


[grammar] ~343-~343: There might be a mistake here.
Context: ...TypeScript - Product search with filters import { AgentHandler } from '@agentuity...

(QB_NEW_EN)


[grammar] ~346-~346: There might be a mistake here.
Context: ... async (request, response, context) => { const { query, maxPrice, category, inSto...

(QB_NEW_EN)


[grammar] ~349-~349: There might be a mistake here.
Context: ... = await request.data.json(); try { // Build metadata filters based on crite...

(QB_NEW_EN)


[grammar] ~379-~379: There might be a mistake here.
Context: ...results }); } catch (error) { context.logger.error('Product search fai...

(QB_NEW_EN)


[grammar] ~385-~385: There might be a mistake here.
Context: ...failed', products: [] }); } }; export default handler;} py={# Pyt...

(QB_NEW_EN)


[grammar] ~388-~388: There might be a mistake here.
Context: ...{`# Python - Product search with filters from agentuity import AgentRequest, Agen...

(QB_NEW_EN)


[grammar] ~391-~391: There might be a mistake here.
Context: ...: AgentResponse, context: AgentContext): data = await request.data.json() que...

(QB_NEW_EN)


[grammar] ~443-~443: There might be a mistake here.
Context: ...": [] })`} /> Key Techniques: - Metadata filters are applied at the ve...

(QB_NEW_EN)


[grammar] ~450-~450: There might be a mistake here.
Context: ...ls & Solutions ### Empty Search Results Problem: Your search returns empty res...

(QB_NEW_EN)


[grammar] ~453-~453: There might be a mistake here.
Context: ...gh relevant data exists. Solutions: - Lower the similarity threshold: Start ...

(QB_NEW_EN)


[grammar] ~474-~474: There might be a mistake here.
Context: ....5 }); } ``` ### Duplicate Documents Problem: Same content appears multiple...

(QB_NEW_EN)


[grammar] ~477-~477: There might be a mistake here.
Context: ...t is idempotent when using the same key: - Always use consistent key values for y...

(QB_NEW_EN)


[grammar] ~482-~482: There might be a mistake here.
Context: ...ur storage clean ### Performance Issues Problem: Vector operations take too lo...

(QB_NEW_EN)


[grammar] ~485-~485: There might be a mistake here.
Context: ...perations take too long. Solutions: - Batch operations: Upsert 100-500 docum...

(QB_NEW_EN)


[grammar] ~490-~490: There might be a mistake here.
Context: ...d focused ### Irrelevant Search Results Problem: Search returns irrelevant or ...

(QB_NEW_EN)


[grammar] ~493-~493: There might be a mistake here.
Context: ...or unexpected documents. Solutions: - Check similarity scores: Results with ...

(QB_NEW_EN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Workers Builds: docs
🔇 Additional comments (1)
content/Guides/vector-db.mdx (1)

167-170: Good clarification on similarity vs. distance.

Clear that similarity is primary and distance is a legacy result field in JS. Nice.

@parteeksingh24 parteeksingh24 merged commit 732f134 into main Aug 28, 2025
2 checks passed
@parteeksingh24 parteeksingh24 deleted the parteek/update-docs-examples branch August 28, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants