"""Score publisher-protocol content without treating truncated thoughts as answers.""" def normalize_content(raw, finish_reason): raw=(raw or '').lstrip() # llama.cpp content-only mode echoes the template's generation prefix. # It is protocol framing, not part of the answer (notably for MC letters). if raw.startswith(''): raw=raw[len(''):].lstrip('\r\n') if '' in raw: reasoning,_,content=raw.rpartition('') return content,reasoning.removeprefix('').strip(),'explicit-close' if finish_reason=='length': return '',raw,'unclosed-length-limit' # Publisher serves without a reasoning parser: completed direct answers # without a closing tag are content. Never infer an answer from hidden fields. return raw,'','publisher-direct-content'