Skip to content

Commit 5b83f4e

Browse files
author
Daniele Briggi
committed
feat(title): limit length when autogenerated
1 parent 7348c58 commit 5b83f4e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/sqlite_rag/cli.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,11 @@ def configure_settings(
116116
model_path: Optional[str] = typer.Option(
117117
None, help="Path to the embedding model file (.gguf)"
118118
),
119-
model_config: Optional[str] = typer.Option(
120-
None, help="Model configuration parameters"
119+
model_options: Optional[str] = typer.Option(
120+
None, help="options specific for the model: See: https://github.com/sqliteai/sqlite-ai/blob/main/API.md#llm_model_loadpath-text-options-text"
121+
),
122+
model_context_options: Optional[str] = typer.Option(
123+
None, help="Options specific for model context creation. See: https://github.com/sqliteai/sqlite-ai/blob/main/API.md#llm_context_createcontext_settings-text"
121124
),
122125
embedding_dim: Optional[int] = typer.Option(
123126
None, help="Dimension of the embedding vectors"
@@ -182,7 +185,9 @@ def configure_settings(
182185
# Build updates dict from all provided parameters
183186
updates = {
184187
"model_path": model_path,
185-
"model_config": model_config,
188+
"model_options": model_options,
189+
"model_context_options": model_context_options,
190+
"use_gpu": use_gpu,
186191
"embedding_dim": embedding_dim,
187192
"vector_type": vector_type,
188193
"other_vector_options": other_vector_options,
@@ -192,7 +197,6 @@ def configure_settings(
192197
"quantize_preload": quantize_preload,
193198
"weight_fts": weight_fts,
194199
"weight_vec": weight_vec,
195-
"use_gpu": use_gpu,
196200
"use_prompt_templates": (
197201
False if no_prompt_templates else None
198202
), # Set only if True

src/sqlite_rag/engine.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class Engine:
1616
# Considered a good default to normilize the score for RRF
1717
DEFAULT_RRF_K = 60
1818

19+
GENERATED_TITLE_MAX_CHARS = 100
20+
1921
def __init__(self, conn: sqlite3.Connection, settings: Settings, chunker: Chunker):
2022
self._conn = conn
2123
self._settings = settings
@@ -239,7 +241,7 @@ def extract_document_title(
239241
for line in text.splitlines():
240242
line = line.strip()
241243
if line:
242-
return line
244+
return line[:self.GENERATED_TITLE_MAX_CHARS]
243245

244246
return None
245247

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,embedding_type=INT8"
21+
"generate_embedding=1,normalize_embedding=1,pooling_type=mean,n_ctx=768,embedding_type=INT8"
2222
)
2323

2424
# Allow the sqlite-ai extension to use the GPU

0 commit comments

Comments
 (0)