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

Commit 8c0915f

Browse files
committed
fix message extraaction
1 parent cb93717 commit 8c0915f

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/codegate/pipeline/codegate_context_retriever/codegate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def generate_context_str(self, objects: list[object], context: PipelineContext)
3636
matched_packages = []
3737
for obj in objects:
3838
# The object is already a dictionary with 'properties'
39-
package_obj = obj["properties"]
39+
package_obj = obj["properties"] # type: ignore
4040
matched_packages.append(f"{package_obj['name']} ({package_obj['type']})")
4141
# Add one alert for each package found
4242
context.add_alert(
@@ -97,7 +97,7 @@ async def process(
9797
user_messages = re.sub(r"⋮...*?⋮...\n\n", "", user_messages, flags=re.DOTALL)
9898

9999
# split messages into double newlines, to avoid passing so many content in the search
100-
split_messages = user_messages.split("\n\n")
100+
split_messages = re.split(r'</?task>|(\n\n)', user_messages)
101101
collected_bad_packages = []
102102
for item_message in split_messages:
103103
# Vector search to find bad packages

src/codegate/pipeline/extract_snippets/extract_snippets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def extract_snippets(message: str) -> List[CodeSnippet]:
125125

126126
#  just correct the typescript exception
127127
lang_map = {"typescript": "javascript"}
128-
lang = lang_map.get(lang, lang)
128+
if lang:
129+
lang = lang_map.get(lang, lang)
129130
snippets.append(CodeSnippet(filepath=filename, code=content, language=lang))
130131

131132
return snippets

src/codegate/storage/storage_engine.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import re
33
import sqlite3
4-
from typing import List
4+
from typing import List, Optional
55

66
import numpy as np
77
import sqlite_vec_sl_tmp
@@ -51,9 +51,13 @@ def __init__(self, data_path="./sqlite_data"):
5151
)
5252

5353
self.inference_engine = LlamaCppInferenceEngine()
54-
self.model_path = (
55-
f"{Config.get_config().model_base_path}/{Config.get_config().embedding_model}"
56-
)
54+
conf = Config.get_config()
55+
if conf and conf.model_base_path and conf.embedding_model:
56+
self.model_path = (
57+
f"{conf.model_base_path}/{conf.embedding_model}"
58+
)
59+
else:
60+
self.model_path = ""
5761

5862
self.conn = self._get_connection()
5963
self._setup_schema()
@@ -131,10 +135,10 @@ async def search_by_property(self, name: str, properties: List[str]) -> list[dic
131135

132136
async def search(
133137
self,
134-
query: str = None,
135-
language: str = None,
136-
ecosystem: str = None,
137-
packages: List[str] = None,
138+
query: Optional[str] = None,
139+
language: Optional[str] = None,
140+
ecosystem: Optional[str] = None,
141+
packages: Optional[List[str]] = None,
138142
limit: int = 50,
139143
distance: float = 0.3,
140144
) -> list[object]:

0 commit comments

Comments
 (0)