Files
xinmi/scripts/configure_business_kb_models.cjs
T
yawan f7fc992f57
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
2026-09-22 16:19:06 +08:00

53 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const fs = require('node:fs')
const path = require('node:path')
const assert = require('node:assert/strict')
const root = path.resolve(__dirname, '../..')
const model = '404e005b-83ae-5e2e-a3b3-999f9d5cd47e'
const tenant = '10059'
let token
async function api(route, method = 'GET', body) {
const response = await fetch(`http://127.0.0.1:18080/api/v1${route}`, { method,
headers: { 'Content-Type': 'application/json', ...(token ? { Authorization: `Bearer ${token}`, 'X-Tenant-ID': tenant } : {}) },
body: body === undefined ? undefined : JSON.stringify(body), signal: AbortSignal.timeout(30000) })
const result = await response.json()
assert.ok(response.ok && result.success !== false, `${method} ${route}: HTTP ${response.status}`)
return result
}
async function main() {
const credentials = JSON.parse(fs.readFileSync(path.join(root, 'acceptance/super-admin-login.json'), 'utf8'))
const login = await api('/auth/login', 'POST', { username: credentials.username, password: credentials.password })
token = (login.data || login).token
const before = (await api('/knowledge-bases')).data
const targets = before.filter(kb => !kb.summary_model_id && kb.embedding_model_id)
if (!process.argv.includes('--apply')) { console.log(JSON.stringify({ missing_models: targets.map(kb => kb.name) })); return }
fs.writeFileSync(path.join(root, 'acceptance', `kb-model-config-before-${Date.now()}.json`), JSON.stringify(targets, null, 2), { mode: 0o600, flag: 'wx' })
for (const kb of targets) {
const c = kb.chunking_config || {}, e = kb.extract_config || {}, q = kb.question_generation_config || {}
const request = {
llmModelId: model, embeddingModelId: kb.embedding_model_id,
vlm_config: kb.vlm_config, asr_config: kb.asr_config,
multimodal: { enabled: !!kb.vlm_config?.enabled },
storageBackendId: kb.storage_backend_id, storageProvider: kb.storage_config?.provider || 'local',
documentSplitting: {
chunkSize: c.chunk_size || 512, chunkOverlap: c.chunk_size ? c.chunk_overlap : 80,
separators: c.separators?.length ? c.separators : ['\n\n', '\n', '。', '!', '?', ';', ';'],
parserEngineRules: c.parser_engine_rules, enableParentChild: !!c.enable_parent_child,
parentChunkSize: c.parent_chunk_size || 4096, childChunkSize: c.child_chunk_size || 384,
strategy: c.strategy, tokenLimit: c.token_limit, languages: c.languages, tableMetadataInstructions: c.table_metadata_instructions,
},
nodeExtract: { ...e, customInstructions: e.custom_instructions },
questionGeneration: { enabled: !!q.enabled, questionCount: q.question_count, customInstructions: q.custom_instructions },
}
await api(`/initialization/config/${kb.id}`, 'PUT', request)
const after = (await api(`/knowledge-bases/${kb.id}`)).data
assert.equal(after.summary_model_id, model)
assert.equal(after.embedding_model_id, kb.embedding_model_id)
assert.deepEqual(after.indexing_strategy, kb.indexing_strategy)
assert.deepEqual(after.wiki_config, kb.wiki_config)
assert.equal(after.storage_backend_id, kb.storage_backend_id)
}
const after = (await api('/knowledge-bases')).data
console.log(JSON.stringify({ updated: targets.map(kb => kb.name), initialized: after.filter(kb => kb.summary_model_id && kb.embedding_model_id).length, total: after.length, existing_indexes_preserved: true }))
}
main().catch(error => { console.error(error.message); process.exitCode = 1 })