158 lines
5.9 KiB
Markdown
158 lines
5.9 KiB
Markdown
# 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
|
|
|
|
<DocsCards>
|
|
<DocsCard header="Use embedded seekdb" href="./100.get-started/50.embedded-mode/25.using-seekdb-in-python-sdk.md">
|
|
<p>A lightweight and easy-to-use deployment mode recommended for both testing and production, delivering stable and efficient service.</p>
|
|
</DocsCard>
|
|
|
|
<DocsCard header="Use server mode seekdb" href="./100.get-started/50.embedded-mode/25.using-seekdb-in-python-sdk.md">
|
|
<p>Recommended deployment mode for testing and production environments. Lightweight and easy to use, ideal for stable and efficient service provision.</p>
|
|
</DocsCard>
|
|
</DocsCards>
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
<Tabs>
|
|
<TabItem value="embedded" label="Embedded mode" default>
|
|
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}")
|
|
|
|
```
|
|
</TabItem>
|
|
<TabItem value="server" label="Server mode">
|
|
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}")
|
|
```
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
## Start building
|
|
|
|
<DocsCards>
|
|
<DocsCard header="pyseekdb (Python SDK)" href="./200.develop/900.sdk/10.pyseekdb-sdk/10.pyseekdb-sdk-get-started.md">
|
|
<p>Overview and examples for using the seekdb Python SDK and API.</p>
|
|
</DocsCard>
|
|
|
|
<DocsCard header="Integrations" href="./300.integrations/100.model/100.jina.md">
|
|
<p>See how seekdb connects with third-party platforms, with practical examples.</p>
|
|
</DocsCard>
|
|
|
|
<DocsCard header="Tutorials" href="./500.tutorials/100.create-ai-app-demo/100.build-kb-in-seekdb.md">
|
|
<p>Step-by-step guides to using seekdb's AI features and building AI apps.</p>
|
|
</DocsCard>
|
|
</DocsCards> |