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

fix: be more flexible when interpreting codegate version #882

Merged
merged 2 commits into from
Feb 3, 2025
Merged
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
14 changes: 4 additions & 10 deletions src/codegate/pipeline/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,12 @@ def _get_cli_from_cline(


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

if user_blocks:
# Extract the last "### User:" block
last_user_block = user_blocks[-1].strip()

# Match "codegate" only in the last "### User:" block
codegate_regex = re.compile(r"^codegate\s*(.*?)\s*$", re.IGNORECASE)
match = codegate_regex.match(last_user_block)
return match
return None
# Match "codegate" only in the last user block or entire input
return re.match(r"^codegate\s*(.*?)\s*$", last_user_block, re.IGNORECASE)


class CodegateCli(PipelineStep):
Expand Down