5.9 KiB
seekdb documentation
import DocsCard from '@components/global/DocsCard'; import DocsCards from '@components/global/DocsCards';
The seekdb documentation provides a wide range of resources, including step-by-step getting started guides, examples of building AI applications with live demos, SDK and API code samples, comprehensive feature overviews, and detailed user manuals—all designed to help you quickly get up to speed and make the most of seekdb.
Get started
A minimalist API design that keeps you focused on building your AI
A lightweight and easy-to-use deployment mode recommended for both testing and production, delivering stable and efficient service.
Recommended deployment mode for testing and production environments. Lightweight and easy to use, ideal for stable and efficient service provision.
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
1. Set up ```python
import pyseekdb
client = pyseekdb.Client()
# create a knowledge base
collection = client.get_or_create_collection("product_database")
```
2. Insert
```python
# Add product documents
collection.upsert(
documents=[
"Laptop Pro with 16GB RAM, 512GB SSD, and high-speed processor",
"Gaming Laptop with 32GB RAM, 1TB SSD, and high-performance graphics",
"Business Ultrabook with 8GB RAM, 256GB SSD, and long battery life",
"Tablet with 6GB RAM, 128GB storage, and 10-inch display"
],
metadatas=[
{"category": "laptop", "ram": 16, "storage": 512, "price": 12000, "type": "professional"},
{"category": "laptop", "ram": 32, "storage": 1000, "price": 25000, "type": "gaming"},
{"category": "laptop", "ram": 8, "storage": 256, "price": 9000, "type": "business"},
{"category": "tablet", "ram": 6, "storage": 128, "price": 6000, "type": "consumer"}
],
ids=["1", "2", "3", "4"]
)
print("Product database built\n")
```
3. Query
```python
# Hybrid search for high-performance laptops
print("Hybrid Search: High-performance laptops for professional work")
results = collection.query(
query_texts=["powerful computer for professional work"], # Vector search
where={ # Relational filter
"category": "laptop",
"ram": {"$gte": 16}
},
where_document={"$contains": "RAM"}, # Full-text search
n_results=2
)
print("\nResults:")
for i, (doc, metadata) in enumerate(zip(results['documents'][0], results['metadatas'][0])):
print(f" {i+1}. {doc}")
```
1. Set up
```python
import pyseekdb
client = pyseekdb.Client(
host = "127.0.0.1", # server host
port = 2881, # server port (default: 2881)
)
# create a knowledge base
collection = client.get_or_create_collection("product_database")
```
2. Insert
```python
# Add product documents
collection.upsert(
documents=[
"Laptop Pro with 16GB RAM, 512GB SSD, and high-speed processor",
"Gaming Laptop with 32GB RAM, 1TB SSD, and high-performance graphics",
"Business Ultrabook with 8GB RAM, 256GB SSD, and long battery life",
"Tablet with 6GB RAM, 128GB storage, and 10-inch display"
],
metadatas=[
{"category": "laptop", "ram": 16, "storage": 512, "price": 12000, "type": "professional"},
{"category": "laptop", "ram": 32, "storage": 1000, "price": 25000, "type": "gaming"},
{"category": "laptop", "ram": 8, "storage": 256, "price": 9000, "type": "business"},
{"category": "tablet", "ram": 6, "storage": 128, "price": 6000, "type": "consumer"}
],
ids=["1", "2", "3", "4"]
)
print("Product database built\n")
```
3. Query
```python
# Hybrid search for high-performance laptops
print("Hybrid Search: High-performance laptops for professional work")
results = collection.query(
query_texts=["powerful computer for professional work"], # Vector search
where={ # Relational filter
"category": "laptop",
"ram": {"$gte": 16}
},
where_document={"$contains": "RAM"}, # Full-text search
n_results=2
)
print("\nResults:")
for i, (doc, metadata) in enumerate(zip(results['documents'][0], results['metadatas'][0])):
print(f" {i+1}. {doc}")
```
Start building
Overview and examples for using the seekdb Python SDK and API.
See how seekdb connects with third-party platforms, with practical examples.
Step-by-step guides to using seekdb's AI features and building AI apps.