You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
wqb-server/templates/feature_engineering.html

765 lines
22 KiB

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Feature Engineering Assistant - BRAIN</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<style>
.feature-engineering-container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.header-section {
text-align: center;
margin-bottom: 30px;
}
.header-section h1 {
color: #2c3e50;
margin-bottom: 10px;
}
.header-section p {
color: #7f8c8d;
font-size: 16px;
}
.back-button {
position: absolute;
top: 20px;
left: 20px;
background: #3498db;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
text-decoration: none;
display: inline-block;
transition: background-color 0.3s;
}
.back-button:hover {
background: #2980b9;
}
.config-section {
background: #f8f9fa;
padding: 20px;
border-radius: 8px;
margin-bottom: 20px;
}
.config-section h3 {
margin-top: 0;
color: #2c3e50;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #2c3e50;
}
.form-input {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
}
.form-input:focus {
outline: none;
border-color: #3498db;
box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}
.btn {
background: #3498db;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s;
}
.btn:hover {
background: #2980b9;
}
.btn-success {
background: #27ae60;
}
.btn-success:hover {
background: #229954;
}
.btn-secondary {
background: #95a5a6;
}
.btn-secondary:hover {
background: #7f8c8d;
}
.options-section {
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
.options-header {
background: #3498db;
color: white;
padding: 15px 20px;
border-radius: 8px 8px 0 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.options-container {
padding: 20px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
gap: 20px;
}
.option-card {
background: #f8f9fa;
border: 2px solid #e9ecef;
border-radius: 8px;
padding: 20px;
transition: all 0.3s ease;
cursor: pointer;
position: relative;
}
.option-card:hover {
border-color: #3498db;
box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}
.option-card.selected {
border-color: #27ae60;
background: #f1f8e9;
}
.option-card.editing {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
width: 80%;
max-width: 800px;
max-height: 80vh;
overflow-y: auto;
border-color: #f39c12;
background: #fef9e7;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 999;
display: none;
}
.modal-overlay.active {
display: block;
}
.option-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.option-number {
background: #3498db;
color: white;
padding: 5px 10px;
border-radius: 20px;
font-size: 12px;
font-weight: bold;
}
.option-actions {
display: flex;
gap: 10px;
}
.option-actions button {
padding: 5px 10px;
font-size: 12px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.edit-btn {
background: #f39c12;
color: white;
}
.save-btn {
background: #27ae60;
color: white;
}
.cancel-btn {
background: #95a5a6;
color: white;
}
.select-btn {
background: #3498db;
color: white;
}
.send-continue-btn {
background: #27ae60;
color: white;
margin-left: 10px;
}
.option-content {
line-height: 1.6;
}
.option-field {
margin-bottom: 10px;
}
.option-field label {
font-weight: bold;
color: #2c3e50;
display: block;
margin-bottom: 5px;
}
.option-field input,
.option-field textarea {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
}
.option-field textarea {
resize: vertical;
min-height: 80px;
overflow: hidden;
}
.option-card.editing .option-field textarea {
min-height: 120px;
overflow-y: auto;
}
.auto-resize-textarea {
overflow: hidden;
resize: none;
}
.option-field.readonly input,
.option-field.readonly textarea {
background: #f8f9fa;
border-color: #e9ecef;
}
.template-actions {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.pipeline-status {
background: #fff3cd;
border: 1px solid #ffeaa7;
border-radius: 4px;
padding: 15px;
margin-bottom: 20px;
}
.pipeline-status h4 {
margin-top: 0;
color: #856404;
}
.pipeline-step {
background: #f8f9fa;
border-left: 4px solid #3498db;
padding: 10px 15px;
margin-bottom: 10px;
border-radius: 0 4px 4px 0;
}
.pipeline-step strong {
color: #2c3e50;
}
.notification {
position: fixed;
top: 20px;
right: 20px;
padding: 15px 20px;
border-radius: 4px;
color: white;
font-weight: bold;
z-index: 1000;
animation: slideIn 0.3s ease-out;
}
.notification.success {
background: #27ae60;
}
.notification.error {
background: #e74c3c;
}
@keyframes slideIn {
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
.loading-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 1000;
}
.loading-spinner {
width: 50px;
height: 50px;
border: 5px solid #f3f3f3;
border-top: 5px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
}
.loading-message {
color: white;
margin-top: 20px;
font-size: 16px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.export-section {
background: #f8f9fa;
padding: 20px;
border-radius: 8px;
margin-top: 20px;
}
.export-section h3 {
margin-top: 0;
color: #2c3e50;
}
.category-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 10px;
margin-top: 15px;
}
.category-item {
background: #ecf0f1;
padding: 8px 12px;
border-radius: 4px;
font-size: 14px;
border-left: 4px solid #3498db;
}
.quick-actions {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.quick-actions button {
padding: 8px 16px;
font-size: 14px;
}
.empty-conversation {
text-align: center;
color: #7f8c8d;
padding: 40px;
font-style: italic;
}
/* 操作符参考模态框样式 */
.operator-category {
background: #f8f9fa;
border-radius: 8px;
margin-bottom: 20px;
border: 1px solid #e9ecef;
overflow: hidden;
}
.operator-category.hidden {
display: none;
}
.operator-category-header {
background: #3498db;
color: white;
padding: 15px 20px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
transition: background-color 0.3s;
}
.operator-category-header:hover {
background: #2980b9;
}
.operator-category-header h4 {
margin: 0;
font-size: 16px;
}
.operator-category-number {
background: rgba(255, 255, 255, 0.2);
padding: 4px 8px;
border-radius: 12px;
font-size: 12px;
font-weight: bold;
margin-right: 10px;
}
.operator-category-toggle {
font-size: 18px;
transition: transform 0.3s;
}
.operator-category-toggle.expanded {
transform: rotate(180deg);
}
.operator-category-content {
padding: 0;
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease-out;
}
.operator-category-content.expanded {
max-height: 500px;
padding: 20px;
}
.operator-description {
color: #2c3e50;
margin-bottom: 15px;
font-style: italic;
line-height: 1.5;
}
.operator-list {
background: white;
border-radius: 4px;
padding: 15px;
border: 1px solid #e9ecef;
}
.operator-list h5 {
margin: 0 0 10px 0;
color: #2c3e50;
font-size: 14px;
font-weight: bold;
}
.operators-grid {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.operator-tag {
background: #ecf0f1;
color: #2c3e50;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
font-family: monospace;
border: 1px solid #bdc3c7;
}
.operator-tag.highlight {
background: #fff3cd;
border-color: #ffeaa7;
color: #856404;
}
.no-results {
text-align: center;
color: #7f8c8d;
padding: 40px;
font-style: italic;
}
/* 可点击分类样式 */
.clickable-category {
color: #3498db;
cursor: pointer;
text-decoration: underline;
font-weight: bold;
}
.clickable-category:hover {
color: #2980b9;
background-color: #f8f9fa;
padding: 2px 4px;
border-radius: 3px;
}
/* 分类弹出提示框 */
.category-popup {
position: absolute;
background: white;
border: 2px solid #3498db;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
z-index: 1000;
max-width: 500px;
min-width: 300px;
padding: 0;
display: none;
}
.category-popup-header {
background: #3498db;
color: white;
padding: 10px 15px;
border-radius: 6px 6px 0 0;
font-weight: bold;
display: flex;
justify-content: space-between;
align-items: center;
}
.category-popup-close {
cursor: pointer;
font-size: 18px;
font-weight: bold;
}
.category-popup-content {
padding: 15px;
}
.category-popup-description {
color: #2c3e50;
margin-bottom: 15px;
font-style: italic;
line-height: 1.4;
}
.category-popup-operators {
background: #f8f9fa;
border-radius: 4px;
padding: 10px;
border: 1px solid #e9ecef;
}
.category-popup-operators h5 {
margin: 0 0 8px 0;
color: #2c3e50;
font-size: 13px;
}
.popup-operators-grid {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.popup-operator-tag {
background: #ecf0f1;
color: #2c3e50;
padding: 2px 6px;
border-radius: 3px;
font-size: 11px;
font-family: monospace;
border: 1px solid #bdc3c7;
}
.readonly-display {
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
background: #f8f9fa;
font-size: 14px;
min-height: 35px;
display: flex;
align-items: center;
}
</style>
</head>
<body>
<div class="feature-engineering-container">
<a href="{{ url_for('index') }}" class="back-button">← 返回主页面</a>
<div class="header-section">
<h1>数据字段指南</h1>
<p>获取AI驱动的多步骤数据字段探索建议</p>
</div>
<!-- API配置部分 -->
<div class="config-section">
<h3>API配置</h3>
<div class="form-group">
<label for="apiKey">Deepseek API密钥:</label>
<input type="password" id="apiKey" class="form-input" placeholder="输入您的Deepseek API密钥">
</div>
<button id="saveApiKey" class="btn">测试并保存API密钥</button>
</div>
<!-- 流水线状态部分 -->
<div class="pipeline-status" id="pipelineStatus" style="display: none;">
<h4>当前流水线状态</h4>
<div id="pipelineSteps">
<!-- 流水线步骤将显示在这里 -->
</div>
</div>
<!-- 初始设置部分 -->
<div class="config-section" id="initialSetup">
<h3>开始新的特征工程流水线</h3>
<div class="template-actions">
<button id="loadQuestionTemplate" class="btn btn-secondary">加载问题模板</button>
<button id="editSystemPrompt" class="btn btn-secondary">编辑系统提示</button>
<button id="startPipeline" class="btn btn-success">获取AI建议</button>
</div>
<div class="form-group">
<label for="questionTemplate">问题模板:</label>
<textarea id="questionTemplate" class="form-input" rows="6" placeholder="点击'加载问题模板'来加载模板"></textarea>
</div>
</div>
<!-- 选项卡片部分 -->
<div class="options-section" id="optionsSection" style="display: none;">
<div class="options-header">
<h3>AI建议</h3>
<div class="quick-actions">
<button id="clearOptions" class="btn btn-secondary">清除并重新开始</button>
<button id="exportPipeline" class="btn">导出流水线</button>
</div>
</div>
<div class="options-container" id="optionsContainer">
<!-- 选项卡片将动态插入到这里 -->
</div>
</div>
<!-- 编辑用模态覆盖层 -->
<div class="modal-overlay" id="modalOverlay"></div>
<!-- 分类弹出框 -->
<div class="category-popup" id="categoryPopup">
<div class="category-popup-header">
<span id="categoryPopupTitle"></span>
<span class="category-popup-close" onclick="hideCategoryPopup()">&times;</span>
</div>
<div class="category-popup-content">
<div class="category-popup-description" id="categoryPopupDescription"></div>
<div class="category-popup-operators">
<h5 id="categoryPopupOperatorsTitle"></h5>
<div class="popup-operators-grid" id="categoryPopupOperators"></div>
</div>
</div>
</div>
<!-- 系统提示编辑模态框 -->
<div class="modal-overlay" id="systemPromptModal" style="display: none;">
<div class="modal-content" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 80%; max-width: 900px; max-height: 80vh; background: white; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 1001;">
<div class="modal-header" style="background: #3498db; color: white; padding: 15px 20px; border-radius: 8px 8px 0 0; display: flex; justify-content: space-between; align-items: center;">
<h3>编辑系统提示</h3>
<span class="close" onclick="closeSystemPromptModal()" style="cursor: pointer; font-size: 24px;">&times;</span>
</div>
<div class="modal-body" style="padding: 20px; max-height: 60vh; overflow-y: auto;">
<div class="form-group">
<label for="systemPromptTextarea">系统提示:</label>
<textarea id="systemPromptTextarea" class="form-input" rows="20" placeholder="在此输入您的自定义系统提示..."></textarea>
</div>
<div class="prompt-actions" style="margin-top: 15px; display: flex; gap: 10px;">
<button id="loadDefaultPrompt" class="btn btn-outline">加载默认提示</button>
</div>
</div>
<div class="modal-footer" style="padding: 15px 20px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 10px;">
<button onclick="closeSystemPromptModal()" class="btn btn-outline">取消</button>
<button onclick="saveSystemPrompt()" class="btn btn-primary">保存并应用</button>
</div>
</div>
</div>
<!-- 导出部分 -->
<div class="export-section">
<h3>可用的特征工程类别</h3>
<p>AI助手可以从以下15个类别中推荐:</p>
<div class="category-list">
<div class="category-item">基础算术与数学运算</div>
<div class="category-item">逻辑与条件运算</div>
<div class="category-item">时间序列: 变化检测与值比较</div>
<div class="category-item">时间序列: 统计特征工程</div>
<div class="category-item">时间序列: 排名、缩放和归一化</div>
<div class="category-item">时间序列: 衰减、平滑和周转控制</div>
<div class="category-item">时间序列: 极值与位置识别</div>
<div class="category-item">横截面: 排名、缩放和归一化</div>
<div class="category-item">横截面: 回归与中性化</div>
<div class="category-item">横截面: 分布变换与截断</div>
<div class="category-item">变换与过滤操作</div>
<div class="category-item">分组聚合与统计摘要</div>
<div class="category-item">分组排名、缩放和归一化</div>
<div class="category-item">分组回归与中性化</div>
<div class="category-item">分组插值与回填</div>
</div>
</div>
</div>
<script src="{{ url_for('static', filename='feature_engineering.js') }}"></script>
</body>
</html>