Spaces:
Sleeping
Sleeping
김민경 Cursor commited on
Commit ·
eb73b31
1
Parent(s): 13d9fdf
fix: init_vectordb crash due to empty ToolRegistry at build time
Browse filesToolRegistry.load_from_modules() was not called in init_vectordb.py,
causing get_all_tools() to return an empty tuple and ChromaDB upsert
to fail with ValueError on empty lists.
Co-authored-by: Cursor <cursoragent@cursor.com>
- app/tool_search/embedder.py +3 -0
- scripts/init_vectordb.py +4 -2
app/tool_search/embedder.py
CHANGED
|
@@ -92,6 +92,9 @@ class ToolEmbeddingSearch:
|
|
| 92 |
|
| 93 |
def index_tools(self, tools: list[BaseTool] | tuple[BaseTool, ...]) -> None:
|
| 94 |
"""LangChain 도구들을 ChromaDB에 멀티-벡터 임베딩. 변경 시에만 재인덱싱."""
|
|
|
|
|
|
|
|
|
|
| 95 |
new_hash = _compute_tools_hash(tools)
|
| 96 |
|
| 97 |
try:
|
|
|
|
| 92 |
|
| 93 |
def index_tools(self, tools: list[BaseTool] | tuple[BaseTool, ...]) -> None:
|
| 94 |
"""LangChain 도구들을 ChromaDB에 멀티-벡터 임베딩. 변경 시에만 재인덱싱."""
|
| 95 |
+
if not tools:
|
| 96 |
+
logger.warning("No tools to index, skipping")
|
| 97 |
+
return
|
| 98 |
new_hash = _compute_tools_hash(tools)
|
| 99 |
|
| 100 |
try:
|
scripts/init_vectordb.py
CHANGED
|
@@ -13,7 +13,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
| 13 |
|
| 14 |
from app.config import get_settings
|
| 15 |
from app.tool_search.embedder import get_tool_search
|
| 16 |
-
from app.tools import
|
| 17 |
from app.rag.retriever import ingest_pdf, ingest_text_file
|
| 18 |
|
| 19 |
# 파일명 패턴: B00329010_0_S.pdf
|
|
@@ -36,8 +36,10 @@ def main():
|
|
| 36 |
print(f"ChromaDB persist dir: {s.chromadb_persist_dir}")
|
| 37 |
|
| 38 |
print("\n[1/2] Tool 임베딩 색인 중...")
|
|
|
|
|
|
|
| 39 |
searcher = get_tool_search()
|
| 40 |
-
tools =
|
| 41 |
searcher.index_tools(tools)
|
| 42 |
print(f" {len(tools)}개 tool 색인 완료")
|
| 43 |
|
|
|
|
| 13 |
|
| 14 |
from app.config import get_settings
|
| 15 |
from app.tool_search.embedder import get_tool_search
|
| 16 |
+
from app.tools import get_tool_registry
|
| 17 |
from app.rag.retriever import ingest_pdf, ingest_text_file
|
| 18 |
|
| 19 |
# 파일명 패턴: B00329010_0_S.pdf
|
|
|
|
| 36 |
print(f"ChromaDB persist dir: {s.chromadb_persist_dir}")
|
| 37 |
|
| 38 |
print("\n[1/2] Tool 임베딩 색인 중...")
|
| 39 |
+
registry = get_tool_registry()
|
| 40 |
+
registry.load_from_modules()
|
| 41 |
searcher = get_tool_search()
|
| 42 |
+
tools = registry.get_all()
|
| 43 |
searcher.index_tools(tools)
|
| 44 |
print(f" {len(tools)}개 tool 색인 완료")
|
| 45 |
|