Skip to content

Commit

Permalink
fix: message parser bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodacus committed Nov 16, 2024
1 parent d46070b commit d5d07e8
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/lib/runtime/message-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,21 @@ export class StreamingMessageParser {
}
break;
}
} else if (state.insideToolCall) {
let { cursor, event } = this._options.agentOutputParser.parse(messageId, input);
if (event && event.type == 'toolCallComplete') {
state.position += cursor.position + 1;
i = state.position;
state.insideToolCall = false;

const artifactFactory = this._options.artifactElement ?? createArtifactElement;
output += artifactFactory({ messageId }) || '';

break;
}

break

} else {
const actionOpenIndex = input.indexOf(ARTIFACT_ACTION_TAG_OPEN, i);
const artifactCloseIndex = input.indexOf(ARTIFACT_TAG_CLOSE, i);
Expand Down Expand Up @@ -179,22 +194,7 @@ export class StreamingMessageParser {
}
}
}
if (state.insideToolCall) {
let { cursor, event } = this._options.agentOutputParser.parse(messageId, input);
if (event && event.type == 'toolCallComplete') {
state.position += cursor.position + 1;
i = state.position;
state.insideToolCall = false;

const artifactFactory = this._options.artifactElement ?? createArtifactElement;
output += artifactFactory({ messageId })||'';

break;
}

break

}

else if (input[i] === '<' && input[i + 1] !== '/') {
let j = i;
let potentialTag = '';
Expand Down

0 comments on commit d5d07e8

Please sign in to comment.