From 779aa419078b50d57928b24b3e3b2b6799ff6a99 Mon Sep 17 00:00:00 2001 From: Gabriele Venturi Date: Wed, 16 Oct 2024 10:51:47 +0200 Subject: [PATCH] lint: fix lint --- pandasai/ee/vectorstores/milvus.py | 12 +++--------- pandasai/pipelines/chat/code_cleaning.py | 5 ++++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pandasai/ee/vectorstores/milvus.py b/pandasai/ee/vectorstores/milvus.py index 5ac435297..c93315eae 100644 --- a/pandasai/ee/vectorstores/milvus.py +++ b/pandasai/ee/vectorstores/milvus.py @@ -25,7 +25,7 @@ class Milvus(VectorStore): default=384, description="default embedding model dimension" ) - # Initializes the Milvus object with collection names, a URI for the Milvus database, + # Initializes the Milvus object with collection names, a URI for the Milvus database, # a logger, and the embedding function. def __init__( self, @@ -86,10 +86,7 @@ def add_question_answer( collection_name=self.qa_collection_name, data=data, ) - return milvus_ids - - # Adds documents to the Milvus collection. # It accepts documents, optional IDs, and metadata, and stores them in the document collection. @@ -124,7 +121,7 @@ def add_docs( collection_name=self.docs_collection_name, data=data, ) - + return milvus_ids # Retrieves the most relevant question-answer pairs from the QA collection @@ -146,7 +143,6 @@ def get_relevant_question_answers(self, question: str, k: int = 1) -> List[Dict] filter="", output_fields=[DOCUMENT], ) - return self._convert_search_response(response) # Retrieves the most relevant documents from the document collection @@ -166,7 +162,6 @@ def get_relevant_docs(self, question: str, k: int = 1) -> List[Dict]: limit=k, output_fields=[DOCUMENT], ) - return self._convert_search_response(response) # Converts the search response returned by Milvus into a list of dictionaries @@ -271,7 +266,6 @@ def get_relevant_question_answers_by_id(self, ids: Iterable[str]) -> List[Dict]: ids=milvus_ids, output_fields=[DOCUMENT, ID, "distance", "entity"], ) - return self._convert_search_response(response)["documents"] # Deletes documents from the document collection based on a list of document IDs. @@ -388,4 +382,4 @@ def _is_valid_uuid(self, id: str): # Generates a list of random UUIDs. def generate_random_uuids(self, n): - return [str(uuid.uuid4()) for _ in range(n)] \ No newline at end of file + return [str(uuid.uuid4()) for _ in range(n)] diff --git a/pandasai/pipelines/chat/code_cleaning.py b/pandasai/pipelines/chat/code_cleaning.py index 9ab3eedaa..3effcaed0 100644 --- a/pandasai/pipelines/chat/code_cleaning.py +++ b/pandasai/pipelines/chat/code_cleaning.py @@ -176,7 +176,10 @@ def _is_malicious_code(self, code) -> bool: "(chr", "b64decode", ] - return any(re.search(r'\b'+re.escape(module)+r'\b',code) for module in dangerous_modules) + return any( + re.search(r"\b" + re.escape(module) + r"\b", code) + for module in dangerous_modules + ) def _is_jailbreak(self, node: ast.stmt) -> bool: """