更新类名字

This commit is contained in:
JackLee 2025-03-03 21:26:54 +08:00
parent 089a0d6b81
commit dcf90fe575
5 changed files with 16 additions and 19 deletions

6
.gitmodules vendored
View File

@ -1,6 +0,0 @@
[submodule "3rdparty/cmark-gfm"]
path = 3rdparty/cmark-gfm
url = https://github.com/github/cmark-gfm.git
[submodule "3rdparty/md4qt"]
path = 3rdparty/md4qt
url = https://github.com/igormironchik/md4qt.git

View File

@ -281,16 +281,16 @@ void ctai_history_textedit::add_message(const model_data &message)
m_tokens_data.total_tokens = "总消耗tokens:" + QSN(message.postback_total_tokens);
m_tokens_data.cache_hit_tokens = "提示词缓存命中消耗tokens:" + QSN(message.postback_prompt_cache_hit_tokens);
m_tokens_data.cache_miss_tokens = "提示词缓存未命中消耗tokens:" + QSN(message.postback_prompt_cache_miss_tokens);
disp_data = ctai_parse::markdown_to_html(QSL(message.postback_model_data));
disp_data =ctai_markdown::md_to_html(QSL(message.postback_model_data));
m_msg_sned_id = QSL(message.postback_send_id);
}
else
{
disp_header = "ID:" + QSL(message.send_user_id) + " | Time:" + QSL(message.send_user_time);
disp_data = ctai_parse::markdown_to_html(QSL(message.send_user_data));
disp_data = ctai_markdown::md_to_html(QSL(message.send_user_data));
m_msg_sned_id = QSL(message.send_user_id);
}
m_msg_header->setText(disp_header);
m_msg_header->setText(disp_header);
m_msg_history->setHtml(disp_data);
}
void ctai_history_textedit::on_delete_clicked()

View File

@ -21,7 +21,7 @@
#include <mutex>
#include <QAbstractTextDocumentLayout>
#include "ctai_base.h"
#include "ctai_parsestring.h"
#include "ctai_markdown.h"
typedef struct tokens_args{
QString prompt_tokens={};

View File

@ -1,11 +1,10 @@
#include "ctai_parsestring.h"
#include "ctai_markdown.h"
namespace ctai_parse {
namespace ctai_markdown {
QString markdown_to_html(const QString& text) {
QString md_to_html(const QString& text) {
// 转换为UTF-8编码的字符串
QByteArray markdown = text.toUtf8();
QByteArray markdown = text.toUtf8();
// 使用cmark解析Markdown
char *html = cmark_markdown_to_html(
markdown.constData(),
@ -16,6 +15,7 @@ QString markdown_to_html(const QString& text) {
// 转换回QString并处理代码块
QString result = QString::fromUtf8(html);
free(html);
qDebug()<<"处理的块:"<<result;
return process_code_blocks(result.toUtf8());
}

View File

@ -1,16 +1,19 @@
#ifndef CTAI_PARSESTRING_H
#define CTAI_PARSESTRING_H
#ifndef CTAI_MARKDOWN_H
#define CTAI_MARKDOWN_H
#include <cmark.h>
#include <QString>
#include <QDebug>
namespace ctai_parse {
namespace ctai_markdown {
// Markdown 转 HTML
QString markdown_to_html(const QString& text);
QString md_to_html(const QString& text);
// 纯文本转义
QString escape_html(const QString& text);
// 处理代码块样式
QString process_code_blocks(QString html);
void savePDF(QString fileName);
}
#endif // CTAI_PARSESTRING_H