mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
Accept no 'reasoning' response in qa evaluator (#7107)
Re add since #6995 inadvertently undid #7031
This commit is contained in:
parent
fd3f8efec7
commit
3f9744c9f4
@ -19,14 +19,20 @@ def _parse_string_eval_output(text: str) -> dict:
|
||||
Returns:
|
||||
Any: The parsed output.
|
||||
"""
|
||||
reasoning, verdict = text.strip().rsplit("\n", maxsplit=1)
|
||||
splits = text.strip().rsplit("\n", maxsplit=1)
|
||||
if len(splits) == 1:
|
||||
verdict = splits[0]
|
||||
reasoning = None
|
||||
else:
|
||||
reasoning, verdict = splits
|
||||
reasoning = reasoning.strip()
|
||||
score = (
|
||||
1
|
||||
if verdict.upper() == "CORRECT"
|
||||
else (0 if verdict.upper() == "INCORRECT" else None)
|
||||
)
|
||||
return {
|
||||
"reasoning": reasoning.strip(),
|
||||
"reasoning": reasoning,
|
||||
"value": verdict,
|
||||
"score": score,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user