2026-05-17 13:06:25 +08:00
|
|
|
import { apiGet } from './base'
|
2025-06-30 22:29:23 +08:00
|
|
|
|
2026-05-17 13:06:25 +08:00
|
|
|
export const graphApi = {
|
2025-12-15 23:25:56 +08:00
|
|
|
getGraphs: async () => {
|
|
|
|
|
return await apiGet('/api/graph/list', {}, true)
|
|
|
|
|
},
|
|
|
|
|
|
2025-07-22 17:29:38 +08:00
|
|
|
getSubgraph: async (params) => {
|
2026-05-17 18:06:25 +08:00
|
|
|
const { db_id, node_label = '*', max_depth = 2, max_nodes = 100, exclude_chunk = false } = params
|
2025-07-22 17:29:38 +08:00
|
|
|
|
|
|
|
|
if (!db_id) {
|
|
|
|
|
throw new Error('db_id is required')
|
|
|
|
|
}
|
2025-06-30 22:29:23 +08:00
|
|
|
|
2025-07-22 17:29:38 +08:00
|
|
|
const queryParams = new URLSearchParams({
|
2026-05-17 13:06:25 +08:00
|
|
|
db_id,
|
|
|
|
|
node_label,
|
2025-07-22 17:29:38 +08:00
|
|
|
max_depth: max_depth.toString(),
|
2026-05-17 18:06:25 +08:00
|
|
|
max_nodes: max_nodes.toString(),
|
|
|
|
|
exclude_chunk: exclude_chunk.toString()
|
2025-06-30 22:29:23 +08:00
|
|
|
})
|
|
|
|
|
|
2025-12-15 23:25:56 +08:00
|
|
|
return await apiGet(`/api/graph/subgraph?${queryParams.toString()}`, {}, true)
|
2025-07-22 17:29:38 +08:00
|
|
|
},
|
|
|
|
|
|
2025-12-15 23:25:56 +08:00
|
|
|
getStats: async (db_id) => {
|
2025-07-22 17:29:38 +08:00
|
|
|
if (!db_id) {
|
|
|
|
|
throw new Error('db_id is required')
|
2025-06-30 22:29:23 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-17 13:06:25 +08:00
|
|
|
const queryParams = new URLSearchParams({ db_id })
|
2025-12-15 23:25:56 +08:00
|
|
|
return await apiGet(`/api/graph/stats?${queryParams.toString()}`, {}, true)
|
2025-07-22 17:29:38 +08:00
|
|
|
},
|
|
|
|
|
|
2025-12-15 23:25:56 +08:00
|
|
|
getLabels: async (db_id) => {
|
2025-07-22 17:29:38 +08:00
|
|
|
if (!db_id) {
|
|
|
|
|
throw new Error('db_id is required')
|
2025-06-30 22:29:23 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-17 13:06:25 +08:00
|
|
|
const queryParams = new URLSearchParams({ db_id })
|
2025-12-15 23:25:56 +08:00
|
|
|
return await apiGet(`/api/graph/labels?${queryParams.toString()}`, {}, true)
|
2025-06-30 22:29:23 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-17 13:06:25 +08:00
|
|
|
export const unifiedApi = graphApi
|