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

Bug: streaming process waiting problem #30

Closed
linkedlist771 opened this issue Apr 19, 2024 · 1 comment
Closed

Bug: streaming process waiting problem #30

linkedlist771 opened this issue Apr 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@linkedlist771
Copy link
Contributor

in the [claude.py](https://github.com/Amm1rr/WebAI-to-API/blob/master/src/claude.py) line 239:

    answer = ""
    with httpx.stream("POST", url, headers=headers, data=payload) as r:
      for text in r.iter_text():
        response_parse_text = await parse_text(text)

        text_res = ""
        if response_parse_text:
            for text in response_parse_text:
                text_res += text

        answer = ''.join(text_res)
        print(answer)
    
        yield answer

I was testing the streaming output results and found that you need to add a async method right behind the yeild in the async function. for example:

yield answer
await asyncio.sleep(0)

Otherwise the function will be blocked until all the streaming data are received. There are two ways to solve it:

  • make the async def stream_message sync,
  • Add a async method below the yield.

I have no idea make this happen, if you figure it out what is happening, catch me later.

@Amm1rr Amm1rr added the bug Something isn't working label Apr 20, 2024
@Amm1rr
Copy link
Owner

Amm1rr commented Apr 20, 2024

Thank you, I have fixed that.

@Amm1rr Amm1rr closed this as completed Apr 20, 2024
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

2 participants