added scaffold struct for the prj

This commit is contained in:
2026-03-24 14:58:58 +01:00
parent 95655686f9
commit cbfcf1e315
26 changed files with 6655 additions and 312 deletions

View File

@@ -0,0 +1,23 @@
from txtai.embeddings import Embeddings
def create_and_index(
data: list[str], model: str = "sentence-transformers/all-MiniLM-L6-v2"
) -> Embeddings:
"""Create and index embeddings from text."""
embeddings = Embeddings({
"path": model,
"content": True,
"hybrid": True,
"scoring": "bm25",
})
embeddings.index(data)
return embeddings
def query_embedding(
embeddings: Embeddings, query: str, limit: int = 100
) -> list[str]:
"""Search embeddings and return matching texts."""
results = embeddings.search(query, limit)
return [r["text"] for r in results]