feat: add energy-aware scheduling and daily insights
- Learn a per-device 7x24 energy profile from completed tasks\n- Constrain high-energy scheduling and expose energy peaks to AI\n- Add ghost-time overlays, daily review dialog, and proactive suggestions\n- Cover energy/insights logic and local OpenAI-compatible providers with tests\n- Update validation docs and screenshots
This commit is contained in:
@@ -47,6 +47,7 @@ class TestOpenAiProvider : public QObject
|
||||
|
||||
private slots:
|
||||
void streamsSseContent();
|
||||
void streamsLocalWithoutApiKey();
|
||||
void reportsHttpError();
|
||||
};
|
||||
|
||||
@@ -92,6 +93,45 @@ void TestOpenAiProvider::streamsSseContent()
|
||||
QCOMPARE(text, QStringLiteral("你好,世界"));
|
||||
}
|
||||
|
||||
void TestOpenAiProvider::streamsLocalWithoutApiKey()
|
||||
{
|
||||
FakeSseServer server;
|
||||
QVERIFY(server.listen(QHostAddress::LocalHost, 0));
|
||||
server.response =
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Content-Type: text/event-stream\r\n"
|
||||
"Connection: close\r\n"
|
||||
"\r\n"
|
||||
"data: {\"choices\":[{\"delta\":{\"content\":\"local\"}}]}\n\n"
|
||||
"data: [DONE]\n\n";
|
||||
|
||||
AiConfig config;
|
||||
config.baseUrl = QStringLiteral("http://127.0.0.1:%1/v1").arg(server.serverPort());
|
||||
config.model = QStringLiteral("local-model");
|
||||
|
||||
QJsonArray messages;
|
||||
QJsonObject message;
|
||||
message.insert(QStringLiteral("role"), QStringLiteral("user"));
|
||||
message.insert(QStringLiteral("content"), QStringLiteral("hi"));
|
||||
messages.append(message);
|
||||
|
||||
OpenAiProvider provider;
|
||||
QString text;
|
||||
QString error;
|
||||
bool finished = false;
|
||||
provider.streamCompletion(
|
||||
config,
|
||||
messages,
|
||||
{
|
||||
[&text](const QString& delta) { text += delta; },
|
||||
[&error](const QString& message) { error = message; },
|
||||
[&finished]() { finished = true; },
|
||||
});
|
||||
QTRY_VERIFY_WITH_TIMEOUT(finished, 5000);
|
||||
QCOMPARE(error, QString());
|
||||
QCOMPARE(text, QStringLiteral("local"));
|
||||
}
|
||||
|
||||
void TestOpenAiProvider::reportsHttpError()
|
||||
{
|
||||
FakeSseServer server;
|
||||
|
||||
Reference in New Issue
Block a user