Commit 216ea4ea authored by StyleZhang's avatar StyleZhang

update segment verify params

parent 281f1133
...@@ -101,7 +101,7 @@ export const SegmentDetail: FC<ISegmentDetailProps> = memo(({ ...@@ -101,7 +101,7 @@ export const SegmentDetail: FC<ISegmentDetailProps> = memo(({
<AutoHeightTextarea <AutoHeightTextarea
className='leading-6 text-md text-gray-800' className='leading-6 text-md text-gray-800'
value={question} value={question}
placeholder={t('datasetDocuments.segment.questionPlaceholder') || ''} placeholder={t('datasetDocuments.segment.contentPlaceholder') || ''}
onChange={e => setQuestion(e.target.value)} onChange={e => setQuestion(e.target.value)}
disabled={!isEditing} disabled={!isEditing}
autoFocus autoFocus
...@@ -262,9 +262,22 @@ const Completed: FC<ICompletedProps> = () => { ...@@ -262,9 +262,22 @@ const Completed: FC<ICompletedProps> = () => {
} }
const handleUpdateSegment = async (segmentId: string, question: string, answer: string) => { const handleUpdateSegment = async (segmentId: string, question: string, answer: string) => {
const params: SegmentUpdator = { content: question } const params: SegmentUpdator = { content: '' }
if (docForm === 'qa_model') if (docForm === 'qa_model') {
if (!question.trim())
return notify({ type: 'error', message: t('datasetDocuments.segment.questionEmpty') })
if (!answer.trim())
return notify({ type: 'error', message: t('datasetDocuments.segment.answerEmpty') })
params.content = question
params.answer = answer params.answer = answer
}
else {
if (!question.trim())
return notify({ type: 'error', message: t('datasetDocuments.segment.contentEmpty') })
params.content = question
}
const res = await updateSegment({ datasetId, documentId, segmentId, body: params }) const res = await updateSegment({ datasetId, documentId, segmentId, body: params })
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
......
...@@ -311,7 +311,11 @@ const translation = { ...@@ -311,7 +311,11 @@ const translation = {
hitCount: 'hit count', hitCount: 'hit count',
vectorHash: 'Vector hash: ', vectorHash: 'Vector hash: ',
questionPlaceholder: 'add question here', questionPlaceholder: 'add question here',
questionEmpty: 'Question can not be empty',
answerPlaceholder: 'add answer here', answerPlaceholder: 'add answer here',
answerEmpty: 'Answer can not be empty',
contentPlaceholder: 'add content here',
contentEmpty: 'Content can not be empty',
}, },
} }
......
...@@ -310,7 +310,11 @@ const translation = { ...@@ -310,7 +310,11 @@ const translation = {
hitCount: '命中次数', hitCount: '命中次数',
vectorHash: '向量哈希:', vectorHash: '向量哈希:',
questionPlaceholder: '在这里添加问题', questionPlaceholder: '在这里添加问题',
questionEmpty: '问题不能为空',
answerPlaceholder: '在这里添加答案', answerPlaceholder: '在这里添加答案',
answerEmpty: '答案不能为空',
contentPlaceholder: '在这里添加内容',
contentEmpty: '内容不能为空',
}, },
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment