From e0453001fcb5f95d16996abfa6219d77d2dd9923 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Tue, 10 Dec 2024 18:36:59 +0000 Subject: [PATCH 1/3] fix: lowercase the packages found in snippets Similar issue with anthropic, interpreting the invokehttp with mixed case --- src/codegate/pipeline/extract_snippets/output.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/codegate/pipeline/extract_snippets/output.py b/src/codegate/pipeline/extract_snippets/output.py index 0a351a8b..a1181199 100644 --- a/src/codegate/pipeline/extract_snippets/output.py +++ b/src/codegate/pipeline/extract_snippets/output.py @@ -49,6 +49,10 @@ async def _snippet_comment(self, snippet: CodeSnippet, secrets: PipelineSensitiv base_url=secrets.api_base, ) + # lower the snippet libraries found + if snippet.libraries and isinstance(snippet.libraries, list): + snippet.libraries = [lib.lower() for lib in snippet.libraries] + # Check if any of the snippet libraries is a bad package storage_engine = StorageEngine() libobjects = await storage_engine.search_by_property("name", snippet.libraries) @@ -88,7 +92,7 @@ def _split_chunk_at_code_end(self, content: str) -> tuple[str, str]: if line.strip() == "```": # Return content up to and including ```, and the rest before = "\n".join(lines[: i + 1]) - after = "\n".join(lines[i + 1 :]) + after = "\n".join(lines[i + 1:]) return before, after return content, "" From 738a42501709af0c0cc8db81178343ef5009df02 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Tue, 10 Dec 2024 20:36:48 +0000 Subject: [PATCH 2/3] fix filtered objects Closes: #262 --- src/codegate/storage/storage_engine.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/codegate/storage/storage_engine.py b/src/codegate/storage/storage_engine.py index 7328cf86..ed26c268 100644 --- a/src/codegate/storage/storage_engine.py +++ b/src/codegate/storage/storage_engine.py @@ -130,9 +130,10 @@ async def search_by_property(self, name: str, properties: List[str]) -> list[obj # Weaviate performs substring matching of the properties. So # we need to double check the response. + properties = [prop.lower() for prop in properties] filterd_objects = [] for object in response.objects: - if object["properties"][name] in properties: + if object.properties[name].lower() in properties: filterd_objects.append(object) response.objects = filterd_objects From cc856c06e054a66ae49267e62efe4012df1af1dd Mon Sep 17 00:00:00 2001 From: Yolanda Robla Mota Date: Tue, 10 Dec 2024 21:44:55 +0100 Subject: [PATCH 3/3] Update output.py --- src/codegate/pipeline/extract_snippets/output.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/codegate/pipeline/extract_snippets/output.py b/src/codegate/pipeline/extract_snippets/output.py index a1181199..a9b67db8 100644 --- a/src/codegate/pipeline/extract_snippets/output.py +++ b/src/codegate/pipeline/extract_snippets/output.py @@ -48,11 +48,6 @@ async def _snippet_comment(self, snippet: CodeSnippet, secrets: PipelineSensitiv api_key=secrets.api_key, base_url=secrets.api_base, ) - - # lower the snippet libraries found - if snippet.libraries and isinstance(snippet.libraries, list): - snippet.libraries = [lib.lower() for lib in snippet.libraries] - # Check if any of the snippet libraries is a bad package storage_engine = StorageEngine() libobjects = await storage_engine.search_by_property("name", snippet.libraries)