Skip to main content

parse_string_list

Function parse_string_list 

Source
pub fn parse_string_list(response: &str) -> Result<Vec<String>, ParseError>
Expand description

Parse an LLM response into a cleaned list of strings.

Cleaning: lowercase, trim, deduplicate, filter empties, filter >50 chars. This is the direct successor to ollama-vision’s parse_tags.

Strategies (in order):

  1. Direct JSON array
  2. JSON object with common list keys (“tags”, “items”, “results”, “list”)
  3. Markdown code block -> JSON array/object
  4. Bracket-matched JSON array
  5. JSON repair on best candidate
  6. Numbered/bulleted list extraction
  7. Comma-separated fallback