Skip to content

Commit

Permalink
updated docs and README
Browse files Browse the repository at this point in the history
  • Loading branch information
NikAiyer committed Feb 21, 2025
1 parent 6d50fb6 commit 0fa343c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 12 deletions.
77 changes: 76 additions & 1 deletion docs/src/pages/docs/reference/rag/pg.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,74 @@ It provides robust vector similarity search capabilities within your existing Po
defaultValue: "cosine",
description: "Distance metric for similarity search",
},
{
name: "indexConfig",
type: "IndexConfig",
isOptional: true,
description: "Index configuration",
},
]}
/>

#### IndexConfig

<PropertiesTable
content={[
{
name: "type",
type: "'flat' | 'hnsw' | 'ivfflat'",
description: "Index type",
},
{
name: "ivf",
type: "IVFConfig",
isOptional: true,
description: "IVF configuration",
properties: [
{
type: "object",
parameters: [
{
name: "lists",
type: "number",
description: "Number of lists (default: 100)",
isOptional: true,
},
{
name: "probes",
type: "number",
description: "Number of probes (default: 1)",
isOptional: true,
},
],
},
],
},
{
name: "hnsw",
type: "HNSWConfig",
isOptional: true,
description: "HNSW configuration",
properties: [
{
type: "object",
parameters: [
{
name: "m",
type: "number",
description: "Max number of connections (default: 16)",
isOptional: true,
},
{
name: "efConstruction",
type: "number",
description: "Build-time complexity (default: 64)",
isOptional: true,
},
],
},
]
},
]}
/>

Expand Down Expand Up @@ -138,10 +206,17 @@ Returns an array of index names as strings.
Returns:

```typescript copy
interface IndexStats {
interface PGIndexStats {
dimension: number;
count: number;
metric: "cosine" | "euclidean" | "dotproduct";
type: "flat" | "hnsw" | "ivfflat";
config: {
m?: number;
efConstruction?: number;
lists?: number;
probes?: number;
};
}
```

Expand Down
26 changes: 16 additions & 10 deletions stores/pg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,27 @@ const store = new PostgresStore({
port: 5432,
database: 'mastra',
user: 'postgres',
password: 'postgres'
password: 'postgres',
});

// Create a thread
await store.saveThread({
id: 'thread-123',
resourceId: 'resource-456',
title: 'My Thread',
metadata: { key: 'value' }
metadata: { key: 'value' },
});

// Add messages to thread
await store.saveMessages([{
id: 'msg-789',
threadId: 'thread-123',
role: 'user',
type: 'text',
content: [{ type: 'text', text: 'Hello' }]
}]);
await store.saveMessages([
{
id: 'msg-789',
threadId: 'thread-123',
role: 'user',
type: 'text',
content: [{ type: 'text', text: 'Hello' }],
},
]);

// Query threads and messages
const savedThread = await store.getThread('thread-123');
Expand All @@ -97,14 +99,18 @@ Connection pool settings:
## Features

### Vector Store Features

- Vector similarity search with cosine, euclidean, and dot product metrics
- Advanced metadata filtering with MongoDB-like query syntax
- Minimum score threshold for queries
- Automatic UUID generation for vectors
- Table management (create, list, describe, delete, truncate)
- Uses pgvector's IVFFLAT indexing with 100 lists
- Uses pgvector's IVFFLAT indexing with 100 lists by default
- Supports HNSW indexing with configurable parameters
- Supports flat indexing

### Storage Features

- Thread and message storage with JSON support
- Atomic transactions for data consistency
- Efficient batch operations
Expand Down
1 change: 0 additions & 1 deletion stores/pg/src/vector/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ interface IVFConfig {
interface HNSWConfig {
m?: number; // Max number of connections (default: 16)
efConstruction?: number; // Build-time complexity (default: 64)
ef?: number; // Search-time complexity (default: 40)
}

export interface IndexConfig {
Expand Down

0 comments on commit 0fa343c

Please sign in to comment.