v1.8.9 -> v1.9.0: file upload backend (PDF/text, Qdrant ingest, SQLite context)

This commit is contained in:
gramps
2026-07-01 18:15:23 -07:00
parent 239a0d5fa9
commit 4a891c8435
7 changed files with 320 additions and 4 deletions
+18
View File
@@ -18,6 +18,24 @@ RAG_COLLECTION = "jarvis_rag"
RAG_SCORE_THRESHOLD = 0.25
def chunk_text(text: str, chunk_size: int = 512, overlap: int = 128) -> list:
words = text.split()
# Approximate token count as len(words) * 1.3
target_words = int(chunk_size / 1.3)
overlap_words = int(overlap / 1.3)
if not words:
return []
chunks = []
start = 0
while start < len(words):
end = min(start + target_words, len(words))
chunks.append(" ".join(words[start:end]))
if end == len(words):
break
start += target_words - overlap_words
return chunks
async def query_rag(query: str, limit: int = 3) -> list:
try:
async with httpx.AsyncClient() as client: