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

AttributeError: 'ChatCompletionChunk' object has no attribute 'as_dict' #2037

Open
doncat99 opened this issue Mar 12, 2025 · 0 comments
Open

Comments

@doncat99
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Traceback (most recent call last):
File "/Users/huangdon/Documents/universe-platform/libs/R2R/py/core/base/providers/llm.py", line 183, in aget_completion_stream
yield LLMChatCompletionChunk(**(chunk.dict()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/pydantic/main.py", line 214, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ChatCompletionChunk
choices.0.delta.tool_calls.0.index
Input should be a valid integer [type=int_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/int_type

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in call
await self.app(scope, receive, send)
File "/Users/huangdon/miniconda3/envs/universe/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 "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/routing.py", line 714, in call
await self.middleware_stack(scope, receive, send)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/routing.py", line 74, in app
await response(scope, receive, send)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/responses.py", line 258, in call
await self.stream_response(send)
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/starlette/responses.py", line 246, in stream_response
async for chunk in self.body_iterator:
File "/Users/huangdon/Documents/universe-platform/libs/R2R/py/core/main/api/v3/retrieval_router.py", line 805, in stream_generator
async for chunk in response:
File "/Users/huangdon/Documents/universe-platform/libs/R2R/py/core/main/services/retrieval_service.py", line 929, in stream_response
raise e
File "/Users/huangdon/Documents/universe-platform/libs/R2R/py/core/main/services/retrieval_service.py", line 921, in stream_response
async for chunk in agent.arun(
File "/Users/huangdon/Documents/universe-platform/libs/R2R/py/core/agent/base.py", line 146, in arun
async for proc_chunk in self.process_llm_response(
File "/Users/huangdon/Documents/universe-platform/libs/R2R/py/core/agent/base.py", line 501, in process_llm_response
async for chunk in stream:
File "/Users/huangdon/Documents/universe-platform/libs/R2R/py/core/base/providers/llm.py", line 186, in aget_completion_stream
yield LLMChatCompletionChunk(**(chunk.as_dict()))
^^^^^^^^^^^^^
File "/Users/huangdon/miniconda3/envs/universe/lib/python3.11/site-packages/pydantic/main.py", line 891, in getattr
raise AttributeError(f'{type(self).name!r} object has no attribute {item!r}')
AttributeError: 'ChatCompletionChunk' object has no attribute 'as_dict'

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