Skip to content

Comments

Fix: Incorrect chat title generation#4775

Closed
sh4shii wants to merge 1 commit intocontinuedev:mainfrom
sh4shii:fix/chat-title
Closed

Fix: Incorrect chat title generation#4775
sh4shii wants to merge 1 commit intocontinuedev:mainfrom
sh4shii:fix/chat-title

Conversation

@sh4shii
Copy link
Contributor

@sh4shii sh4shii commented Mar 23, 2025

Description

fixes: #4774
The chat title was previously being generated as [object Object][object Object]. This issue has been fixed by ensuring the correct string representation is used for the title.

Checklist

  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screenshots

As you can see in the attached screenshot, the chat title is now generated correctly.
image

Testing instructions

[ For new or modified features, provide step-by-step testing instructions to validate the intended behavior of the change, including any relevant tests to run. ]

@sh4shii sh4shii requested a review from a team as a code owner March 23, 2025 19:56
@sh4shii sh4shii requested review from sestinj and removed request for a team March 23, 2025 19:56
@netlify
Copy link

netlify bot commented Mar 23, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit ad0667e
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67e0678cc133250008d86deb

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sh4shii would it be possible to implement the same fix using chat instead of complete? Something in the latter lines you updated is likely the culprit?

Specifically wondering what the [object Object] actually is in your case. Is it an error because the model doesn't support chat? Is it not parsed correctly?

@sh4shii
Copy link
Contributor Author

sh4shii commented Mar 24, 2025

@RomneyDa tried implementing the fix using model.chat, but it's still returning [object Object][object Object] instead of the expected string.

It seems like the response from model.chat is not being parsed correctly, as it returns:
titleResponse
{role: 'assistant', content: '[object Object][object Object]'}
Whereas model.complete correctly returns a string with the title.

This suggests that either the model's chat response structure differs, or additional parsing is needed when using model.chat. Do you have any insights on why this might be happening? I can explore further based on that.

@RomneyDa
Copy link
Collaborator

I don't have an immediate answer to why chat is returning {role: 'assistant', content: '[object Object][object Object]'} but let's debug that before switching to complete. If you put a breakpoint in chat for whichever provider class you're using (or BaseLLM) you should be able to walk through and find this. I haven't been able to duplicate on my end, would you be able to try that breakpoint?

@sh4shii
Copy link
Contributor Author

sh4shii commented Mar 29, 2025

@RomneyDa I've investigated with breakpoints in the Gemini model class as suggested. Here's what I found:

  1. Within the stream chat, the message structure looks correct:
    message:
    {role: 'assistant', content: Array(1)}
    content: (1) [{…}]
    0: {type: 'text', text: 'React'}

  2. However, when this response is returned as titleResponse, it somehow transforms to:
    {
    role: 'assistant',
    content: '[object Object][object Object]'
    }

Would you be able to point me to which specific files/methods I should add logging or breakpoints to track this transformation?

@sestinj sestinj removed their request for review April 1, 2025 03:46
@RomneyDa
Copy link
Collaborator

RomneyDa commented Apr 1, 2025

@sh4shii looks like could be one of two lines. Probably BaseLLM's chat function:

async chat(
    messages: ChatMessage[],
    signal: AbortSignal,
    options: LLMFullCompletionOptions = {},
  ) {
    let completion = "";
    for await (const chunk of this.streamChat(messages, signal, options)) {
      completion += chunk.content;
    }
    return { role: "assistant" as const, content: completion };
  }

In completion += chunk.content, chunk.content is MessageContent, which can be an array of parts. I might try that first

Same issue actually shows up in ChatDescriber

removeQuotesAndEscapes(titleResponse.content.toString());

where content can be an array

@RomneyDa
Copy link
Collaborator

@sh4shii done here #5425
Added you as coauthor on the commit, thanks for the contribution!

@RomneyDa RomneyDa closed this Apr 29, 2025
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.

Chat Title Displays as [object Object]

2 participants