Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

fix: lowercase the packages found in snippets #260

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/codegate/pipeline/extract_snippets/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ async def _snippet_comment(self, snippet: CodeSnippet, secrets: PipelineSensitiv
api_key=secrets.api_key,
base_url=secrets.api_base,
)

# Check if any of the snippet libraries is a bad package
storage_engine = StorageEngine()
libobjects = await storage_engine.search_by_property("name", snippet.libraries)
Expand Down Expand Up @@ -88,7 +87,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, ""

Expand Down
3 changes: 2 additions & 1 deletion src/codegate/storage/storage_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading