更新类名字
This commit is contained in:
parent
089a0d6b81
commit
dcf90fe575
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -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
|
|
||||||
@ -281,13 +281,13 @@ void ctai_history_textedit::add_message(const model_data &message)
|
|||||||
m_tokens_data.total_tokens = "总消耗tokens:" + QSN(message.postback_total_tokens);
|
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_hit_tokens = "提示词缓存命中消耗tokens:" + QSN(message.postback_prompt_cache_hit_tokens);
|
||||||
m_tokens_data.cache_miss_tokens = "提示词缓存未命中消耗tokens:" + QSN(message.postback_prompt_cache_miss_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);
|
m_msg_sned_id = QSL(message.postback_send_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disp_header = "ID:" + QSL(message.send_user_id) + " | Time:" + QSL(message.send_user_time);
|
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_sned_id = QSL(message.send_user_id);
|
||||||
}
|
}
|
||||||
m_msg_header->setText(disp_header);
|
m_msg_header->setText(disp_header);
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <QAbstractTextDocumentLayout>
|
#include <QAbstractTextDocumentLayout>
|
||||||
#include "ctai_base.h"
|
#include "ctai_base.h"
|
||||||
#include "ctai_parsestring.h"
|
#include "ctai_markdown.h"
|
||||||
|
|
||||||
typedef struct tokens_args{
|
typedef struct tokens_args{
|
||||||
QString prompt_tokens={};
|
QString prompt_tokens={};
|
||||||
|
|||||||
@ -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编码的字符串
|
// 转换为UTF-8编码的字符串
|
||||||
QByteArray markdown = text.toUtf8();
|
QByteArray markdown = text.toUtf8();
|
||||||
|
|
||||||
// 使用cmark解析Markdown
|
// 使用cmark解析Markdown
|
||||||
char *html = cmark_markdown_to_html(
|
char *html = cmark_markdown_to_html(
|
||||||
markdown.constData(),
|
markdown.constData(),
|
||||||
@ -16,6 +15,7 @@ QString markdown_to_html(const QString& text) {
|
|||||||
// 转换回QString并处理代码块
|
// 转换回QString并处理代码块
|
||||||
QString result = QString::fromUtf8(html);
|
QString result = QString::fromUtf8(html);
|
||||||
free(html);
|
free(html);
|
||||||
|
qDebug()<<"处理的块:"<<result;
|
||||||
return process_code_blocks(result.toUtf8());
|
return process_code_blocks(result.toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,16 +1,19 @@
|
|||||||
#ifndef CTAI_PARSESTRING_H
|
#ifndef CTAI_MARKDOWN_H
|
||||||
#define CTAI_PARSESTRING_H
|
#define CTAI_MARKDOWN_H
|
||||||
|
|
||||||
#include <cmark.h>
|
#include <cmark.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
namespace ctai_parse {
|
namespace ctai_markdown {
|
||||||
// Markdown 转 HTML
|
// Markdown 转 HTML
|
||||||
QString markdown_to_html(const QString& text);
|
QString md_to_html(const QString& text);
|
||||||
// 纯文本转义
|
// 纯文本转义
|
||||||
QString escape_html(const QString& text);
|
QString escape_html(const QString& text);
|
||||||
// 处理代码块样式
|
// 处理代码块样式
|
||||||
QString process_code_blocks(QString html);
|
QString process_code_blocks(QString html);
|
||||||
|
|
||||||
|
void savePDF(QString fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CTAI_PARSESTRING_H
|
#endif // CTAI_PARSESTRING_H
|
||||||
Loading…
Reference in New Issue
Block a user