Skip to content

Conversation

YoungHypo
Copy link

@YoungHypo YoungHypo commented Jun 19, 2025

Problem description

#24

Cause Analysis

chat_history in app.py has the following structure.

[
    UserContent(
        parts=[
            Part(
                text='<input prompt>',
                video_metadata=None,
                thought=None,
                code_execution_result=None,
                executable_code=None,
                file_data=None,
                function_call=None,
                function_response=None,
                inline_data=None
            )
        ],
        role='user'
    ),
    Content(
        parts=[
            Part(
                text='<output response 1>',
                video_metadata=None,
                thought=None,
                code_execution_result=None,
                executable_code=None,
                file_data=None,
                function_call=None,
                function_response=None,
                inline_data=None
            )
        ],
        role='model'
    ),
    Content(
        parts=[
            Part(
                text='<output response 2>',
                ...
            )
        ],
        role='model'
    )
]

The templates/index.html file does not handle this structure. Also, a model response may be split into multiple Content objects. That's why there are lots of empty pop-ups after refreshing.

Solution

Refactor the Jinja2 template logic to:

  • Validate content (filter out empty messages and check whether is User of Model),
  • Merge consecutive model responses into a single reply,

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

Successfully merging this pull request may close these issues.

1 participant