update requirements.txt and fix editor

This commit is contained in:
张建生 2025-02-24 19:48:16 +08:00
parent f3ced99c92
commit 70123a79d2
3 changed files with 13 additions and 4 deletions

View file

@ -165,3 +165,6 @@ EXPERIENCE_MASK = "<experience>"
# TeamLeader's name
TEAMLEADER_NAME = "Mike"
DEFAULT_MIN_TOKEN_COUNT = 10000
DEFAULT_MAX_TOKEN_COUNT = 100000000

View file

@ -13,8 +13,7 @@ from typing import List, Optional, Union
import tiktoken
from pydantic import BaseModel, ConfigDict
from metagpt.const import DEFAULT_WORKSPACE_ROOT
from metagpt.tools.libs.index_repo import DEFAULT_MIN_TOKEN_COUNT, IndexRepo
from metagpt.const import DEFAULT_MIN_TOKEN_COUNT, DEFAULT_WORKSPACE_ROOT
from metagpt.tools.libs.linter import Linter
from metagpt.tools.tool_registry import register_tool
from metagpt.utils.common import awrite
@ -1125,7 +1124,12 @@ class Editor(BaseModel):
>>> texts: List[str] = await Editor.similarity_search(query=query, path=file_or_path)
>>> print(texts)
"""
return await IndexRepo.cross_repo_search(query=query, file_or_path=path)
try:
from metagpt.tools.libs.index_repo import IndexRepo
return await IndexRepo.cross_repo_search(query=query, file_or_path=path)
except ImportError:
raise ImportError("To use the similarity search, you need to install the RAG module.")
@staticmethod
def is_large_file(content: str, mix_token_count: int = 0) -> bool:

View file

@ -75,4 +75,6 @@ pygithub~=2.3
htmlmin
fsspec
grep-ast~=0.3.3 # linter
tree-sitter~=0.21.3 # linter
tree-sitter~=0.21.3 # linter
unidiff==0.7.5 # used at metagpt/tools/libs/cr.py
httpx==0.27.2