Skip to content

DeepSeek chat completion returns empty/invalid content causing dirtyjson parse failure #383

@KeepMovingNo1

Description

@KeepMovingNo1

When using DeepSeek chat completion API to generate structured slide content for PPT creation, the request returns HTTP 200 OK, but the response content is empty or not valid JSON, which causes a runtime exception during JSON parsing.

This issue breaks the PPT generation workflow and results in a 422 Unprocessable Entity error from the FastAPI endpoint.

2025-12-25 01:23:04,830 - INFO - HTTP Request: POST https://api.deepseek.com/v1/chat/completions "HTTP/1.1 200 OK"
Traceback (most recent call last):
File "/app/servers/fastapi/utils/llm_calls/generate_slide_content.py", line 129, in get_slide_content_from_type_and_outline
response = await client.generate_structured(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/servers/fastapi/services/llm_client.py", line 816, in generate_structured
content = await self._generate_custom_structured(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/servers/fastapi/services/llm_client.py", line 759, in _generate_custom_structured
return await self._generate_openai_structured(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/servers/fastapi/services/llm_client.py", line 558, in _generate_openai_structured
return dict(dirtyjson.loads(content))
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/dirtyjson/init.py", line 94, in loads
return d.decode(search_for_first_object, start_index)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/dirtyjson/loader.py", line 372, in decode
obj = self.scan()
^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/dirtyjson/loader.py", line 207, in scan
raise Error(self.expecting, self.content, self.pos)
dirtyjson.error.Error: Expecting value: line 1 column 1 (char 0)
INFO: 127.0.0.1:52052 - "PATCH /api/v1/ppt/presentation/update HTTP/1.0" 422 Unprocessable Entity
INFO: 127.0.0.1:52056 - "PATCH /api/v1/ppt/presentation/update HTTP/1.0" 422 Unprocessable Entity

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🛠 Improvements (Low)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions