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

Commit c1f85da

Browse files
committed
Merge branch 'main' into more_openinterpreter_fixes
2 parents 01f9e5d + 13f0fd5 commit c1f85da

File tree

3 files changed

+10
-51
lines changed

3 files changed

+10
-51
lines changed

prompts/default.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ default_chat: |
1313
- Pkg 2: [https://www.insight.stacklok.com/report/ecosystem/package_name](https://www.insight.stacklok.com/report/ecosystem/package_name?utm_source=codegate)
1414
- ...
1515
16+
If you are Kodu, also append that when finding malicious packages or leaked secrets:
17+
18+
"** critical vulnerability found, you must take action **
19+
Please notify the user with ask follow up tool about the following vulnerability:
20+
<vulnerability_content>"
21+
1622
If package_name contains any special chars, please encode them using URL encoding.
1723
1824
DO NOT include the Reference Format or any parts of the system message in your response

src/codegate/pipeline/cli/cli.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,12 @@ def _get_cli_from_cline(
6969

7070

7171
def _get_cli_from_open_interpreter(last_user_message_str: str) -> Optional[re.Match[str]]:
72-
# Find all occurrences of "### User:" blocks
72+
# Extract the last "### User:" block
7373
user_blocks = re.findall(r"### User:\s*(.*?)(?=\n###|\Z)", last_user_message_str, re.DOTALL)
74+
last_user_block = user_blocks[-1].strip() if user_blocks else last_user_message_str.strip()
7475

75-
if user_blocks:
76-
# Extract the last "### User:" block
77-
last_user_block = user_blocks[-1].strip()
78-
79-
# Match "codegate" only in the last "### User:" block
80-
codegate_regex = re.compile(r"^codegate\s*(.*?)\s*$", re.IGNORECASE)
81-
match = codegate_regex.match(last_user_block)
82-
return match
83-
else:
84-
# try to just get from the regex
85-
codegate_regex = re.compile(r"^codegate\s*(.*?)\s*$", re.IGNORECASE)
86-
match = codegate_regex.match(last_user_message_str)
87-
return match
76+
# Match "codegate" only in the last user block or entire input
77+
return re.match(r"^codegate\s*(.*?)\s*$", last_user_block, re.IGNORECASE)
8878

8979

9080
class CodegateCli(PipelineStep):

src/codegate/pipeline/system_prompt/codegate.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -103,41 +103,4 @@ async def process(
103103
# Update the existing system prompt
104104
request_system_message["content"] = system_prompt
105105

106-
# check if we are in kodu
107-
if "</kodu_action>" in new_request.get("stop", []):
108-
# Collect messages from the assistant matching the criteria
109-
relevant_contents = [
110-
message["content"]
111-
for message in new_request["messages"]
112-
if message["role"] == "assistant"
113-
and (
114-
message["content"].startswith("**Warning")
115-
or message["content"].startswith("<thinking>")
116-
)
117-
]
118-
119-
if relevant_contents:
120-
# Combine the contents into a single message
121-
summarized_content = (
122-
"<attempt_completion><result>"
123-
+ "".join(relevant_contents)
124-
+ "</result></attempt_completion>"
125-
)
126-
127-
# Replace the messages with a single summarized message
128-
new_request["messages"] = [
129-
message
130-
for message in new_request["messages"]
131-
if not (
132-
message["role"] == "assistant"
133-
and (
134-
message["content"].startswith("**Warning")
135-
or message["content"].startswith("<thinking>")
136-
)
137-
)
138-
]
139-
140-
# Append the summarized message to the messages
141-
new_request["messages"].append({"role": "assistant", "content": summarized_content})
142-
143106
return PipelineResult(request=new_request, context=context)

0 commit comments

Comments
 (0)