INNER CODE UNIT · Python
_get_cli_from_open_interpreter
stacklok/codegate · src/codegate/pipeline/cli/cli.py:72
def _get_cli_from_open_interpreter(last_user_message_str: str) -> Optional[re.Match[str]]:
# 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()
# Match "codegate" only in the last user block or entire input
return re.match(r"^codegate\s*(.*?)\s*$", last_user_block, re.IGNORECASE)
def _get_cli_from_continue(last_user_message_str: str) -> Optional[re.Match[str]]:
"""
Continue sends a differently formatted message to the CLI if DeepSeek is used
"""
deepseek_match = re.search(
r"utilizing the DeepSeek Coder model.*?### Instruction:\s*codegate\s+(.*?)\s*### Response:",
last_user_message_str,
re.DOTALL | re.IGNORECASE,
)