feat: implement AI schedule app with multi-device sync
- Qt 6 desktop client with day/month/year views, AI scheduling, and TOML settings\n- Go sync server with SQLite change stream, WebSocket notifications, and Docker deployment\n- Client outbox/LWW sync, offline retry, and dual-client integration tests\n- Linux fcitx5 setup, validation reports, and Windows MinGW preset
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QObject>
|
||||
|
||||
#include "ai/IAIProvider.h"
|
||||
|
||||
/*
|
||||
* 类名: OpenAiProvider
|
||||
* 功能: OpenAI 兼容 Chat Completions 流式实现(SSE)
|
||||
* 线程安全: 否;主线程使用
|
||||
*/
|
||||
class OpenAiProvider : public QObject, public ai::IAIProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenAiProvider(QObject* parent = nullptr);
|
||||
~OpenAiProvider() override;
|
||||
|
||||
QString name() const override;
|
||||
void streamCompletion(const AiConfig& config,
|
||||
const QJsonArray& messages,
|
||||
ai::CompletionCallbacks callbacks) override;
|
||||
void cancel() override;
|
||||
|
||||
private slots:
|
||||
void onReadyRead();
|
||||
void onFinished();
|
||||
void onNetworkError(QNetworkReply::NetworkError code);
|
||||
|
||||
private:
|
||||
void handleLine(const QByteArray& line);
|
||||
void handleSsePayload(const QByteArray& payload);
|
||||
void finishOk();
|
||||
void finishWithError(const QString& message);
|
||||
void cleanupReply();
|
||||
|
||||
QNetworkAccessManager m_manager;
|
||||
QNetworkReply* m_reply = nullptr;
|
||||
QByteArray m_buffer;
|
||||
QByteArray m_rawBody;
|
||||
ai::CompletionCallbacks m_callbacks;
|
||||
bool m_completed = false;
|
||||
bool m_parsedContent = false;
|
||||
bool m_sawDone = false;
|
||||
QString m_networkError;
|
||||
};
|
||||
Reference in New Issue
Block a user