export def main [--authority:string] { let input = $in let host = $env.FLAIR_AUTHORITY $input | each {|text| http post -t application/json $"($host)/tags?limit=1" { text: $"($text)." } } | flatten | get tokens } export def batch [file_to_text_fn] { each {|ocr_path| print $"flair processing of ($ocr_path | path basename)" {filename: $ocr_path} | insert flair (($ocr_path | do $file_to_text_fn) | main --authority $env.FLAIR_AUTHORITY) } }