Skip to content

Commit

Permalink
style consistency
Browse files Browse the repository at this point in the history
Signed-off-by: Jared Van Bortel <[email protected]>
  • Loading branch information
cebtenzzre committed Jan 30, 2025
1 parent b80f171 commit c990fe6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions gpt4all-chat/src/chatllm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ auto ChatLLM::promptInternal(

// Split the response into two if needed and create chat items
if (toolCallParser.numberOfBuffers() < 2 && toolCallParser.splitIfPossible()) {
const QStringList parseBuffers = toolCallParser.buffers();
const auto parseBuffers = toolCallParser.buffers();
Q_ASSERT(parseBuffers.size() == 2);
if (toolCallParser.startTag() == ToolCallConstants::ThinkTag)
m_chatModel->splitThinking({parseBuffers.at(0), parseBuffers.at(1)});
Expand All @@ -953,7 +953,7 @@ auto ChatLLM::promptInternal(
// Split the response into three if needed and create chat items
if (toolCallParser.numberOfBuffers() < 3 && toolCallParser.startTag() == ToolCallConstants::ThinkTag
&& toolCallParser.splitIfPossible()) {
const QStringList parseBuffers = toolCallParser.buffers();
const auto parseBuffers = toolCallParser.buffers();
Q_ASSERT(parseBuffers.size() == 3);
m_chatModel->endThinking({parseBuffers.at(1), parseBuffers.at(2)}, totalTime.elapsed());
}
Expand All @@ -962,7 +962,7 @@ auto ChatLLM::promptInternal(
auto respStr = QString::fromUtf8(result.response);

try {
const QStringList parseBuffers = toolCallParser.buffers();
const auto parseBuffers = toolCallParser.buffers();
if (parseBuffers.size() > 1)
m_chatModel->setResponseValue(parseBuffers.last());
else
Expand Down Expand Up @@ -996,7 +996,7 @@ auto ChatLLM::promptInternal(
m_timer->stop();
qint64 elapsed = totalTime.elapsed();

const QStringList parseBuffers = toolCallParser.buffers();
const auto parseBuffers = toolCallParser.buffers();
const bool shouldExecuteToolCall = toolCallParser.state() == ToolEnums::ParseState::Complete
&& toolCallParser.startTag() != ToolCallConstants::ThinkTag;

Expand Down
12 changes: 6 additions & 6 deletions gpt4all-chat/src/toolcallparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void ToolCallParser::reset()

// These are global states maintained between update calls
m_buffers.clear();
m_buffers.append(QByteArray());
m_buffers << QByteArray();
}

void ToolCallParser::resetSearchState()
Expand Down Expand Up @@ -159,18 +159,18 @@ bool ToolCallParser::splitIfPossible()
// The first split happens when we're in a partial state
if (m_buffers.size() < 2 && m_state == ToolEnums::ParseState::Partial) {
Q_ASSERT(m_startIndex >= 0);
const QByteArray beforeToolCall = currentBuffer().left(m_startIndex);
const QByteArray toolCall = currentBuffer().mid(m_startIndex);
const auto beforeToolCall = currentBuffer().left(m_startIndex);
const auto toolCall = currentBuffer().mid (m_startIndex);
m_buffers = { beforeToolCall, toolCall };
return true;
}

// The second split happens when we're in the complete state
if (m_buffers.size() < 3 && m_state == ToolEnums::ParseState::Complete) {
Q_ASSERT(m_endIndex >= 0);
const QByteArray &beforeToolCall = m_buffers.first();
const QByteArray toolCall = currentBuffer().left(m_endIndex);
const QByteArray afterToolCall = currentBuffer().mid(m_endIndex);
const auto &beforeToolCall = m_buffers.first();
const auto toolCall = currentBuffer().left(m_endIndex);
const auto afterToolCall = currentBuffer().mid (m_endIndex);
m_buffers = { beforeToolCall, toolCall, afterToolCall };
return true;
}
Expand Down

0 comments on commit c990fe6

Please sign in to comment.