diff --git a/ltx_director.py b/ltx_director.py index 8044128..1f89b8d 100644 --- a/ltx_director.py +++ b/ltx_director.py @@ -458,12 +458,23 @@ def _extract_ollama_generated_text(resp_json: dict) -> str: message.get("thinking"), ]) + cleaned_candidates = [] for candidate in candidates: if isinstance(candidate, str): text = candidate.strip() + if "" in text: + text = text.split("")[-1].strip() if text: - return text - return "" + cleaned_candidates.append(text) + + if not cleaned_candidates: + return "" + + usable = [text for text in cleaned_candidates if _analysis_text_is_usable(text)] + if usable: + return max(usable, key=len) + + return max(cleaned_candidates, key=len) def _analysis_text_is_usable(text: str) -> bool: