Skip to content

Commit 32cdd2f

Browse files
docs: Add SurrealDB to storage documentation (#3163)
1 parent fbc9b64 commit 32cdd2f

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

docs/mintlify/key_modules/storages.mdx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ The <b>Storage</b> module in CAMEL-AI gives you a **unified interface for saving
6161
- Schema-based, semantic search, hybrid queries
6262

6363
**ChromaStorage**
64-
- For [ChromaDB](https://www.trychroma.com/) (AI-native open-source embedding database)
64+
- For [ChromaDB](https://www.trychroma.com/) (AI-native open-source embedding database)
6565
- Simple API, scales from notebook to production
6666

67+
**SurrealStorage**
68+
- For [SurrealDB](https://surrealdb.com/) (scalable, distributed database with WebSocket support)
69+
- Efficient vector storage and similarity search with real-time updates
70+
6771
**PgVectorStorage**
6872
- For [PostgreSQL with pgvector](https://github.com/pgvector/pgvector) (open-source vector engine)
6973
- Leverages PostgreSQL for vector search
@@ -298,6 +302,56 @@ Here are practical usage patterns for each storage type—pick the ones you need
298302

299303
---
300304

305+
<Card title="SurrealDB Vector Storage" icon="database">
306+
<b>Use for:</b> Scalable, distributed vector storage with WebSocket support.
307+
<b>Perfect for:</b> Real-time vector search with distributed deployments and SQL-like querying.
308+
309+
<Tabs>
310+
<Tab title="Python Example">
311+
```python
312+
import os
313+
from camel.storages import SurrealStorage, VectorDBQuery, VectorRecord
314+
315+
# Set environment variables for SurrealDB connection
316+
os.environ["SURREAL_URL"] = "ws://localhost:8000/rpc"
317+
os.environ["SURREAL_PASSWORD"] = "your_password"
318+
319+
# Create SurrealStorage instance with WebSocket connection
320+
surreal_storage = SurrealStorage(
321+
url=os.getenv("SURREAL_URL"),
322+
table="camel_vectors",
323+
namespace="ns",
324+
database="db",
325+
user="root",
326+
password=os.getenv("SURREAL_PASSWORD"),
327+
vector_dim=4,
328+
)
329+
330+
# Add vector records
331+
surreal_storage.add([
332+
VectorRecord(vector=[-0.1, 0.1, -0.1, 0.1], payload={'key1': 'value1'}),
333+
VectorRecord(vector=[-0.1, 0.1, 0.1, 0.1], payload={'key2': 'value2'}),
334+
])
335+
336+
# Query similar vectors
337+
query_results = surreal_storage.query(VectorDBQuery(query_vector=[0.1, 0.2, 0.1, 0.1], top_k=1))
338+
for result in query_results:
339+
print(result.record.payload, result.similarity)
340+
341+
# Clear all vectors
342+
surreal_storage.clear()
343+
```
344+
</Tab>
345+
<Tab title="Output">
346+
```markdown
347+
>>> {'key2': 'value2'} 0.5669467095138407
348+
```
349+
</Tab>
350+
</Tabs>
351+
</Card>
352+
353+
---
354+
301355
<Card title="OceanBase Vector Storage" icon="earth-oceania">
302356
<b>Use for:</b> Massive vector storage with advanced analytics.
303357
<b>Perfect for:</b> Batch operations, cloud or on-prem setups, and high-throughput search.

0 commit comments

Comments
 (0)