| 202 | } |
| 203 | |
| 204 | LLMQore::RequestID Session::dispatch(std::optional<bool> toolsOverride) |
| 205 | { |
| 206 | auto *provider = m_agent->provider(); |
| 207 | auto *tmpl = m_agent->promptTemplate(); |
| 208 | const auto &cfg = m_agent->config(); |
| 209 | |
| 210 | const QString renderedContext = renderAgentContext(); |
| 211 | if (renderedContext.isEmpty()) |
| 212 | m_systemPrompt->clearLayer(QStringLiteral("agent.context")); |
| 213 | else |
| 214 | m_systemPrompt->setLayer(QStringLiteral("agent.context"), renderedContext); |
| 215 | |
| 216 | Templates::ContextData ctx = toLegacyContext(); |
| 217 | QJsonObject payload{{QStringLiteral("model"), cfg.model}}; |
| 218 | |
| 219 | const bool tools = toolsOverride.value_or(cfg.enableTools); |
| 220 | if (!provider->prepareRequest(payload, tmpl, ctx, tools, cfg.enableThinking)) |
| 221 | return {}; |
| 222 | |
| 223 | const auto id = provider->sendRequest(QUrl(provider->url()), payload, cfg.endpoint); |
| 224 | if (id.isEmpty()) |
| 225 | return {}; |
| 226 | |
| 227 | m_inFlight = id; |
| 228 | if (m_router) |
| 229 | m_router->beginRequest(id); |
| 230 | emit started(id); |
| 231 | return id; |
| 232 | } |
| 233 | |
| 234 | Templates::ContextData Session::toLegacyContext() const |
| 235 | { |
nothing calls this directly
no test coverage detected