Skip to content

Commit

Permalink
Always load indicies from dir
Browse files Browse the repository at this point in the history
  • Loading branch information
aorwall committed Jul 31, 2024
1 parent 25759b5 commit 7e6bd35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
1 change: 1 addition & 0 deletions moatless/find/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ def messages(self) -> list[Message]:
content = f"<issue>\n{self.loop.trajectory.initial_message}\n</issue>"

if self.provide_initial_context:
logger.info("Search for initial context to provide in the prompt")
result = self.workspace.code_index.semantic_search(
query=self.loop.trajectory.initial_message,
exact_match_if_possible=False,
Expand Down
22 changes: 6 additions & 16 deletions moatless/index/code_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def __init__(
self._vector_store = vector_store or default_vector_store(self._settings)
self._docstore = docstore or SimpleDocumentStore()

logger.info(f"Initiated CodeIndex {self._index_name} with:\n"
f" * {len(self._blocks_by_class_name)} classes\n"
f" * {len(self._blocks_by_function_name)} functions\n"
f" * {len(self._docstore.docs)} vectors\n")

@classmethod
def from_persist_dir(cls, persist_dir: str, file_repo: FileRepository, **kwargs):
vector_store = SimpleFaissVectorStore.from_persist_dir(persist_dir)
Expand Down Expand Up @@ -135,22 +140,7 @@ def from_url(cls, url: str, persist_dir: str, file_repo: FileRepository):
raise e

logger.info(f"Downloaded existing index from {url}.")

vector_store = SimpleFaissVectorStore.from_persist_dir(persist_dir)
docstore = SimpleDocumentStore.from_persist_dir(persist_dir)

if not os.path.exists(os.path.join(persist_dir, "settings.json")):
# TODO: Remove this when new indexes are uploaded
settings = IndexSettings(embed_model="voyage-code-2")
else:
settings = IndexSettings.from_persist_dir(persist_dir)

return cls(
file_repo=file_repo,
vector_store=vector_store,
docstore=docstore,
settings=settings,
)
return cls.from_persist_dir(persist_dir, file_repo)

@classmethod
def from_index_name(
Expand Down

0 comments on commit 7e6bd35

Please sign in to comment.