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

Method GeminiReply

app/src/AI/Providers/GeminiReply.cpp:57–88  ·  view source on GitHub ↗

* @brief Issues the POST and wires SSE / network slots. */

Source from the content-addressed store, hash-verified

55 * @brief Issues the POST and wires SSE / network slots.
56 */
57AI::GeminiReply::GeminiReply(QNetworkAccessManager& nam,
58 const QUrl& endpoint,
59 const QString& apiKey,
60 const QByteArray& requestBody,
61 QObject* parent)
62 : Reply(parent)
63 , m_nam(nam)
64 , m_apiKey(apiKey)
65 , m_requestBody(requestBody)
66 , m_reply(nullptr)
67 , m_sse(new SseEventReader(this))
68 , m_finished(false)
69{
70 connect(m_sse, &SseEventReader::frameReceived, this, &GeminiReply::onSseEvent);
71 connect(m_sse, &SseEventReader::parseError, this, &GeminiReply::onSseError);
72
73 QNetworkRequest req(endpoint);
74 req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/json"));
75 req.setRawHeader("x-goog-api-key", apiKey.toUtf8());
76 req.setRawHeader("accept", "text/event-stream");
77 req.setTransferTimeout(kInitialResponseTimeoutMs);
78
79 qCDebug(serialStudioAI) << "POST gemini url=" << redactUrl(endpoint)
80 << "key=" << KeyVault::redact(apiKey)
81 << "body_bytes=" << requestBody.size();
82
83 m_reply = m_nam.post(req, requestBody);
84 m_reply->setParent(this);
85
86 connect(m_reply, &QNetworkReply::readyRead, this, &GeminiReply::onReplyReadyRead);
87 connect(m_reply, &QNetworkReply::finished, this, &GeminiReply::onReplyFinished);
88}
89
90//--------------------------------------------------------------------------------------------------
91// Public API

Callers

nothing calls this directly

Calls 3

redactUrlFunction · 0.85
sizeMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected