🐛 fix meilisearch restart and other bugs
This commit is contained in:
parent
1d4c0b157b
commit
e0943632bb
5 changed files with 32 additions and 18 deletions
|
|
@ -432,6 +432,9 @@ class ContextManager:
|
|||
logger.warning(
|
||||
"Meilisearch did not restart in less than 20 seconds. Stopping polling."
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"Error restarting meilisearch: {e}")
|
||||
|
||||
await self.load_index(workspace_dir, False)
|
||||
|
||||
async def get_context_item(self, id: str, query: str) -> Optional[ContextItem]:
|
||||
|
|
|
|||
|
|
@ -70,12 +70,17 @@ class ContinueSDK(AbstractContinueSDK):
|
|||
ide: AbstractIdeProtocolServer,
|
||||
gui: AbstractGUIProtocolServer,
|
||||
autopilot: Autopilot,
|
||||
models: Models,
|
||||
):
|
||||
self.ide = ide
|
||||
self.gui = gui
|
||||
self.config = config
|
||||
self.models = models
|
||||
self.models = config.construct_models()
|
||||
self.models.start(
|
||||
self.ide.window_info.unique_id,
|
||||
self.config.system_message,
|
||||
self.config.completion_options.temperature,
|
||||
self.config.llm_request_hook,
|
||||
)
|
||||
self.__autopilot = autopilot
|
||||
|
||||
@property
|
||||
|
|
@ -242,10 +247,7 @@ class ContinueSDK(AbstractContinueSDK):
|
|||
role = "user"
|
||||
msgs.extend(
|
||||
await self.__autopilot.context_manager.get_chat_messages(
|
||||
[
|
||||
ContextItem(**itm)
|
||||
for itm in step.params.get("context_items", [])
|
||||
]
|
||||
[ContextItem(**itm) for itm in step.params["context_items"]]
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ loading config.json, and will return the final ContinueConfig to be used.
|
|||
from continuedev.core.config import ContinueConfig
|
||||
|
||||
def modify_config(config: ContinueConfig) -> ContinueConfig:
|
||||
config.completion_options.temperature = 0.5
|
||||
# config.completion_options.temperature = 0.5
|
||||
return config
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -80,9 +80,12 @@ class MeilisearchCodebaseIndex(CodebaseIndex):
|
|||
)
|
||||
|
||||
async def delete_chunks(self, document_ids: List[str], index: Index):
|
||||
documents = await index.get_documents(
|
||||
filter=f'document_id IN [{",".join(document_ids)}]'
|
||||
)
|
||||
documents = (
|
||||
await index.get_documents(
|
||||
filter=f'document_id IN [{",".join(document_ids)}]'
|
||||
)
|
||||
).results
|
||||
|
||||
ids = [document["id"] for document in documents]
|
||||
await index.delete_documents(ids)
|
||||
|
||||
|
|
@ -91,14 +94,14 @@ class MeilisearchCodebaseIndex(CodebaseIndex):
|
|||
return await index.get_documents(filter=f'document_id="{digest}"')
|
||||
|
||||
async def remove_label(self, digest: str, label: str, index: Index):
|
||||
documents = await self.get_docs_for_digest(digest, index)
|
||||
documents = (await self.get_docs_for_digest(digest, index)).results
|
||||
for document in documents:
|
||||
document["tags"].remove(label)
|
||||
|
||||
await index.update_documents(documents)
|
||||
|
||||
async def add_label(self, digest: str, label: str, index: Index):
|
||||
documents = await self.get_docs_for_digest(digest, index)
|
||||
documents = (await self.get_docs_for_digest(digest, index)).results
|
||||
for document in documents:
|
||||
document["tags"].append(label)
|
||||
|
||||
|
|
|
|||
|
|
@ -165,22 +165,24 @@ async def start_meilisearch(url: Optional[str] = None):
|
|||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.STDOUT,
|
||||
close_fds=True,
|
||||
start_new_session=True,
|
||||
# start_new_session=True,
|
||||
shell=True,
|
||||
)
|
||||
|
||||
logger.info(f"Meilisearch started at {meilisearch_url}")
|
||||
logger.info(f"Meilisearch started at {meilisearch_url}")
|
||||
|
||||
|
||||
def stop_meilisearch():
|
||||
def stop_meilisearch() -> bool:
|
||||
"""
|
||||
Stops the MeiliSearch server.
|
||||
If we have the meilisearch process in memory, stop it. Return whether we had it.
|
||||
"""
|
||||
global meilisearch_process
|
||||
if meilisearch_process is not None:
|
||||
meilisearch_process.terminate()
|
||||
meilisearch_process.wait()
|
||||
meilisearch_process = None
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def kill_proc(port):
|
||||
|
|
@ -201,8 +203,12 @@ def kill_proc(port):
|
|||
|
||||
|
||||
async def restart_meilisearch():
|
||||
stop_meilisearch()
|
||||
kill_proc(7700)
|
||||
if not stop_meilisearch():
|
||||
# This actually shouldn't happen because Meilisearch gets stopped when the server is stopped
|
||||
logger.warning(
|
||||
"Meilisearch was started by previous Continue server, but not stopped"
|
||||
)
|
||||
kill_proc(7700)
|
||||
await start_meilisearch(url=global_config.meilisearch_url)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue