link0518 commited on
Commit
3ed6209
·
1 Parent(s): f783f84

fix: 修复message.content.trim调用错误

Browse files
Files changed (1) hide show
  1. src/utils/utils.js +14 -2
src/utils/utils.js CHANGED
@@ -67,7 +67,19 @@ function handleUserMessage(extracted, antigravityMessages) {
67
  function handleAssistantMessage(message, antigravityMessages) {
68
  const lastMessage = antigravityMessages[antigravityMessages.length - 1];
69
  const hasToolCalls = message.tool_calls && message.tool_calls.length > 0;
70
- const hasContent = message.content && message.content.trim() !== '';
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  const antigravityTools = hasToolCalls ? message.tool_calls.map(toolCall => ({
73
  functionCall: {
@@ -84,7 +96,7 @@ function handleAssistantMessage(message, antigravityMessages) {
84
  } else {
85
  const parts = [];
86
  if (hasContent) {
87
- let text = message.content;
88
  let thoughtSignature = null;
89
  const signatureMatch = text.match(/<!-- thought_signature: (.+?) -->/);
90
  if (signatureMatch) {
 
67
  function handleAssistantMessage(message, antigravityMessages) {
68
  const lastMessage = antigravityMessages[antigravityMessages.length - 1];
69
  const hasToolCalls = message.tool_calls && message.tool_calls.length > 0;
70
+
71
+ let contentText = '';
72
+ if (typeof message.content === 'string') {
73
+ contentText = message.content;
74
+ } else if (Array.isArray(message.content)) {
75
+ for (const item of message.content) {
76
+ if (item.type === 'text') {
77
+ contentText += item.text;
78
+ }
79
+ }
80
+ }
81
+
82
+ const hasContent = contentText && contentText.trim() !== '';
83
 
84
  const antigravityTools = hasToolCalls ? message.tool_calls.map(toolCall => ({
85
  functionCall: {
 
96
  } else {
97
  const parts = [];
98
  if (hasContent) {
99
+ let text = contentText;
100
  let thoughtSignature = null;
101
  const signatureMatch = text.match(/<!-- thought_signature: (.+?) -->/);
102
  if (signatureMatch) {