lanarky: bug: Expected response header Content-Type to contain 'text/event-stream', got 'text/plain'
Scenario
While running following client, httpx throws the exception denoting that Content-Type is ‘text/plain’ instead of ‘text/event-stream’
import json
import click
from lanarky.clients import StreamingClient
@click.command()
@click.option("--input", required=True)
@click.option("--stream", is_flag=True)
def main(input: str, stream: bool):
client = StreamingClient("http://localhost:8001")
for event in client.stream_response(
method="POST",
path="/chat?session_id=123",
json={"input": input},
):
print(f"{event.event}: {json.loads(event.data)['token']}", end="", flush=True)
if __name__ == "__main__":
main()
The following versions and dependencies are used:
- python: 3.11
- langchain: 0.1.12
- lanarky: 0.8.5
- fastapi: 0.110.0
- httpx: 0.27.0
- httpx-sse: 0.4.0
Actual result
httpx_sse._exceptions.SSEError: Expected response header Content-Type to contain 'text/event-stream', got 'text/plain'
Expected result
The client should be able to send the streaming request properly
Acceptance criteria
- [ ]
Contribute
- Yes, I can fix this bug and open a PR
About this issue
- Original URL
- State: open
- Created 4 months ago
- Comments: 31 (10 by maintainers)
@ajndkr I tried that too (the following code)
it also results in unfinished chain which compels the client to keep on pinging continuously.
@ajndkr Thanks a lot for your continuous assistance! Looking forward to your further analysis 👍
@ajndkr Thanks a lot for your quick response. I strongly believe that the main issue lies in
Attempted to access streaming response content, without having called read().
and we have to figure out what needs to be done there.