code_utils
autogen.code_utils.extract_code
extract_code
Extract code from a text.
Parameters:Name | Description |
---|---|
text | The content to extract code from. The content can be a string or a list, as returned by standard GPT or multimodal GPT. Type: str | list |
pattern | The regular expression pattern for finding the code block. Defaults to CODE_BLOCK_PATTERN. Type: str Default: ‘ [ \\t]*(\\w+)?[ \\t]*\\r?\\n(.*?)\\r?\\n[ \\t]* ’ |
detect_single_line_code | Enable the new feature for extracting single line code. Defaults to False. Type: bool Default: False |
Type | Description |
---|---|
list[tuple[str, str]] | list: A list of tuples, each containing the language and the code. If there is no code block in the input text, the language would be “unknown”. If there is code block but the language is not specified, the language would be "". |