File tree 1 file changed +6
-19
lines changed
1 file changed +6
-19
lines changed Original file line number Diff line number Diff line change @@ -256,13 +256,12 @@ class ChatItem : public QObject
256
256
if (parser.startIndex () < 0 )
257
257
return value;
258
258
259
- // Otherwise we only return the text before and any partial code interpreter code
259
+ // Otherwise we only return the text before and any partial tool call
260
260
const QString beforeToolCall = value.left (parser.startIndex ());
261
- const QString toolCallString = value.mid (parser.startIndex ());
262
- return beforeToolCall + codeInterpreterContent (toolCallString);
261
+ return beforeToolCall;
263
262
}
264
263
265
- // For complete tool calls we only return content if it is code interpreter
264
+ // For tool calls we only return content if it is the code interpreter
266
265
if (type () == Type::ToolCall)
267
266
return codeInterpreterContent (value);
268
267
@@ -275,23 +274,11 @@ class ChatItem : public QObject
275
274
276
275
QString codeInterpreterContent (const QString &value) const
277
276
{
278
- // Constants for identifying and formatting the code interpreter tool call
279
- static const QString prefix = ToolCallConstants::CodeInterpreterTag;
280
-
281
- // Check if the tool call is a code interpreter tool call
282
- if (!value.startsWith (prefix))
283
- return QString ();
284
-
285
- // Regex to remove the tag and any surrounding whitespace
286
- static const QRegularExpression regex (" ^"
287
- + ToolCallConstants::CodeInterpreterTag
288
- + " \\ s*|\\ s*"
289
- + ToolCallConstants::CodeInterpreterEndTag
290
- + " $" );
277
+ ToolCallParser parser;
278
+ parser.update (value);
291
279
292
280
// Extract the code
293
- QString code = value;
294
- code.remove (regex);
281
+ QString code = parser.toolCall ();
295
282
code = code.trimmed ();
296
283
297
284
QString result;
You can’t perform that action at this time.
0 commit comments