agentscope.parsers.code_block_parser¶
Model response parser class for Markdown code block.
- class MarkdownCodeBlockParser(language_name: str, content_hint: str | None = None)[source]¶
Bases:
ParserBase
The base class for parsing the response text by fenced block.
- parse(response: ModelResponse) ModelResponse [source]¶
Extract the content between the tag_begin and tag_end in the response and store it in the parsed field of the response object.
- content_hint: str = '${{your_{language_name}_code}}'¶
The hint of the content.
- format_instruction: str = 'You should generate {language_name} code in a {language_name} fenced code block as follows: \n```{language_name}\n{content_hint}\n```'¶
The instruction for the format of the code block.
- name: str = '{language_name} block'¶
The name of the parser.
- tag_begin: str = '```{language_name}'¶
The beginning tag.
- tag_end: str = '```'¶
The ending tag.