From 982b11b396f5b57ca85ea70e24630adb597fd42d Mon Sep 17 00:00:00 2001 From: JackLee <809262979@qq.com> Date: Tue, 4 Mar 2025 22:39:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=87=AA=E9=80=82=E5=BA=94BU?= =?UTF-8?q?G?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ctai_base.h | 12 ++++++------ src/ctai_history_textedit.cpp | 6 +----- src/ctai_history_widget.cpp | 15 ++++++++++----- src/ctai_session_info.cpp | 6 +++--- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/ctai_base.h b/src/ctai_base.h index 0f37107..9950ce2 100644 --- a/src/ctai_base.h +++ b/src/ctai_base.h @@ -27,12 +27,12 @@ typedef struct curl_opts } curl_opts; typedef struct model_data{ - //std::string api_url = "https://api.deepseek.com/chat/completions"; - //std::string api_key = "Authorization: Bearer sk-7e6932ed45674c389dea1cd3481e0ec2"; - //std::string user_model = "deepseek-chat"; - std::string api_url="https://api.siliconflow.cn/v1/chat/completions"; - std::string api_key="Authorization: Bearer sk-oiphigpzqtmkkcoucyakrfevcvndroywvxhprvscjqhdykdb"; - std::string user_model = "deepseek-ai/DeepSeek-V3"; + std::string api_url = "https://api.deepseek.com/chat/completions"; + std::string api_key = "Authorization: Bearer sk-7e6932ed45674c389dea1cd3481e0ec2"; + std::string user_model = "deepseek-chat"; + //std::string api_url="https://api.siliconflow.cn/v1/chat/completions"; + //std::string api_key="Authorization: Bearer sk-oiphigpzqtmkkcoucyakrfevcvndroywvxhprvscjqhdykdb"; + //std::string user_model = "deepseek-ai/DeepSeek-V3"; std::string send_content_header = "Content-Type: application/json"; std::string send_accept_header = "Accept: application/json"; std::string send_user_data; diff --git a/src/ctai_history_textedit.cpp b/src/ctai_history_textedit.cpp index e82de18..ae494a1 100644 --- a/src/ctai_history_textedit.cpp +++ b/src/ctai_history_textedit.cpp @@ -230,15 +230,11 @@ void ctai_history_textedit::on_text_height() static const int HEIGHT_THRESHOLD = 5; // 5像素的阈值 if (abs(m_msg_history->height() - newHeight) > HEIGHT_THRESHOLD) { - m_original_height = newHeight+15; - - // 批量更新布局 + m_original_height = newHeight; bool wasBlocked = m_msg_history->signalsBlocked(); m_msg_history->blockSignals(true); - m_msg_history->setFixedHeight(newHeight); updateGeometry(); - m_msg_history->blockSignals(wasBlocked); emit current_row_height_changed(); diff --git a/src/ctai_history_widget.cpp b/src/ctai_history_widget.cpp index 9915ccc..2a687a4 100644 --- a/src/ctai_history_widget.cpp +++ b/src/ctai_history_widget.cpp @@ -17,7 +17,7 @@ void ctai_history_widget::setup_table() // 设置自动滚动属性 setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); // 滚动步长 - verticalScrollBar()->setSingleStep(10); + verticalScrollBar()->setSingleStep(5); } ctai_history_widget::~ctai_history_widget() @@ -108,7 +108,7 @@ void ctai_history_widget::add_message(const model_data &message) void ctai_history_widget::on_rows_height_changed() { //全部行高自适应 - for (int row = 0; row < rowCount(); ++row) { + for (int row = 0; row < rowCount()-1; ++row) { resizeRowToContents(row); } scrollToBottom(); @@ -116,9 +116,14 @@ void ctai_history_widget::on_rows_height_changed() //适合自适应流式输出内容 void ctai_history_widget::on_current_rows_height_changed() { - // 当前行高自适应 - resizeRowToContents(rowCount()); - scrollToBottom(); + int row = rowCount()-1; + if (row >= 0 && row < rowCount()) { + int currentHeight = rowHeight(row); + setRowHeight(row, currentHeight + 100); + resizeRowToContents(row); + } + //resizeRowToContents(rowCount()-1); + //scrollToBottom(); } void ctai_history_widget::on_msg_remove(QString send_id) { diff --git a/src/ctai_session_info.cpp b/src/ctai_session_info.cpp index ef7599d..da4f83f 100644 --- a/src/ctai_session_info.cpp +++ b/src/ctai_session_info.cpp @@ -136,9 +136,9 @@ void ctai_session_info::ctai_session_postback_info(model_data resp_data) } if (QSL(resp_data.postback_model_data).contains("[DONE]")) { - current_info_id = {}; - btn_disable_enable(true); - } + current_info_id = {}; + } + btn_disable_enable(true); ctai_session_curl_state_tips(""); } void ctai_session_info::ctai_session_curl_state_tips(std::string state_str)