Новый раг

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
@@ -0,0 +1,34 @@
from __future__ import annotations
from hashlib import sha256
from app.modules.rag.indexing.code.entrypoints.registry import Entrypoint
class FastApiEntrypointDetector:
_METHODS = {"get", "post", "put", "patch", "delete"}
def detect(self, *, path: str, symbols: list) -> list[Entrypoint]:
items: list[Entrypoint] = []
for symbol in symbols:
decorators = symbol.decorators or []
for decorator in decorators:
name = decorator.lower()
tail = name.split(".")[-1]
if tail not in self._METHODS and ".route" not in name:
continue
route = decorator.split("(")[-1].rstrip(")") if "(" in decorator else decorator
items.append(
Entrypoint(
entry_id=sha256(f"{path}|fastapi|{symbol.symbol_id}|{decorator}".encode("utf-8")).hexdigest(),
entry_type="http",
framework="fastapi",
route_or_command=route,
handler_symbol_id=symbol.symbol_id,
path=path,
start_line=symbol.start_line,
end_line=symbol.end_line,
metadata={"methods": [tail.upper()] if tail in self._METHODS else []},
)
)
return items