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

'StringIO' object has no attribute <some-attribute> #1831

Open
vesely-david opened this issue Jan 10, 2025 · 2 comments
Open

'StringIO' object has no attribute <some-attribute> #1831

vesely-david opened this issue Jan 10, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@vesely-david
Copy link

vesely-david commented Jan 10, 2025

Describe the bug

I believe there is a bug in RagasOutputParser when OutputParserException is raised.

While we try to generate new prompt, we forget to parse the output again..

Specificaly in

class RagasOutputParser(PydanticOutputParser[OutputModel]):
    async def parse_output_string(
        self,
        output_string: str,
        prompt_value: PromptValue,
        llm: BaseRagasLLM,
        callbacks: Callbacks,
        retries_left: int = 1,
    ):
        callbacks = callbacks or []
        try:
            jsonstr = extract_json(output_string)
            result = super().parse(jsonstr)
        except OutputParserException:
            if retries_left != 0:
                retry_rm, retry_cb = new_group(
                    name="fix_output_format",
                    inputs={"output_string": output_string},
                    callbacks=callbacks,
                )
                fixed_output_string = await fix_output_format_prompt.generate(
                    llm=llm,
                    data=OutputStringAndPrompt(
                        output_string=output_string,
                        prompt_value=prompt_value.to_string(),
                    ),
                    callbacks=retry_cb,
                    retries_left=retries_left - 1,
                )
                retry_rm.on_chain_end({"fixed_output_string": fixed_output_string})
                result = fixed_output_string
            else:
                raise RagasOutputParserException()
        return result

my chain of thoughts:

  • the OutputModel of fix_output_format_prompt is StringIO
    => fixed_output_string will be of type StringIO
    => given result = fixed_output_string, the result will be of type StringIO no matter of what the original OutputModel is

Ragas version: 0.2.10
Python version: 3.10.13


I believe this issue, may be related

@vesely-david vesely-david added the bug Something isn't working label Jan 10, 2025
@tim-hilde
Copy link

I encounter the same error on my end!

@andreped
Copy link
Contributor

Ugh. Encountering it myself right now. This worked fine a while back. I dont recall ever changing the ragas version, so it is likely coming from some hidden dependency, or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants