Новый раг

This commit is contained in:
2026-03-01 14:21:33 +03:00
parent 2728c07ba9
commit 1ef0b4d68c
95 changed files with 3145 additions and 927 deletions

View File

@@ -0,0 +1,32 @@
from __future__ import annotations
from app.modules.rag.contracts import RagDocument, RagLayer, RagSource, RagSpan
from app.modules.rag.indexing.code.symbols.extractor import PySymbol
class SymbolDocumentBuilder:
def build(self, source: RagSource, symbol: PySymbol) -> RagDocument:
body = [f"{symbol.kind} {symbol.qname}", symbol.signature]
if symbol.docstring:
body.append(symbol.docstring.strip())
return RagDocument(
layer=RagLayer.CODE_SYMBOL_CATALOG,
lang="python",
source=source,
title=symbol.qname,
text="\n".join(part for part in body if part),
span=RagSpan(symbol.start_line, symbol.end_line),
metadata={
"symbol_id": symbol.symbol_id,
"qname": symbol.qname,
"kind": symbol.kind,
"signature": symbol.signature,
"decorators_or_annotations": symbol.decorators,
"docstring_or_javadoc": symbol.docstring,
"parent_symbol_id": symbol.parent_symbol_id,
"package_or_module": source.path.replace("/", ".").removesuffix(".py"),
"is_entry_candidate": bool(symbol.decorators),
"lang_payload": symbol.lang_payload,
"artifact_type": "CODE",
},
)