Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: value error in BooleanOutputParser #5396

Closed
ARSblithe212 opened this issue May 29, 2023 · 1 comment
Closed

Issue: value error in BooleanOutputParser #5396

ARSblithe212 opened this issue May 29, 2023 · 1 comment

Comments

@ARSblithe212
Copy link
Contributor

Issue you'd like to raise.

when use the BooleanOutputParser in the chain_filter.py, the LLMs output 'yes|no',the function 'parse' will throw ValueError。

Suggestion:

I fix it,as follows:

def parse(self, text: str) -> bool:
"""Parse the output of an LLM call to a boolean.

    Args:
        text: output of language model

    Returns:
        boolean

    """
    cleaned_text = text.upper().strip()
    if cleaned_text not in (self.true_val, self.false_val):
        raise ValueError(
            f"BooleanOutputParser expected output value to either be "
            f"{self.true_val} or {self.false_val}. Received {cleaned_text}."
        )
    return cleaned_text == self.true_val
dev2049 pushed a commit that referenced this issue May 30, 2023
…the class BooleanOutputParser (#5397)

when the LLMs output 'yes|no',BooleanOutputParser can parse it to
'True|False', fix the ValueError in parse().
<!--
when use the BooleanOutputParser in the chain_filter.py, the LLMs output
'yes|no',the function 'parse' will throw ValueError。
-->

Fixes # (issue)
  #5396
  #5396

---------

Co-authored-by: gaofeng27692 <gaofeng27692@hundsun.com>
vowelparrot pushed a commit that referenced this issue May 31, 2023
…the class BooleanOutputParser (#5397)

when the LLMs output 'yes|no',BooleanOutputParser can parse it to
'True|False', fix the ValueError in parse().
<!--
when use the BooleanOutputParser in the chain_filter.py, the LLMs output
'yes|no',the function 'parse' will throw ValueError。
-->

Fixes # (issue)
  #5396
  #5396

---------

Co-authored-by: gaofeng27692 <gaofeng27692@hundsun.com>
Undertone0809 pushed a commit to Undertone0809/langchain that referenced this issue Jun 19, 2023
…the class BooleanOutputParser (langchain-ai#5397)

when the LLMs output 'yes|no',BooleanOutputParser can parse it to
'True|False', fix the ValueError in parse().
<!--
when use the BooleanOutputParser in the chain_filter.py, the LLMs output
'yes|no',the function 'parse' will throw ValueError。
-->

Fixes # (issue)
  langchain-ai#5396
  langchain-ai#5396

---------

Co-authored-by: gaofeng27692 <gaofeng27692@hundsun.com>
@dosubot
Copy link

dosubot bot commented Aug 30, 2023

Hi, @ARSblithe212! I'm Dosu, and I'm here to help the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you reported an issue regarding the BooleanOutputParser in chain_filter.py. It seems that when the LLMs output 'yes|no', a ValueError is thrown. The suggested fix is to modify the 'parse' function to check if the cleaned text is either the true value or the false value, and raise a ValueError if it is not.

Since there hasn't been any activity on this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the LangChain project!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Aug 30, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant