mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-09 07:16:04 +00:00
Merge pull request #1606 from langbot-app/feat/topk_splitter
Feat/topk splitter
This commit is contained in:
@@ -3,6 +3,7 @@ export interface IKnowledgeBaseVO {
|
||||
name: string;
|
||||
description: string;
|
||||
embeddingModelUUID: string;
|
||||
top_k: number;
|
||||
lastUpdatedTimeAgo: string;
|
||||
}
|
||||
|
||||
@@ -11,6 +12,7 @@ export class KnowledgeBaseVO implements IKnowledgeBaseVO {
|
||||
name: string;
|
||||
description: string;
|
||||
embeddingModelUUID: string;
|
||||
top_k: number;
|
||||
lastUpdatedTimeAgo: string;
|
||||
|
||||
constructor(props: IKnowledgeBaseVO) {
|
||||
@@ -18,6 +20,7 @@ export class KnowledgeBaseVO implements IKnowledgeBaseVO {
|
||||
this.name = props.name;
|
||||
this.description = props.description;
|
||||
this.embeddingModelUUID = props.embeddingModelUUID;
|
||||
this.top_k = props.top_k;
|
||||
this.lastUpdatedTimeAgo = props.lastUpdatedTimeAgo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,10 @@ const getFormSchema = (t: (key: string) => string) =>
|
||||
embeddingModelUUID: z
|
||||
.string()
|
||||
.min(1, { message: t('knowledge.embeddingModelUUIDRequired') }),
|
||||
top_k: z
|
||||
.number()
|
||||
.min(1, { message: t('knowledge.topKRequired') })
|
||||
.max(30, { message: t('knowledge.topKMax') }),
|
||||
});
|
||||
|
||||
export default function KBForm({
|
||||
@@ -55,6 +59,7 @@ export default function KBForm({
|
||||
name: '',
|
||||
description: t('knowledge.defaultDescription'),
|
||||
embeddingModelUUID: '',
|
||||
top_k: 5,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -69,6 +74,7 @@ export default function KBForm({
|
||||
form.setValue('name', val.name);
|
||||
form.setValue('description', val.description);
|
||||
form.setValue('embeddingModelUUID', val.embeddingModelUUID);
|
||||
form.setValue('top_k', val.top_k || 5);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -83,6 +89,7 @@ export default function KBForm({
|
||||
name: res.base.name,
|
||||
description: res.base.description,
|
||||
embeddingModelUUID: res.base.embedding_model_uuid,
|
||||
top_k: res.base.top_k || 5,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -109,6 +116,7 @@ export default function KBForm({
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
embedding_model_uuid: data.embeddingModelUUID,
|
||||
top_k: data.top_k,
|
||||
};
|
||||
httpClient
|
||||
.updateKnowledgeBase(initKbId, updateKb)
|
||||
@@ -127,6 +135,7 @@ export default function KBForm({
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
embedding_model_uuid: data.embeddingModelUUID,
|
||||
top_k: data.top_k,
|
||||
};
|
||||
httpClient
|
||||
.createKnowledgeBase(newKb)
|
||||
@@ -226,6 +235,30 @@ export default function KBForm({
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="top_k"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>
|
||||
{t('knowledge.topK')}
|
||||
<span className="text-red-500">*</span>
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="number"
|
||||
{...field}
|
||||
onChange={(e) => field.onChange(Number(e.target.value))}
|
||||
className="w-[180px] h-10 text-base appearance-none"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
{t('knowledge.topKdescription')}
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
|
||||
@@ -46,6 +46,7 @@ export default function KnowledgePage() {
|
||||
name: kb.name,
|
||||
description: kb.description,
|
||||
embeddingModelUUID: kb.embedding_model_uuid,
|
||||
top_k: kb.top_k ?? 5,
|
||||
lastUpdatedTimeAgo: lastUpdatedTimeAgoText,
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -61,7 +61,7 @@ export interface KnowledgeBase {
|
||||
description: string;
|
||||
embedding_model_uuid: string;
|
||||
created_at?: string;
|
||||
top_k?: number;
|
||||
top_k: number;
|
||||
}
|
||||
|
||||
export interface ApiRespProviderEmbeddingModels {
|
||||
@@ -155,6 +155,7 @@ export interface KnowledgeBase {
|
||||
name: string;
|
||||
description: string;
|
||||
embedding_model_uuid: string;
|
||||
top_k: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
@@ -255,6 +255,11 @@ const enUS = {
|
||||
today: 'Today',
|
||||
kbName: 'Knowledge Base Name',
|
||||
kbDescription: 'Knowledge Base Description',
|
||||
topK: 'Top K',
|
||||
topKRequired: 'Top K cannot be empty',
|
||||
topKMax: 'Top K maximum value is 30',
|
||||
topKdescription:
|
||||
'Used to specify the number of relevant documents to retrieve, ranging from 1 to 30.',
|
||||
defaultDescription: 'A knowledge base',
|
||||
embeddingModelUUID: 'Embedding Model',
|
||||
selectEmbeddingModel: 'Select Embedding Model',
|
||||
|
||||
@@ -257,6 +257,11 @@ const jaJP = {
|
||||
today: '今日',
|
||||
kbName: '知識ベース名',
|
||||
kbDescription: '知識ベースの説明',
|
||||
topK: 'Top K',
|
||||
topKRequired: 'Top Kは必須です',
|
||||
topKMax: 'Top Kの最大値は30です',
|
||||
topKdescription:
|
||||
'取得する関連性の高い上位K件の文書の数。1~30の範囲で設定できます',
|
||||
defaultDescription: '知識ベース',
|
||||
embeddingModelUUID: '埋め込みモデル',
|
||||
selectEmbeddingModel: '埋め込みモデルを選択',
|
||||
|
||||
@@ -250,6 +250,10 @@ const zhHans = {
|
||||
today: '今天',
|
||||
kbName: '知识库名称',
|
||||
kbDescription: '知识库描述',
|
||||
topK: '召回数量',
|
||||
topKRequired: '召回数量不能为空',
|
||||
topKMax: '召回数量最大值为 30',
|
||||
topKdescription: '召回相关文档块的数量,取值范围为 1-30',
|
||||
defaultDescription: '一个知识库',
|
||||
embeddingModelUUID: '嵌入模型',
|
||||
selectEmbeddingModel: '选择嵌入模型',
|
||||
|
||||
Reference in New Issue
Block a user