feat(ai-web): 完成JPA存储适配

This commit is contained in:
v-zhangjc9
2025-06-23 16:53:34 +08:00
parent e48d7e8649
commit 5b3c27ea48
32 changed files with 458 additions and 493 deletions

View File

@@ -24,7 +24,7 @@ const DataDetail: React.FC = () => {
{
type: 'service',
className: 'inline',
api: `${commonInfo.baseAiUrl}/knowledge/name?id=${knowledge_id}`,
api: `${commonInfo.baseAiUrl}/knowledge/${knowledge_id}/name`,
body: {
type: 'tpl',
tpl: '${name}',
@@ -38,7 +38,21 @@ const DataDetail: React.FC = () => {
body: [
{
type: 'crud',
api: `${commonInfo.baseAiUrl}/knowledge/group/list?knowledge_id=${knowledge_id}`,
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/group/list`,
data: {
query: {
equal: {
'knowledge/id': knowledge_id,
}
},
page: {
index: '${page}',
size: '${perPage}',
}
}
},
...crudCommonOptions(),
headerToolbar: [
'reload',
@@ -146,7 +160,7 @@ const DataDetail: React.FC = () => {
level: 'link',
size: 'sm',
actionType: 'ajax',
api: `get:${commonInfo.baseAiUrl}/knowledge/group/delete?id=\${id}`,
api: `get:${commonInfo.baseAiUrl}/knowledge/group/remove/\${id}`,
confirmText: '确认删除',
confirmTitle: '删除',
},

View File

@@ -23,7 +23,7 @@ const DataImport: React.FC = () => {
{
type: 'service',
className: 'inline',
api: `${commonInfo.baseAiUrl}/knowledge/name?id=${knowledge_id}`,
api: `${commonInfo.baseAiUrl}/knowledge/${knowledge_id}/name`,
body: {
type: 'tpl',
tpl: '${name}',
@@ -42,6 +42,7 @@ const DataImport: React.FC = () => {
body: [
{
id: 'a5219cc7-72dd-4199-9eeb-61305fe41075',
debug: commonInfo.debug,
type: 'form',
wrapWithPanel: false,
actions: [],
@@ -103,6 +104,8 @@ const DataImport: React.FC = () => {
autoUpload: false,
drag: true,
multiple: true,
joinValues: false,
extractValue: true,
accept: '*',
// 5MB 5242880
// 100MB 104857600
@@ -131,7 +134,6 @@ const DataImport: React.FC = () => {
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/preview_text`,
dataType: 'form',
data: {
mode: '${mode|default:undefined}',
type: '${type|default:undefined}',
@@ -149,7 +151,6 @@ const DataImport: React.FC = () => {
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/submit_text`,
dataType: 'form',
data: {
id: knowledge_id,
mode: '${mode|default:undefined}',

View File

@@ -18,7 +18,7 @@ const DataDetail: React.FC = () => {
{
type: 'service',
className: 'inline',
api: `${commonInfo.baseAiUrl}/knowledge/name?id=${knowledge_id}`,
api: `${commonInfo.baseAiUrl}/knowledge/${knowledge_id}/name`,
body: {
type: 'tpl',
tpl: '${name}',

View File

@@ -1,6 +1,13 @@
import React from 'react'
import {useNavigate} from 'react-router'
import {amisRender, commonInfo, crudCommonOptions, mappingField, mappingItem} from '../../../util/amis.tsx'
import {
amisRender,
commonInfo,
crudCommonOptions,
mappingField,
mappingItem,
paginationTemplate,
} from '../../../util/amis.tsx'
const strategyMapping = [
mappingItem('文本', 'Cosine'),
@@ -25,62 +32,74 @@ const Knowledge: React.FC = () => {
body: [
{
type: 'crud',
api: `${commonInfo.baseAiUrl}/knowledge/list`,
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/list`,
data: {
page: {
index: '${page}',
size: '${perPage}',
}
}
},
...crudCommonOptions(),
headerToolbar: [
'reload',
{
type: 'action',
label: '',
icon: 'fa fa-plus',
tooltip: '新增',
tooltipPlacement: 'top',
actionType: 'dialog',
dialog: {
title: '新增知识库',
size: 'md',
body: {
type: 'form',
api: {
url: `${commonInfo.baseAiUrl}/knowledge/add`,
dataType: 'form',
...paginationTemplate(
10,
5,
[
{
type: 'action',
label: '',
icon: 'fa fa-plus',
tooltip: '新增',
tooltipPlacement: 'top',
actionType: 'dialog',
dialog: {
title: '新增知识库',
size: 'md',
body: {
type: 'form',
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/save`,
},
body: [
{
type: 'input-text',
name: 'name',
label: '名称',
required: true,
},
{
type: 'textarea',
name: 'description',
label: '描述',
required: true,
},
{
type: 'select',
name: 'strategy',
label: '类型',
value: 'Cosine',
required: true,
options: [
{
label: '文本',
value: 'Cosine',
},
{
label: '图片',
value: 'Euclid',
disabled: true,
},
],
},
],
},
body: [
{
type: 'input-text',
name: 'name',
label: '名称',
required: true,
},
{
type: 'textarea',
name: 'description',
label: '描述',
required: true,
},
{
type: 'select',
name: 'strategy',
label: '类型',
value: 'Cosine',
required: true,
options: [
{
label: '文本',
value: 'Cosine',
},
{
label: '图片',
value: 'Euclid',
disabled: true,
},
],
},
],
},
},
},
],
],
),
columns: [
{
name: 'name',
@@ -128,13 +147,12 @@ const Knowledge: React.FC = () => {
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/update_description`,
dataType: 'form',
},
mode: 'normal',
body: [
{
type: 'hidden',
name: "id",
name: 'id',
// value: '${id}',
},
{
@@ -142,10 +160,10 @@ const Knowledge: React.FC = () => {
name: 'description',
label: '描述',
required: true,
}
]
}
}
},
],
},
},
},
{
type: 'action',
@@ -192,17 +210,8 @@ const Knowledge: React.FC = () => {
level: 'link',
size: 'sm',
actionType: 'ajax',
api: {
method: 'get',
url: `${commonInfo.baseAiUrl}/knowledge/delete`,
headers: {
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
},
data: {
id: '${id}',
},
},
confirmText: '确认删除',
api: `get:${commonInfo.baseAiUrl}/knowledge/remove/\${id}`,
confirmText: '确认删除知识库:${name}',
confirmTitle: '删除',
},
],

View File

@@ -10,8 +10,8 @@ import {isEqual} from 'licia'
export const commonInfo = {
debug: isEqual(import.meta.env.MODE, 'development'),
baseUrl: 'http://132.126.207.130:35690/hudi_services/service_web',
// baseAiUrl: 'http://132.126.207.130:35690/hudi_services/service_ai_web',
baseAiUrl: 'http://localhost:8080',
baseAiUrl: 'http://132.126.207.130:35690/hudi_services/service_ai_web',
// baseAiUrl: 'http://localhost:8080',
authorizationHeaders: {
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
'Content-Type': 'application/json',
@@ -311,16 +311,18 @@ export function paginationCommonOptions(perPage = true, maxButtons = 5) {
return option
}
export function paginationTemplate(perPage = 20, maxButtons = 5) {
export function paginationTemplate(perPage = 20, maxButtons = 5, extraHeaders: Schema[] = [], extraFooters: Schema[] = []) {
return {
perPage: perPage,
headerToolbar: [
'reload',
paginationCommonOptions(true, maxButtons),
...extraHeaders,
],
footerToolbar: [
'statistics',
paginationCommonOptions(true, maxButtons),
...extraFooters,
],
}
}