MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / issueRequest

Method issueRequest

app/src/AI/Conversation.cpp:1079–1125  ·  view source on GitHub ↗

* @brief Issues a fresh request to the active provider with the current history. */

Source from the content-addressed store, hash-verified

1077 * @brief Issues a fresh request to the active provider with the current history.
1078 */
1079void AI::Conversation::issueRequest()
1080{
1081 Q_ASSERT(m_provider);
1082 Q_ASSERT(m_dispatcher);
1083
1084 pruneHistory();
1085
1086 reconcileHistoryToolPairs();
1087
1088 ageHistoryToolResults();
1089
1090 beginAssistantMessage();
1091
1092 if (m_provider->capabilities().slowFirstToken)
1093 m_assistantThinking = tr("Waiting for %1 to respond. Loading the model and processing "
1094 "the prompt can take a while on local hardware...")
1095 .arg(m_provider->displayName());
1096 else
1097 m_assistantThinking = tr("Sending request to %1...").arg(m_provider->displayName());
1098
1099 m_thinkingIsSynthetic = true;
1100 if (m_assistantIndex >= 0 && m_assistantIndex < m_uiMessages.size()) {
1101 auto map = m_uiMessages.at(m_assistantIndex).toMap();
1102 map.insert(QStringLiteral("thinking"), m_assistantThinking);
1103 m_uiMessages[m_assistantIndex] = map;
1104 Q_EMIT messagesChanged();
1105 }
1106
1107 const auto tools = dispatcherTools();
1108 m_reply = m_provider->sendMessage(budgetedHistory(tools), tools, m_summaryForced);
1109 if (!m_reply) {
1110 setLastError(tr("Provider returned no reply"));
1111 Q_EMIT errorOccurred(m_lastError);
1112 setBusy(false);
1113 return;
1114 }
1115
1116 connect(m_reply, &Reply::partialText, this, &Conversation::onPartialText);
1117 connect(m_reply, &Reply::partialThinking, this, &Conversation::onPartialThinking);
1118 connect(m_reply, &Reply::thinkingBlockFinished, this, &Conversation::onThinkingBlockFinished);
1119 connect(m_reply, &Reply::toolCallRequested, this, &Conversation::onToolCallRequested);
1120 connect(m_reply, &Reply::finished, this, &Conversation::onReplyFinished);
1121 connect(m_reply, &Reply::errorOccurred, this, &Conversation::onReplyError);
1122 connect(m_reply, &Reply::cacheStatsAvailable, this, [](int read, int created) {
1123 Assistant::instance().reportCacheStats(read, created);
1124 });
1125}
1126
1127/**
1128 * @brief Returns the ordered, deduped tool_use ids declared by an assistant message.

Callers

nothing calls this directly

Calls 5

reportCacheStatsMethod · 0.80
capabilitiesMethod · 0.45
displayNameMethod · 0.45
sizeMethod · 0.45
sendMessageMethod · 0.45

Tested by

no test coverage detected