Prefer fuller Ollama analysis text
This commit is contained in:
@@ -458,12 +458,23 @@ def _extract_ollama_generated_text(resp_json: dict) -> str:
|
|||||||
message.get("thinking"),
|
message.get("thinking"),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
cleaned_candidates = []
|
||||||
for candidate in candidates:
|
for candidate in candidates:
|
||||||
if isinstance(candidate, str):
|
if isinstance(candidate, str):
|
||||||
text = candidate.strip()
|
text = candidate.strip()
|
||||||
|
if "<think>" in text:
|
||||||
|
text = text.split("</think>")[-1].strip()
|
||||||
if text:
|
if text:
|
||||||
return text
|
cleaned_candidates.append(text)
|
||||||
return ""
|
|
||||||
|
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:
|
def _analysis_text_is_usable(text: str) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user