feat(data-process): 支持思维链输出类型
This commit is contained in:
@@ -195,13 +195,13 @@ function toBackendConfig(): DataProcessConfig {
|
||||
const options = processType.value === 'unstructured'
|
||||
? unstructuredOptions.value
|
||||
: structuredOptions.value
|
||||
|
||||
const common = {
|
||||
preprocess_options: [...options.preprocessOptions],
|
||||
semantic_enrichment: options.semanticEnrichment,
|
||||
dataset_split: { ...options.datasetSplit },
|
||||
generation_model_id: options.generationModelId,
|
||||
generation_prompt: options.generationPrompt,
|
||||
output_type: options.outputType,
|
||||
temperature: options.temperature,
|
||||
max_tokens: options.maxTokens,
|
||||
json_mode: options.jsonMode,
|
||||
|
||||
@@ -70,6 +70,7 @@ const configLabelMap: Record<string, string> = {
|
||||
dataset_split: '数据集划分',
|
||||
generation_model_id: '数据生成模型',
|
||||
generation_prompt: '生成提示语',
|
||||
output_type: '输出类型',
|
||||
temperature: '生成温度',
|
||||
max_tokens: '最大输出长度',
|
||||
json_mode: 'JSON 输出',
|
||||
@@ -245,6 +246,9 @@ function formatConfigValue(key: string, value: unknown) {
|
||||
if (key === 'chunk_method' && typeof value === 'string') {
|
||||
return chunkMethodLabelMap[value] || value
|
||||
}
|
||||
if (key === 'output_type') {
|
||||
return value === 'reasoning' ? '思维链回答' : '标准回答'
|
||||
}
|
||||
if (key === 'dataset_split' && value && typeof value === 'object') {
|
||||
const split = value as Partial<DataProcessDatasetSplit>
|
||||
return `训练集 ${split.train ?? 0}% / 验证集 ${split.validation ?? 0}% / 测试集 ${split.test ?? 0}%`
|
||||
|
||||
@@ -30,6 +30,10 @@ function updateQualityRules(value: Array<string | number>) {
|
||||
})
|
||||
}
|
||||
|
||||
function updateOutputType(value: string | number | boolean | undefined) {
|
||||
updateField('outputType', value === 'reasoning' ? 'reasoning' : 'standard')
|
||||
}
|
||||
|
||||
const selectedQualityRules = () => [
|
||||
props.options.filterLowQuality ? 'low_quality' : '',
|
||||
props.options.filterShortContent ? 'short_content' : '',
|
||||
@@ -106,6 +110,28 @@ function modelMeta(model: ModelItem) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="model-field output-type-field">
|
||||
<div class="field-copy">
|
||||
<strong>输出类型</strong>
|
||||
<small>控制答案是否包含可用于推理模型训练的思维链内容</small>
|
||||
</div>
|
||||
<el-radio-group
|
||||
class="output-type-options"
|
||||
:model-value="options.outputType"
|
||||
aria-label="输出类型"
|
||||
@update:model-value="updateOutputType"
|
||||
>
|
||||
<el-radio-button value="standard">标准回答</el-radio-button>
|
||||
<el-radio-button value="reasoning">思维链回答</el-radio-button>
|
||||
</el-radio-group>
|
||||
<p class="output-type-hint">
|
||||
<template v-if="options.outputType === 'reasoning'">
|
||||
生成结果将按 <code><think>推理过程</think></code> 加最终答案的格式保存。
|
||||
</template>
|
||||
<template v-else>仅保存最终答案,不包含推理过程。</template>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="advanced-settings-grid">
|
||||
<label class="config-field">
|
||||
<span class="config-field-label">生成温度 (Temperature)</span>
|
||||
@@ -304,6 +330,31 @@ function modelMeta(model: ModelItem) {
|
||||
}
|
||||
}
|
||||
|
||||
.output-type-options {
|
||||
align-self: flex-start;
|
||||
|
||||
:deep(.el-radio-button__inner) {
|
||||
min-height: 44px;
|
||||
padding: 13px 22px;
|
||||
}
|
||||
}
|
||||
|
||||
.output-type-hint {
|
||||
min-height: 20px;
|
||||
margin: 0;
|
||||
color: #667085;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
|
||||
code {
|
||||
padding: 2px 5px;
|
||||
color: #5b50f2;
|
||||
background: #f0f0ff;
|
||||
border-radius: 4px;
|
||||
font-family: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
.advanced-settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
} from './types'
|
||||
import { normalizeQaPairsGenerationCount } from './types'
|
||||
|
||||
export const DEFAULT_GENERATION_PROMPT = '你是一名专业的数据生成助手。请根据输入内容生成准确、完整、可直接用于模型训练的问答数据。仅输出符合目标格式的内容,答案应事实清晰、语言自然,不要添加分析过程、说明或无关内容。'
|
||||
export const DEFAULT_GENERATION_PROMPT = '你是一名专业的数据生成助手。请根据输入内容生成准确、完整、可直接用于模型训练的问答数据。仅输出符合所选输出类型和目标格式的内容,答案应事实清晰、语言自然,不要添加无关说明。'
|
||||
|
||||
export function createDefaultStructuredOptions(): StructuredProcessOptions {
|
||||
return {
|
||||
@@ -19,6 +19,7 @@ export function createDefaultStructuredOptions(): StructuredProcessOptions {
|
||||
datasetSplit: { train: 80, validation: 10, test: 10 },
|
||||
generationModelId: '',
|
||||
generationPrompt: DEFAULT_GENERATION_PROMPT,
|
||||
outputType: 'standard',
|
||||
temperature: 0.7,
|
||||
maxTokens: 1024,
|
||||
jsonMode: false,
|
||||
@@ -52,6 +53,7 @@ export function createDefaultUnstructuredOptions(): UnstructuredProcessOptions {
|
||||
datasetSplit: { train: 80, validation: 10, test: 10 },
|
||||
generationModelId: '',
|
||||
generationPrompt: DEFAULT_GENERATION_PROMPT,
|
||||
outputType: 'standard',
|
||||
temperature: 0.7,
|
||||
maxTokens: 1024,
|
||||
jsonMode: false,
|
||||
@@ -93,6 +95,9 @@ function generationOptionsFromConfig(
|
||||
return {
|
||||
generationModelId: configValue(config, 'generation_model_id', defaults.generationModelId),
|
||||
generationPrompt: String(configValue(config, 'generation_prompt', defaults.generationPrompt)),
|
||||
outputType: configValue(config, 'output_type', defaults.outputType) === 'reasoning'
|
||||
? 'reasoning'
|
||||
: 'standard',
|
||||
temperature: numberValue(config, 'temperature', defaults.temperature),
|
||||
maxTokens: numberValue(config, 'max_tokens', defaults.maxTokens),
|
||||
jsonMode: Boolean(configValue(config, 'json_mode', defaults.jsonMode)),
|
||||
@@ -218,6 +223,7 @@ export function generationAffectingOptionsFor(
|
||||
datasetSplit: options.datasetSplit,
|
||||
generationModelId: options.generationModelId,
|
||||
generationPrompt: options.generationPrompt,
|
||||
outputType: options.outputType,
|
||||
temperature: options.temperature,
|
||||
maxTokens: options.maxTokens,
|
||||
jsonMode: options.jsonMode,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { DataProcessPreviewFileStatus } from '@/types/dataProcess'
|
||||
import type { DataProcessOutputType, DataProcessPreviewFileStatus } from '@/types/dataProcess'
|
||||
|
||||
export type ProcessType = 'structured' | 'unstructured' | 'external'
|
||||
|
||||
@@ -32,6 +32,7 @@ export interface DatasetSplitOptions {
|
||||
export interface GenerationControlOptions {
|
||||
generationModelId: string | number | ''
|
||||
generationPrompt: string
|
||||
outputType: DataProcessOutputType
|
||||
temperature: number
|
||||
maxTokens: number
|
||||
jsonMode: boolean
|
||||
|
||||
Reference in New Issue
Block a user