INNER CODE UNIT · Python
last_user_block
stacklok/codegate · src/codegate/pipeline/cli/cli.py:75
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,
)
if deepseek_match:
command = deepseek_match.group(1).strip()
return re.match(r"^(.*?)$", command) # This creates a match object with the command