incognitolm commited on
Commit
4f18d5e
·
verified ·
1 Parent(s): 8d1cf35

Update server/wsHandler.js

Browse files
Files changed (1) hide show
  1. server/wsHandler.js +3 -2
server/wsHandler.js CHANGED
@@ -153,8 +153,9 @@ const handlers = {
153
  const finalText = text || fullText;
154
  const userEntry = buildEntry('user', content);
155
  const asstEntry = buildEntry('assistant', finalText, toolCalls || []);
 
 
156
  const newHistory = [...(session.history || []), userEntry, asstEntry];
157
- for (const a of assetsCollected) newHistory.push({ role: a.role, content: a.content, timestamp: Date.now() });
158
  let newName = session.name;
159
  if (!(session.history || []).length || session.name === 'New Chat')
160
  newName = await autoName(content, client.accessToken);
@@ -259,4 +260,4 @@ async function autoName(prompt, accessToken) {
259
  const d = await r.json();
260
  return d.choices?.[0]?.message?.content?.trim() || 'New Chat';
261
  } catch { return 'New Chat'; }
262
- }
 
153
  const finalText = text || fullText;
154
  const userEntry = buildEntry('user', content);
155
  const asstEntry = buildEntry('assistant', finalText, toolCalls || []);
156
+ // Assets (images/video/audio) are sent to the client via chat:asset events and
157
+ // must NOT be pushed into LLM history — invalid roles cause blank responses.
158
  const newHistory = [...(session.history || []), userEntry, asstEntry];
 
159
  let newName = session.name;
160
  if (!(session.history || []).length || session.name === 'New Chat')
161
  newName = await autoName(content, client.accessToken);
 
260
  const d = await r.json();
261
  return d.choices?.[0]?.message?.content?.trim() || 'New Chat';
262
  } catch { return 'New Chat'; }
263
+ }