-
Notifications
You must be signed in to change notification settings - Fork 227
Add escaping of whitespaces in qwen3coder tool output #3691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
dd9714c
8b7f8f6
9c15e60
6b6214b
7fc0563
1606470
72b54fc
0e4abd9
f30be1d
c92d05b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -127,6 +127,22 @@ static const ParametersTypeMap_t parseToolSchema(const std::string& functionName | |||||
return result; | ||||||
} | ||||||
|
||||||
// helper function to double escape \n,\r, \t in string | ||||||
static std::string escapeString(const std::string& input) { | ||||||
std::string output; | ||||||
output.reserve(input.size()); | ||||||
for (char c : input) { | ||||||
switch (c) { | ||||||
case '\n': | ||||||
output += "\\n"; | ||||||
break; | ||||||
default: | ||||||
output += c; | ||||||
} | ||||||
} | ||||||
return output; | ||||||
} | ||||||
|
||||||
static std::string setCorrectValueType(std::string& inputValue, const std::string& currentParameterName, const ParametersTypeMap_t& parametersType) { | ||||||
auto paramIt = parametersType.find(currentParameterName); | ||||||
if (paramIt == parametersType.end()) { | ||||||
|
@@ -157,10 +173,24 @@ bool Qwen3CoderToolParserImpl::parseUntilStateChange(ToolCalls_t& toolCalls) { | |||||
auto previousState = this->currentState; | ||||||
switch (this->currentState) { | ||||||
case State::Content: { | ||||||
DEFINE_TAG_POSITION_AND_BREAK_IF_NOT_FOUND(Qwen3CoderToolParser::TOOL_START_TAG); | ||||||
this->lastProcessedPosition = pos + Qwen3CoderToolParser::TOOL_START_TAG.length(); | ||||||
this->currentState = State::InsideToolCall; | ||||||
this->toolCallPositions.begin.push(pos); | ||||||
// normally we expect <tool_call> tag but we observerd that sometimes model generates <function=...> directly | ||||||
|
// normally we expect <tool_call> tag but we observerd that sometimes model generates <function=...> directly | |
// normally we expect <tool_call> tag but we observed that sometimes model generates <function=...> directly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it cover well cases when posTool == std::string::npos
or posFunc == std::string::npos
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then posTool != posFunc so we hit either else if
or else
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"we will add it" - do you inject "<tool_call>" somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misleading comment - i will remove it.
Uh oh!
There was an error while loading. Please reload this page.