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

Exception in ASGI application #176

Open
Favern opened this issue Feb 3, 2024 · 3 comments
Open

Exception in ASGI application #176

Favern opened this issue Feb 3, 2024 · 3 comments

Comments

@Favern
Copy link

Favern commented Feb 3, 2024

Hello All,

I installed openchat and openchat-ui on a ubuntu 23.04.
Unfortunatelly, when i ask a question on the web page, i have this error on the openchat ssh console :

During handling of the above exception, another exception occurred:

  • Exception Group Traceback (most recent call last):
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call
    | return await self.app(scope, receive, send)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/applications.py", line 123, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call
    | raise exc
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call
    | await self.app(scope, receive, _send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in call
    | await self.app(scope, receive, send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    | raise exc
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 762, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 782, in app
    | await route.handle(scope, receive, send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 297, in handle
    | await self.app(scope, receive, send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 77, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    | raise exc
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 75, in app
    | await response(scope, receive, send)
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/responses.py", line 254, in call
    | async with anyio.create_task_group() as task_group:
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 678, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/responses.py", line 257, in wrap
    | await func()
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/responses.py", line 246, in stream_response
    | async for chunk in self.body_iterator:
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/ochat/serving/openai_api_server.py", line 222, in completion_stream_generator
    | yield f"data: {chunk.json(exclude_unset=True, ensure_ascii=False)}\n\n"
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ubuntu/miniconda3/envs/openchat/lib/python3.11/site-packages/pydantic/main.py", line 1056, in json
    | raise TypeError('dumps_kwargs keyword arguments are no longer supported.')
    | TypeError: dumps_kwargs keyword arguments are no longer supported.
    +------------------------------------

Do you have an idea to solve this problem ?
Best regards

@Lockness0911
Copy link

I have this same problem
Mine is
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/applications.py", line 123, in call
await self.middleware_stack(scope, receive, send)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call
raise exc
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call
await self.app(scope, receive, _send)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in call
await self.app(scope, receive, send)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
raise exc
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 758, in call
await self.middleware_stack(scope, receive, send)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 778, in app
await route.handle(scope, receive, send)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 299, in handle
await self.app(scope, receive, send)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 79, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
raise exc
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/routing.py", line 74, in app
response = await func(request)
^^^^^^^^^^^^^^^^^^^
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/fastapi/routing.py", line 278, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/ochat/serving/openai_api_server.py", line 137, in create_chat_completion
request = openai_api_protocol.ChatCompletionRequest(**await raw_request.json())
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/site-packages/starlette/requests.py", line 252, in json
self._json = json.loads(body)
^^^^^^^^^^^^^^^^
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/json/init.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lockness01/miniconda3/envs/openchat/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@whatEverPan
Copy link

whatEverPan commented Mar 15, 2024

The dumps_kwargs keyword argument is no longer supported. This change was introduced in Pydantic library version 1.8.0. If you want to fix the code snippet above, you can follow these steps:

file openchat/ochat/serving/openai_api_server.py

  1. Replace
    chunk.json(exclude_unset=True, ensure_ascii=False)
    with
    json.dumps(chunk.dict(exclude_unset=True), ensure_ascii=False)
  2. Replace
    response.json(exclude_unset=True, ensure_ascii=False)
    with
    response.json(exclude_unset=True)

In summary, Pydantic no longer accepts the dumps_kwargs argument, and you should use json.dumps instead of chunk.json for serialization

@Lockness0911
Copy link

The dumps_kwargs keyword argument is no longer supported. This change was introduced in Pydantic library version 1.8.0. If you want to fix the code snippet above, you can follow these steps:

file openchat/ochat/serving/openai_api_server.py

  1. Replace
    chunk.json(exclude_unset=True, ensure_ascii=False)
    with
    json.dumps(chunk.dict(exclude_unset=True), ensure_ascii=False)
  2. Replace
    response.json(exclude_unset=True, ensure_ascii=False)
    with
    response.json(exclude_unset=True)

In summary, Pydantic no longer accepts the dumps_kwargs argument, and you should use json.dumps instead of chunk.json for serialization

Thanks so much ill try your fix if it happens again i tried everything finally making sure all libarys were upto date which they werent despite being a fresh install, so i updated all the libarys for example "pydantic" and the rest and it fixed it...

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

4 participants
@Favern @whatEverPan @Lockness0911 and others