#include "ctai_session_setting.h"

ctai_session_setting::ctai_session_setting(QWidget *parent)
    : QWidget(parent)
{
    initUI();
    setupConnections();
}

ctai_session_setting::~ctai_session_setting()
{
}

void ctai_session_setting::initUI()
{
    mainLayout = new QVBoxLayout(this);
    mainLayout->setSpacing(10);
    mainLayout->setContentsMargins(10, 10, 10, 10);

    // 创建标签和输入框
    labelModelName = new QLabel("Model Name:", this);
    labelFreqPenalty = new QLabel("Frequency Penalty:", this);
    labelMaxTokens = new QLabel("Max Tokens:", this);
    labelPresencePenalty = new QLabel("Presence Penalty:", this);
    labelTemperature = new QLabel("Temperature:", this);
    labelTopP = new QLabel("Top P:", this);

    editModelName = new QTextEdit(this);
    editFreqPenalty = new QTextEdit(this);
    editMaxTokens = new QTextEdit(this);
    editPresencePenalty = new QTextEdit(this);
    editTemperature = new QTextEdit(this);
    editTopP = new QTextEdit(this);

    // 设置输入框的固定高度
    QList<QTextEdit*> textEdits = {editModelName, editFreqPenalty, editMaxTokens,
                                  editPresencePenalty, editTemperature, editTopP};
    for(auto edit : textEdits) {
        edit->setFixedHeight(30);
    }

    // 创建水平布局并添加到主布局
    QList<QPair<QLabel*, QTextEdit*>> rows = {
        {labelModelName, editModelName},
        {labelFreqPenalty, editFreqPenalty},
        {labelMaxTokens, editMaxTokens},
        {labelPresencePenalty, editPresencePenalty},
        {labelTemperature, editTemperature},
        {labelTopP, editTopP}
    };

    for(const auto& row : rows) {
        QHBoxLayout* hLayout = new QHBoxLayout();
        hLayout->addWidget(row.first);
        hLayout->addWidget(row.second);
        mainLayout->addLayout(hLayout);
    }
}

void ctai_session_setting::setupConnections()
{
    // 在这里添加信号和槽的连接
}