Merge pull request #943 from trheyi/main

Update asset metadata and enhance Agent class functionality in SUI
This commit is contained in:
Max 2025-05-08 12:21:36 +08:00 committed by GitHub
commit dec0a7db6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 91 additions and 85 deletions

File diff suppressed because one or more lines are too long

View file

@ -211,6 +211,7 @@ class Agent {
};
try {
let last_type: string | null = null;
const es = new EventSource(endpoint, { withCredentials: true });
this.es = es;
@ -226,10 +227,10 @@ class Agent {
const {
tool_id,
begin,
type,
end,
text,
props,
type,
done,
assistant_id,
assistant_name,
@ -271,11 +272,16 @@ class Agent {
// Check if we need to create a new message
const shouldCreateNewMessage =
(type !== last_type &&
(!done || (done === true && (text || props)))) || // if type changed or done is true and there is text or props
messages.length === 0 ||
(assistant_id &&
messages[messages.length - 1].assistant_id !== assistant_id) ||
(is_new && !delta); // Only create new message if it's new and not a delta update
// Update last type
last_type = type;
// Update assistant information
if (assistant_id) lastAssistant.assistant_id = assistant_id;
if (assistant_name) lastAssistant.assistant_name = assistant_name;