Skip to content

Commit c58eaad

Browse files
author
Daniele Briggi
committed
feat(ai): add use_gpu setting
False by default for wider compatibility.
1 parent 630839a commit c58eaad

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/sqlite_rag/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ def configure_settings(
143143
weight_vec: Optional[float] = typer.Option(
144144
None, help="Weight for vector search results"
145145
),
146+
use_gpu: Optional[bool] = typer.Option(
147+
None, help="Whether to allow sqlite-ai extension to use the GPU"
148+
),
146149
):
147150
"""Configure settings for the RAG system.
148151
@@ -165,6 +168,7 @@ def configure_settings(
165168
"quantize_preload": quantize_preload,
166169
"weight_fts": weight_fts,
167170
"weight_vec": weight_vec,
171+
"use_gpu": use_gpu,
168172
}
169173

170174
# Filter out None values (unset options)

src/sqlite_rag/database.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ def initialize(conn: sqlite3.Connection, settings: Settings) -> sqlite3.Connecti
2121
conn.enable_load_extension(True)
2222
try:
2323
conn.load_extension(
24-
str(importlib.resources.files("sqliteai.binaries.cpu") / "ai")
24+
str(
25+
importlib.resources.files(
26+
"sqliteai.binaries." + ("gpu" if settings.use_gpu else "cpu")
27+
)
28+
/ "ai"
29+
)
2530
)
2631
conn.load_extension(
2732
str(importlib.resources.files("sqlite-vector.binaries") / "vector")

src/sqlite_rag/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class Settings:
4444
weight_fts: float = 1.0
4545
weight_vec: float = 1.0
4646

47+
# Allow the sqlite-ai extension to use the GPU
48+
# See: https://github.com/sqliteai/sqlite-ai
49+
use_gpu = False
50+
4751

4852
class SettingsManager:
4953
def __init__(self, connection: sqlite3.Connection):

0 commit comments

Comments
 (0)