-
Notifications
You must be signed in to change notification settings - Fork 40
feat(chat): Add the ability to support content parts in the chat (Issue #3769) #3777
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
base: development
Are you sure you want to change the base?
Conversation
/deploy-review
|
/deploy-review
|
/deploy-review
|
/deploy-review
|
})} | ||
|
||
{/* Keep support old render for backward compatibility */} | ||
{!!(message.content || (!message.parts && isShowResponseLoader)) && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have content
and parts
together?
according to this code we can render both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It could be either content
or parts
, but we need to have compatibility with old chats which have only content
and if user wants to continue the chat.
content += part.content; | ||
} | ||
}); | ||
return content; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return content; | |
return content.trim(); |
let content = ''; | ||
parts.forEach((part) => { | ||
if (part.content) { | ||
content += part.content; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use any separator here?
const lastIndex = newSource.parts.length - 1; | ||
if (newSource.parts[lastIndex]?.content) { | ||
const newContent: ContentPart = { | ||
partId: nanoid(4), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you update partId
here? if this part already have content that means that partId
already was generated and need to update only content
newSource.parts[lastIndex].content += newData.content;
|
||
if (newSource.parts[lastIndex]?.attachments) { | ||
const newAttachments = { | ||
partId: nanoid(4), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same. See previous comment
content?: string; | ||
attachments?: Attachment[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose type should be { partId:string } & ({ content: string } | { attachments: Attachment[] })
because one kind of payload is required here (XOR)
@@ -67,10 +68,24 @@ export const mergeMessages = ( | |||
} | |||
|
|||
if (newData.content) { | |||
if (!newSource.content) { | |||
newSource.content = ''; | |||
if (!newSource.parts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check some flag to start putting the content into parts? It looks like now we started to use parts always without conditions
Pull request was converted to draft
Description:
Add the ability to support content parts in the chat
Issues:
Related:
Checklist:
fix(<scope>):
,feat(<scope>):
,feature(<scope>):
,chore(<scope>):
,hotfix(<scope>):
ore2e(<scope>):
. If contains breaking changes then the pull request name must start withfix(<scope>)!:
,feat(<scope>)!:
,feature(<scope>)!:
,chore(<scope>)!:
,hotfix(<scope>)!:
ore2e(<scope>)!:
where<scope>
is name of affected project:chat
,chat-e2e
,overlay
,shared
,sandbox-overlay
, etc.(Issue #<TICKET_ID>)
(comma-separated list of issues)