Skip to content

Commit f90af0d

Browse files
author
Daniele Briggi
committed
feat(context): new option
1 parent 80fd54d commit f90af0d

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/sqlite_rag/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Settings:
1818
model_options: str = ""
1919
# See: https://github.com/sqliteai/sqlite-ai/blob/main/API.md#llm_context_createoptions-text
2020
model_context_options: str = (
21-
"generate_embedding=1,normalize_embedding=1,pooling_type=mean"
21+
"generate_embedding=1,normalize_embedding=1,pooling_type=mean,embedding_type=FLOAT16"
2222
)
2323

2424
vector_type: str = "FLOAT16"

src/sqlite_rag/sqliterag.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,16 @@ def add(
7373
self._engine.create_new_context()
7474

7575
processed = 0
76-
self._logger.info(f"Processing {len(files_to_process)} files...")
76+
total_to_process = len(files_to_process)
77+
self._logger.info(f"Processing {total_to_process} files...")
7778
try:
78-
for file_path in files_to_process:
79+
for i, file_path in enumerate(files_to_process):
7980
content = FileReader.parse_file(file_path)
8081

8182
if not content:
82-
self._logger.warning(f"Skipping empty file: {file_path}")
83+
self._logger.warning(
84+
f"{i+1}/{total_to_process} Skipping empty file: {file_path}"
85+
)
8386
continue
8487

8588
uri = (
@@ -91,10 +94,12 @@ def add(
9194

9295
exists = self._repository.document_exists_by_hash(document.hash())
9396
if exists:
94-
self._logger.info(f"Unchanged: {file_path}")
97+
self._logger.info(
98+
f"{i+1}/{total_to_process} Unchanged: {file_path}"
99+
)
95100
continue
96101

97-
self._logger.info(f"Processing: {file_path}")
102+
self._logger.info(f"{i+1}/{total_to_process} Processing: {file_path}")
98103
document = self._engine.process(document)
99104

100105
self._repository.add_document(document)

tests/test_engine.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pytest
2-
31
from sqlite_rag.chunker import Chunker
42
from sqlite_rag.engine import Engine
53
from sqlite_rag.models.chunk import Chunk
@@ -22,13 +20,13 @@ def test_search_with_empty_database(self, engine):
2220

2321
assert len(results) == 0
2422

25-
@pytest.mark.skip(reason="Waiting for sqlite-ai context to be fixed")
2623
def test_search_with_semantic_and_fts(self, db_conn):
2724
# Arrange
2825
conn, settings = db_conn
2926

3027
engine = Engine(conn, settings, Chunker(conn, settings))
3128
engine.load_model()
29+
engine.create_new_context()
3230

3331
doc1 = Document(
3432
content="The quick brown fox jumps over the lazy dog.",
@@ -60,13 +58,13 @@ def test_search_with_semantic_and_fts(self, db_conn):
6058
assert len(results) > 0
6159
assert doc3_id == results[0].document.id
6260

63-
@pytest.mark.skip(reason="Waiting for sqlite-ai context to be fixed")
6461
def test_search_semantic_result(self, db_conn):
6562
# Arrange
6663
conn, settings = db_conn
6764

6865
engine = Engine(conn, settings, Chunker(conn, settings))
6966
engine.load_model()
67+
engine.create_new_context()
7068

7169
doc1 = Document(
7270
content="The quick brown fox jumps over the lazy dog.",

0 commit comments

Comments
 (0)