Новый раг
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.modules.rag.contracts import RagDocument, RagLayer, RagSource, RagSpan
|
||||
from app.modules.rag.indexing.code.code_text.chunker import CodeChunk
|
||||
|
||||
|
||||
class CodeTextDocumentBuilder:
|
||||
def build(self, source: RagSource, chunk: CodeChunk, *, chunk_index: int) -> RagDocument:
|
||||
return RagDocument(
|
||||
layer=RagLayer.CODE_SOURCE_CHUNKS,
|
||||
lang="python",
|
||||
source=source,
|
||||
title=chunk.title,
|
||||
text=chunk.text,
|
||||
span=RagSpan(chunk.start_line, chunk.end_line),
|
||||
metadata={
|
||||
"chunk_index": chunk_index,
|
||||
"chunk_type": chunk.chunk_type,
|
||||
"module_or_unit": source.path.replace("/", ".").removesuffix(".py"),
|
||||
"artifact_type": "CODE",
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user