updata部分文件
This commit is contained in:
parent
3c3d360b55
commit
81ea49de8d
@ -61,13 +61,11 @@ include_directories(${JSON}/include)
|
||||
#CURL
|
||||
find_package(CURL REQUIRED)
|
||||
|
||||
#cmark
|
||||
#find_package(cmark CONFIG REQUIRED)
|
||||
|
||||
#cmark-gfm
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/cmark-gfm)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmark-gfm/src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmark-gfm/extensions)
|
||||
|
||||
#MicroTeX
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/MicroTeX)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/MicroTeX/lib)
|
||||
@ -85,7 +83,6 @@ MESSAGE(STATUS "----------基础路径输出 END---------------")
|
||||
|
||||
#增加sui的cpp
|
||||
FILE(GLOB src_sui "${PROJECT_SOURCE_DIR}/src/*.*")
|
||||
|
||||
SET(PROJECT_SOURCES ${src_sui})
|
||||
|
||||
# 设置消息策略为qFatal来禁用qDebug信息
|
||||
@ -151,7 +148,6 @@ target_link_libraries(
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
CURL::libcurl
|
||||
#cmark::cmark
|
||||
libcmark-gfm-extensions_static
|
||||
libcmark-gfm_static
|
||||
microtex
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
#include "ctai_cmark_gfm.h"
|
||||
|
||||
ctai_cmark_gfm::ctai_cmark_gfm(QTextEdit *textEdit)
|
||||
: m_textEdit(textEdit), m_buffer()
|
||||
{
|
||||
}
|
||||
|
||||
ctai_cmark_gfm::~ctai_cmark_gfm()
|
||||
ctai_cmark_gfm::ctai_cmark_gfm(QTextEdit* textEdit)
|
||||
: m_textEdit(textEdit)
|
||||
, m_cursor(textEdit->document())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ctai_cmark_gfm::appendMarkdown(const QString &markdown)
|
||||
{
|
||||
|
||||
ctai_cmark_gfm::~ctai_cmark_gfm() {
|
||||
}
|
||||
|
||||
void ctai_cmark_gfm::appendMarkdown(const QString& text) {
|
||||
|
||||
}
|
||||
@ -6,6 +6,8 @@
|
||||
#include "cmark-gfm-core-extensions.h"
|
||||
#include <QString>
|
||||
#include <QTextEdit>
|
||||
#include <QTextCursor>
|
||||
#include <QTextCharFormat>
|
||||
|
||||
class ctai_cmark_gfm {
|
||||
public:
|
||||
@ -14,11 +16,9 @@ public:
|
||||
|
||||
// 追加内容并处理Markdown
|
||||
void appendMarkdown(const QString& text);
|
||||
|
||||
private:
|
||||
static constexpr size_t BUFFER_SIZE = 4096;
|
||||
QTextEdit* m_textEdit;
|
||||
QString m_buffer;
|
||||
QTextCursor m_cursor;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -90,8 +90,7 @@ void ctai_history_textedit::init_layout(msg_type msg_type_mode)
|
||||
hLine->setLineWidth(2); // 线宽
|
||||
// 5. 历史信息QTextEdit
|
||||
historyLayout = new QVBoxLayout();
|
||||
m_msg_history = new QTextEdit();
|
||||
m_cmark_gfm=new ctai_cmark_gfm(m_msg_history);
|
||||
m_msg_history = new QTextBrowser();
|
||||
m_msg_history->setAcceptRichText(true);
|
||||
m_msg_history->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_msg_history->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
@ -258,7 +257,7 @@ void ctai_history_textedit::add_user_message(const model_data &message)
|
||||
QString disp_data;
|
||||
disp_data = QSL(message.send_user_data);
|
||||
m_msg_sned_id = QSL(message.send_user_id);
|
||||
m_msg_history->setHtml(disp_data);
|
||||
m_msg_history->setMarkdown(disp_data);
|
||||
}
|
||||
|
||||
void ctai_history_textedit::add_system_message(const model_data &message)
|
||||
@ -271,13 +270,13 @@ void ctai_history_textedit::add_system_message(const model_data &message)
|
||||
{
|
||||
// 流式模式下追加内容
|
||||
m_current_content += message.postback_model_data;
|
||||
m_cmark_gfm->appendMarkdown(QSL(message.postback_model_data));
|
||||
m_msg_history->setMarkdown(m_current_content);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 非流式模式直接设置全部内容
|
||||
disp_data = QSL(message.postback_model_data);
|
||||
m_msg_history->setHtml(disp_data);
|
||||
m_msg_history->setMarkdown(disp_data);
|
||||
m_current_content = QSL(message.postback_model_data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
// Qt控件相关
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QTextBrowser>
|
||||
#include <QLineEdit>
|
||||
#include <QFrame>
|
||||
#include <QMenu>
|
||||
@ -79,19 +80,19 @@ private:
|
||||
QVBoxLayout *historyLayout={};
|
||||
QHBoxLayout *header_opts_Layout={};
|
||||
|
||||
QPushButton *m_msg_system_header_ico={};
|
||||
QPushButton *m_msg_user_header_ico={};
|
||||
QLineEdit *m_msg_header={};
|
||||
QTextEdit *m_msg_history={};
|
||||
QPushButton *m_msg_user_del={};
|
||||
QPushButton *m_msg_system_del={};
|
||||
QPushButton *m_msg_copy={};
|
||||
QPushButton *m_msg_save={};
|
||||
QPushButton *m_msg_menu={};
|
||||
QPushButton *m_msg_fold={}; // 折叠按钮
|
||||
QPushButton *m_msg_tokens={};
|
||||
QPushButton *m_history_to_send={};
|
||||
QPushButton *m_restart_to_send={};
|
||||
QPushButton *m_msg_system_header_ico={};
|
||||
QPushButton *m_msg_user_header_ico={};
|
||||
QLineEdit *m_msg_header={};
|
||||
QTextBrowser *m_msg_history={};
|
||||
QPushButton *m_msg_user_del={};
|
||||
QPushButton *m_msg_system_del={};
|
||||
QPushButton *m_msg_copy={};
|
||||
QPushButton *m_msg_save={};
|
||||
QPushButton *m_msg_menu={};
|
||||
QPushButton *m_msg_fold={}; // 折叠按钮
|
||||
QPushButton *m_msg_tokens={};
|
||||
QPushButton *m_history_to_send={};
|
||||
QPushButton *m_restart_to_send={};
|
||||
//tokens消耗显示
|
||||
QMenu *m_msg_tokens_menu={};
|
||||
QAction *m_menu_prompt_tokens={};
|
||||
|
||||
@ -48,7 +48,8 @@ void ctai_session_info::init_sub_layout()
|
||||
m_sub_systeam_widget->setLayout(m_session_systeam_info_layout);
|
||||
|
||||
m_session_user_group_layout = new QVBoxLayout();
|
||||
m_session_user_edit_info = new QTextEdit(tr("1+1为什么等于2"));
|
||||
m_session_user_edit_info = new QTextEdit();
|
||||
m_session_user_edit_info->setPlaceholderText(tr("请输入内容"));
|
||||
m_session_user_edit_layout = new QVBoxLayout();
|
||||
m_session_user_edit_layout->addWidget(m_session_user_edit_info);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user