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

Chunk too big #98

Open
talhaanwarch opened this issue Apr 30, 2024 · 0 comments
Open

Chunk too big #98

talhaanwarch opened this issue Apr 30, 2024 · 0 comments

Comments

@talhaanwarch
Copy link

While calling humloop streaming endpoint, i encountered this error. Though this is caused by aiohttp here but not sure what is recommended way to stream in humanloop with prompt deployed on humanloop

async def humanloop_stream(config, project, inputs, ref_id, metadata, messages=None):
    humanloop = Humanloop(
        api_key=config["HUMANLOOP_API_KEY"], openai_api_key=config["openai_api_key"]
    )
    response = await humanloop.chat_deployed_stream(
        messages=messages if messages else [],
        session_reference_id=ref_id,
        user=ref_id,
        project=project,
        inputs=inputs,
        source=config["HUMANLOOP_ENV"],  # local, prod, dev,stg
        metadata=metadata,
        save=True,
        num_samples=1,
        stream=True,
        environment=config["HUMANLOOP_ENV"],
    )
    async for token in response.content:
        yield token

Error log

raceback (most recent call last):
  File "menv/lib/python3.10/site-packages/starlette/responses.py", line 264, in __call__
    await wrap(partial(self.listen_for_disconnect, receive))
  File "menv/lib/python3.10/site-packages/starlette/responses.py", line 260, in wrap
    await func()
  File "menv/lib/python3.10/site-packages/starlette/responses.py", line 237, in listen_for_disconnect
    message = await receive()
  File "menv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 535, in receive
    await self.message_event.wait()
  File "/usr/lib/python3.10/asyncio/locks.py", line 214, in wait
    await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 7ed1bb777040

During handling of the above exception, another exception occurred:

  + Exception Group Traceback (most recent call last):
  |   File "menv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
  |     result = await app(  # type: ignore[func-returns-value]
  |   File "menv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
  |     return await self.app(scope, receive, send)
  |   File "menv/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
  |     await super().__call__(scope, receive, send)
  |   File "menv/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
  |     await self.middleware_stack(scope, receive, send)
  |   File "menv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
  |     raise exc
  |   File "menv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
  |     await self.app(scope, receive, _send)
  |   File "menv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
  |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  |   File "menv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
  |     raise exc
  |   File "menv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
  |     await app(scope, receive, sender)
  |   File "menv/lib/python3.10/site-packages/starlette/routing.py", line 758, in __call__
  |     await self.middleware_stack(scope, receive, send)
  |   File "menv/lib/python3.10/site-packages/starlette/routing.py", line 778, in app
  |     await route.handle(scope, receive, send)
  |   File "menv/lib/python3.10/site-packages/starlette/routing.py", line 299, in handle
  |     await self.app(scope, receive, send)
  |   File "menv/lib/python3.10/site-packages/starlette/routing.py", line 79, in app
  |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  |   File "menv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
  |     raise exc
  |   File "menv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
  |     await app(scope, receive, sender)
  |   File "menv/lib/python3.10/site-packages/starlette/routing.py", line 77, in app
  |     await response(scope, receive, send)
  |   File "menv/lib/python3.10/site-packages/starlette/responses.py", line 257, in __call__
  |     async with anyio.create_task_group() as task_group:
  |   File "menv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 678, in __aexit__
  |     raise BaseExceptionGroup(
  | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "src/prompts/conversation.py", line 388, in qa_conversation_hl
    |     async for chunk in generator:
    |   File "src/prompts/conversation.py", line 57, in humanloop_stream
    |     async for token in response.content:
    |   File "menv/lib/python3.10/site-packages/humanloop/client_custom.py", line 43, in _parsed_generator
    |     async for line in generator:
    |   File "menv/lib/python3.10/site-packages/humanloop/paths/chat_deployed/post.py", line 278, in stream_iterator
    |     async for line in response.http_response.content:
    |   File "menv/lib/python3.10/site-packages/aiohttp/streams.py", line 44, in __anext__
    |     rv = await self.read_func()
    |   File "menv/lib/python3.10/site-packages/aiohttp/streams.py", line 307, in readline
    |     return await self.readuntil()
    |   File "menv/lib/python3.10/site-packages/aiohttp/streams.py", line 339, in readuntil
    |     raise ValueError("Chunk too big")
    | ValueError: Chunk too big
    | 
    +------------------------------------
    ```
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