LMS.ExtractCleanAnswer - Extract Clean Answer

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > LMS. - LM-Studio Commands > NEW: LMS v2.1 Commands - Model Query, Status, and Text Extraction >

LMS.ExtractCleanAnswer - Extract Clean Answer

Automatically extracts clean answer content from AI responses that may contain formatting, code blocks, or XML tags. Useful for getting pure content without markdown or other formatting.

Syntax:

LMS.ExtractCleanAnswer|$$SOURCE|$$PREF|$$RET_VAR

Parameters:

$$SOURCE (String, required) - Source text containing formatted response.

$$PREF (String, required) - Extraction preference: "auto", "code", or "xml".

$$RET_VAR (Variable, required) - Variable to receive clean answer.

Preference Options:

auto - Tries JSON code block, then any code block, then XML tagscode - Tries code blocks onlyxml - Tries XML tags only

Examples:

; Get AI response and extract clean answer

LMS.ask|"Give me a JSON object with name and age"|raw

LMS.ExtractCleanAnswer|raw|auto|clean

; 'clean' now contains just the JSON without markdown

See Also:

LMS.ExtractCodeBlockLMS.ExtractXmlTag