feat(chat,todo): 小埃同学对话窗口与待办窗口
Chat: - DTK2 窗口:左侧会话列表 + 右侧对话区 + 输入框 - DeepSeek / 自定义 API,SSE 流式输出,首字即显示 - 会话持久化到 chat.json,新建/切换/标题自动生成 - 设置对话框:API Key、API 地址、模型、系统提示,含开通指引 - 拖放:左侧空白=新建对话,左侧会话=指定会话,右侧对话区=当前会话 - Ctrl+Enter 发送,错误以消息形式回显 Todo: - 待办窗口(layer-shell,不抢焦点、不进 dock),复选框/删除/新建 - 待办持久化 todo.json,--todo 打开,独立 desktop 入口 其他: - desktop 入口改为打开对话窗口,--chat 参数 - 单实例消息支持 show/todo/chat
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// SPDX-FileCopyrightText: 2026 GXDE OS Team
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
struct ChatMessage
|
||||
{
|
||||
QString role; // system / user / assistant
|
||||
QString content;
|
||||
};
|
||||
|
||||
/**
|
||||
* Minimal streaming client for the DeepSeek (OpenAI compatible) chat API.
|
||||
*/
|
||||
class ChatClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChatClient(QObject *parent = nullptr);
|
||||
|
||||
bool busy() const { return m_reply != nullptr; }
|
||||
void send(const QVector<ChatMessage> &messages);
|
||||
void cancel();
|
||||
|
||||
signals:
|
||||
void delta(const QString &text);
|
||||
void finished(const QString &text);
|
||||
void failed(const QString &error);
|
||||
|
||||
private:
|
||||
void handleReadyRead();
|
||||
void handleFinished();
|
||||
void handlePayload(const QByteArray &payload);
|
||||
|
||||
QNetworkAccessManager m_manager;
|
||||
class QNetworkReply *m_reply = nullptr;
|
||||
QByteArray m_buffer;
|
||||
QString m_fullText;
|
||||
bool m_done = false;
|
||||
};
|
||||
Reference in New Issue
Block a user