Prefer fuller Ollama analysis text
This commit is contained in:
@@ -458,13 +458,24 @@ 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 "<think>" in text:
|
||||
text = text.split("</think>")[-1].strip()
|
||||
if text:
|
||||
return text
|
||||
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:
|
||||
text = (text or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user