Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Mastra integration #1345

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions qdrant-landing/content/documentation/frameworks/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ partition: build
| [Langchain4j](/documentation/frameworks/langchain4j/) | Java framework for building context-aware, reasoning applications using LLMs. |
| [LangGraph](/documentation/frameworks/langgraph/) | Python, Javascript libraries for building stateful, multi-actor applications. |
| [LlamaIndex](/documentation/frameworks/llama-index/) | A data framework for building LLM applications with modular integrations. |
| [Mastra](/documentation/frameworks/mastra/) | Typescript framework to build AI applications and features quickly. |
| [Mem0](/documentation/frameworks/mem0/) | Self-improving memory layer for LLM applications, enabling personalized AI experiences. |
| [MemGPT](/documentation/frameworks/memgpt/) | System to build LLM agents with long term memory & custom tools |
| [Neo4j GraphRAG](/documentation/frameworks/neo4j-graphrag/) | Package to build graph retrieval augmented generation (GraphRAG) applications using Neo4j and Python. |
Expand Down
104 changes: 104 additions & 0 deletions qdrant-landing/content/documentation/frameworks/mastra.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
title: Mastra
---

# Mastra

[Mastra](https://mastra.ai/) is a Typescript framework to build AI applications and features quickly. It gives you the set of primitives you need: workflows, agents, RAG, integrations, syncs and evals. You can run Mastra on your local machine, or deploy to a serverless cloud.

Qdrant is available as a vector store in Mastra node to augment application with retrieval capabilities.

## Setup

```bash
npm install @mastra/core
```

## Usage

```typescript
import { QdrantVector } from "@mastra/rag";

const qdrant = new QdrantVector({
url: "https://xyz-example.eu-central.aws.cloud.qdrant.io:6333"
apiKey: "<YOUR_API_KEY>",
https: true
});
```

## Constructor Options

| Name | Type | Description |
|--------|-----------|-------------------------------------------------------------------------------------------------------|
| `url` | `string` | REST URL of the Qdrant instance. Eg. <https://xyz-example.eu-central.aws.cloud.qdrant.io:6333> |
| `apiKey` | `string` | Optional Qdrant API key |
| `https` | `boolean` | Whether to use TLS when setting up the connection. Recommended. |

## Methods

### `createIndex()`

| Name | Type | Description | Default Value |
|------------|------------------------------------------|-------------------------------------------------|--------------|
| `indexName` | `string` | Name of the index to create | |
| `dimension` | `number` | Vector dimension size | |
| `metric` | `string` | Distance metric for similarity search | `cosine` |

### `upsert()`

| Name | Type | Description | Default Value |
|-------------|---------------------------|-----------------------------------------|--------------|
| `vectors` | `number[][]` | Array of embedding vectors | |
| `metadata` | `Record<string, any>[]` | Metadata for each vector (optional) | |
| `namespace` | `string` | Optional namespace for organization | |

### `query()`

| Name | Type | Description | Default Value |
|------------|-------------------------|---------------------------------------------|--------------|
| `vector` | `number[]` | Query vector to find similar vectors | |
| `topK` | `number` | Number of results to return (optional) | `10` |
| `filter` | `Record<string, any>` | Metadata filters for the query (optional) | |

### `listIndexes()`

Returns an array of index names as strings.

### `describeIndex()`

| Name | Type | Description |
|-------------|----------|----------------------------------|
| `indexName` | `string` | Name of the index to describe |

#### Returns

```typescript
interface IndexStats {
dimension: number;
count: number;
metric: "cosine" | "euclidean" | "dotproduct";
}
```

### `deleteIndex()`

| Name | Type | Description |
|-------------|----------|----------------------------------|
| `indexName` | `string` | Name of the index to delete |

## Response Types

Query results are returned in this format:

```typescript
interface QueryResult {
id: string;
score: number;
metadata: Record<string, any>;
}
```

## Further Reading

- [Mastra Examples](https://github.com/mastra-ai/mastra/tree/main/examples)
- [Mastra Documentation](http://mastra.ai/docs/)
Loading