beaver-db 0.16.8__tar.gz → 0.17.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of beaver-db might be problematic. Click here for more details.
- {beaver_db-0.16.8 → beaver_db-0.17.0}/PKG-INFO +12 -3
- beaver_db-0.17.0/beaver/cli.py +34 -0
- beaver_db-0.17.0/beaver/server.py +132 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/fts.py +2 -2
- {beaver_db-0.16.8 → beaver_db-0.17.0}/makefile +1 -1
- {beaver_db-0.16.8 → beaver_db-0.17.0}/pyproject.toml +9 -5
- beaver_db-0.17.0/uv.lock +850 -0
- beaver_db-0.16.8/uv.lock +0 -238
- {beaver_db-0.16.8 → beaver_db-0.17.0}/.gitignore +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/.python-version +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/LICENSE +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/README.md +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/__init__.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/blobs.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/channels.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/collections.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/core.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/dicts.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/lists.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/logs.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/queues.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/types.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/beaver/vectors.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/design.md +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/async_pubsub.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/blobs.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/cache.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/fuzzy.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/general_test.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/graph.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/kvstore.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/list.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/logs.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/pqueue.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/producer_consumer.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/publisher.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/pubsub.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/rerank.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/stress_vectors.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/subscriber.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/textual_chat.css +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/textual_chat.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/type_hints.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/examples/vector.py +0 -0
- {beaver_db-0.16.8 → beaver_db-0.17.0}/roadmap.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: beaver-db
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: Fast, embedded, and multi-modal DB based on SQLite for AI-powered applications.
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -9,8 +9,17 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
9
9
|
Classifier: Topic :: Database
|
|
10
10
|
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
11
11
|
Requires-Python: >=3.13
|
|
12
|
-
Provides-Extra:
|
|
13
|
-
Requires-Dist:
|
|
12
|
+
Provides-Extra: cli
|
|
13
|
+
Requires-Dist: typer>=0.19.2; extra == 'cli'
|
|
14
|
+
Provides-Extra: full
|
|
15
|
+
Requires-Dist: faiss-cpu>=1.12.0; extra == 'full'
|
|
16
|
+
Requires-Dist: fastapi[standard]>=0.118.0; extra == 'full'
|
|
17
|
+
Requires-Dist: typer>=0.19.2; extra == 'full'
|
|
18
|
+
Provides-Extra: server
|
|
19
|
+
Requires-Dist: fastapi[standard]>=0.118.0; extra == 'server'
|
|
20
|
+
Requires-Dist: typer>=0.19.2; extra == 'server'
|
|
21
|
+
Provides-Extra: vector
|
|
22
|
+
Requires-Dist: faiss-cpu>=1.12.0; extra == 'vector'
|
|
14
23
|
Description-Content-Type: text/markdown
|
|
15
24
|
|
|
16
25
|
# beaver 🦫
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
import rich
|
|
3
|
+
|
|
4
|
+
app = typer.Typer()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@app.command()
|
|
8
|
+
def serve(
|
|
9
|
+
database: str = typer.Option(
|
|
10
|
+
"beaver.db", "--database", "-d", help="Path to the database file."
|
|
11
|
+
),
|
|
12
|
+
host: str = typer.Option(
|
|
13
|
+
"127.0.0.1", "--host", "-h", help="The host to bind the server to."
|
|
14
|
+
),
|
|
15
|
+
port: int = typer.Option(
|
|
16
|
+
8000, "--port", "-p", help="The port to run the server on."
|
|
17
|
+
),
|
|
18
|
+
):
|
|
19
|
+
"""
|
|
20
|
+
Starts a RESTful API server for a BeaverDB instance.
|
|
21
|
+
"""
|
|
22
|
+
try:
|
|
23
|
+
from .server import serve as run_server
|
|
24
|
+
except ImportError as e:
|
|
25
|
+
rich.print(f"[red]Error: {e}[/]")
|
|
26
|
+
rich.print('[yellow]Please install the server dependencies with `pip install "beaver-db[server]"`[/]')
|
|
27
|
+
raise typer.Exit(code=1)
|
|
28
|
+
|
|
29
|
+
rich.print(f"[blue]Starting server for database at '{database}' on http://{host}:{port}[/]")
|
|
30
|
+
run_server(db_path=database, host=host, port=port)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if __name__ == "__main__":
|
|
34
|
+
app()
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from fastapi import FastAPI, HTTPException, Body
|
|
3
|
+
import uvicorn
|
|
4
|
+
except ImportError:
|
|
5
|
+
raise ImportError(
|
|
6
|
+
"FastAPI and Uvicorn are required to serve the database. "
|
|
7
|
+
'Please install them with `pip install "beaver-db[server]"`'
|
|
8
|
+
)
|
|
9
|
+
from typing import Any
|
|
10
|
+
from .core import BeaverDB
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def build(db: BeaverDB) -> FastAPI:
|
|
14
|
+
"""
|
|
15
|
+
Constructs a FastAPI application instance for a given BeaverDB instance.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
db: An active BeaverDB instance.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
A FastAPI application with all endpoints configured.
|
|
22
|
+
"""
|
|
23
|
+
app = FastAPI(
|
|
24
|
+
title="BeaverDB",
|
|
25
|
+
description="A RESTful API for a BeaverDB instance.",
|
|
26
|
+
version="0.1.0",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# --- Dicts Endpoints ---
|
|
30
|
+
|
|
31
|
+
@app.get("/dicts/{name}")
|
|
32
|
+
def get_all_dict_items(name: str) -> dict:
|
|
33
|
+
"""Retrieves all key-value pairs in a dictionary."""
|
|
34
|
+
d = db.dict(name)
|
|
35
|
+
return {k: v for k, v in d.items()}
|
|
36
|
+
|
|
37
|
+
@app.get("/dicts/{name}/{key}")
|
|
38
|
+
def get_dict_item(name: str, key: str) -> Any:
|
|
39
|
+
"""Retrieves the value for a specific key."""
|
|
40
|
+
d = db.dict(name)
|
|
41
|
+
try:
|
|
42
|
+
return d[key]
|
|
43
|
+
except KeyError:
|
|
44
|
+
raise HTTPException(status_code=404, detail=f"Key '{key}' not found in dictionary '{name}'")
|
|
45
|
+
|
|
46
|
+
@app.post("/dicts/{name}/{key}")
|
|
47
|
+
def set_dict_item(name: str, key: str, value: Any = Body(...)):
|
|
48
|
+
"""Sets the value for a specific key."""
|
|
49
|
+
d = db.dict(name)
|
|
50
|
+
d[key] = value
|
|
51
|
+
return {"status": "ok"}
|
|
52
|
+
|
|
53
|
+
@app.delete("/dicts/{name}/{key}")
|
|
54
|
+
def delete_dict_item(name: str, key: str):
|
|
55
|
+
"""Deletes a key-value pair."""
|
|
56
|
+
d = db.dict(name)
|
|
57
|
+
try:
|
|
58
|
+
del d[key]
|
|
59
|
+
return {"status": "ok"}
|
|
60
|
+
except KeyError:
|
|
61
|
+
raise HTTPException(status_code=404, detail=f"Key '{key}' not found in dictionary '{name}'")
|
|
62
|
+
|
|
63
|
+
# --- Lists Endpoints ---
|
|
64
|
+
|
|
65
|
+
@app.get("/lists/{name}")
|
|
66
|
+
def get_list(name: str) -> list:
|
|
67
|
+
"""Retrieves all items in the list."""
|
|
68
|
+
l = db.list(name)
|
|
69
|
+
return l[:]
|
|
70
|
+
|
|
71
|
+
@app.get("/lists/{name}/{index}")
|
|
72
|
+
def get_list_item(name: str, index: int) -> Any:
|
|
73
|
+
"""Retrieves the item at a specific index."""
|
|
74
|
+
l = db.list(name)
|
|
75
|
+
try:
|
|
76
|
+
return l[index]
|
|
77
|
+
except IndexError:
|
|
78
|
+
raise HTTPException(status_code=404, detail=f"Index {index} out of bounds for list '{name}'")
|
|
79
|
+
|
|
80
|
+
@app.post("/lists/{name}")
|
|
81
|
+
def push_list_item(name: str, value: Any = Body(...)):
|
|
82
|
+
"""Adds an item to the end of the list."""
|
|
83
|
+
l = db.list(name)
|
|
84
|
+
l.push(value)
|
|
85
|
+
return {"status": "ok"}
|
|
86
|
+
|
|
87
|
+
@app.put("/lists/{name}/{index}")
|
|
88
|
+
def update_list_item(name: str, index: int, value: Any = Body(...)):
|
|
89
|
+
"""Updates the item at a specific index."""
|
|
90
|
+
l = db.list(name)
|
|
91
|
+
try:
|
|
92
|
+
l[index] = value
|
|
93
|
+
return {"status": "ok"}
|
|
94
|
+
except IndexError:
|
|
95
|
+
raise HTTPException(status_code=404, detail=f"Index {index} out of bounds for list '{name}'")
|
|
96
|
+
|
|
97
|
+
@app.delete("/lists/{name}/{index}")
|
|
98
|
+
def delete_list_item(name: str, index: int):
|
|
99
|
+
"""Deletes the item at a specific index."""
|
|
100
|
+
l = db.list(name)
|
|
101
|
+
try:
|
|
102
|
+
del l[index]
|
|
103
|
+
return {"status": "ok"}
|
|
104
|
+
except IndexError:
|
|
105
|
+
raise HTTPException(status_code=404, detail=f"Index {index} out of bounds for list '{name}'")
|
|
106
|
+
|
|
107
|
+
# TODO: Add endpoints for all BeaverDB modalities
|
|
108
|
+
# - Queues
|
|
109
|
+
# - Collections
|
|
110
|
+
# - Channels
|
|
111
|
+
# - Logs
|
|
112
|
+
# - Blobs
|
|
113
|
+
|
|
114
|
+
@app.get("/")
|
|
115
|
+
def read_root():
|
|
116
|
+
return {"message": "Welcome to the BeaverDB API"}
|
|
117
|
+
|
|
118
|
+
return app
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def serve(db_path: str, host: str, port: int):
|
|
122
|
+
"""
|
|
123
|
+
Initializes a BeaverDB instance and runs a Uvicorn server for it.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
db_path: The path to the SQLite database file.
|
|
127
|
+
host: The host to bind the server to.
|
|
128
|
+
port: The port to run the server on.
|
|
129
|
+
"""
|
|
130
|
+
db = BeaverDB(db_path)
|
|
131
|
+
app = build(db)
|
|
132
|
+
uvicorn.run(app, host=host, port=port)
|
|
@@ -64,9 +64,9 @@ def full_text_search_demo():
|
|
|
64
64
|
|
|
65
65
|
# --- 3. Perform a Targeted Full-Text Search on a Specific Field ---
|
|
66
66
|
|
|
67
|
-
# Now, we search for "Jane" but ONLY in the flattened '
|
|
67
|
+
# Now, we search for "Jane" but ONLY in the flattened 'author.name' field.
|
|
68
68
|
# This should return only the documents by Jane Doe (doc1 and doc3).
|
|
69
|
-
print("\n--- Specific Search for 'Jane' in the '
|
|
69
|
+
print("\n--- Specific Search for 'Jane' in the 'author.name' field ---")
|
|
70
70
|
specific_results = articles.match("Jane", on="author.name", top_k=5)
|
|
71
71
|
|
|
72
72
|
for doc, rank in specific_results:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "beaver-db"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.17.0"
|
|
4
4
|
description = "Fast, embedded, and multi-modal DB based on SQLite for AI-powered applications."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.13"
|
|
@@ -12,6 +12,9 @@ classifiers = [
|
|
|
12
12
|
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
13
13
|
]
|
|
14
14
|
|
|
15
|
+
[project.scripts]
|
|
16
|
+
beaver = "beaver.cli:app"
|
|
17
|
+
|
|
15
18
|
[build-system]
|
|
16
19
|
requires = ["hatchling"]
|
|
17
20
|
build-backend = "hatchling.build"
|
|
@@ -20,9 +23,10 @@ build-backend = "hatchling.build"
|
|
|
20
23
|
packages = ["beaver"]
|
|
21
24
|
|
|
22
25
|
[project.optional-dependencies]
|
|
23
|
-
|
|
26
|
+
vector = ["faiss-cpu>=1.12.0"]
|
|
27
|
+
server = ["fastapi[standard]>=0.118.0", "typer>=0.19.2"]
|
|
28
|
+
cli = ["typer>=0.19.2"]
|
|
29
|
+
full = ["faiss-cpu>=1.12.0", "fastapi[standard]>=0.118.0", "typer>=0.19.2"]
|
|
24
30
|
|
|
25
31
|
[dependency-groups]
|
|
26
|
-
dev = [
|
|
27
|
-
"textual>=6.1.0",
|
|
28
|
-
]
|
|
32
|
+
dev = ["textual>=6.1.0"]
|