| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- /**
- * 与 img-center-point-location 相同栈:nodejs/ai ai.run('img2text', prompt, [url1,url2], { model })。
- * 默认模型用 nodejs/ai/config IMG_CENTER_MODEL(可用 VERIFY_FORCE_MODEL 覆盖)。
- */
- const path = require('path')
- const fs = require('fs')
- const aiModule = require(path.join(__dirname, '..', 'ai.js'))
- const aiConfig = require(path.join(__dirname, '..', 'config.js'))
- const img2textReq = require(path.join(__dirname, '..', 'request', 'img2text.js'))
- function fileToDataUrlPng (absPath) {
- const buf = fs.readFileSync(absPath)
- return `data:image/png;base64,${buf.toString('base64')}`
- }
- function defaultFixtureDir () {
- const projectRoot = path.resolve(__dirname, '..', '..', '..')
- const d = path.join(
- projectRoot,
- 'static',
- 'process',
- 'GenerateNote',
- 'tmp',
- 'img-center-1774080885011'
- )
- return fs.existsSync(path.join(d, 'screenshot.png')) ? d : null
- }
- async function main () {
- const model = (
- process.env.VERIFY_FORCE_MODEL ||
- img2textReq.resolveImgCenterModel(undefined)
- ).trim()
- const def = defaultFixtureDir()
- const screenPath =
- process.argv[2] ||
- (def && path.join(def, 'screenshot.png')) ||
- path.join(__dirname, 'fixture-verify.png')
- const tplPath =
- process.argv[3] ||
- (def && path.join(def, 'template.png')) ||
- screenPath
- if (!fs.existsSync(screenPath)) {
- console.error('缺少截图:', screenPath)
- process.exit(1)
- }
- if (!fs.existsSync(tplPath)) {
- console.error('缺少模板:', tplPath)
- process.exit(1)
- }
- const verifyPrompt = `你收到两张图(与 img-center ROI 流程相同的多模态调用)。
- 请严格只输出纯文本三行,不要 markdown:
- 第1行:你认为本次 API 实际为你分配的模型名称或系列(若不确定写 未知)。
- 第2行:若你认为是 GPT-5.4 系列则写 YES,否则写 NO。
- 第3行:简短说明依据(不超过 40 字)。
- 注意:以服务端返回的 JSON 里 model 字段为准;你的自称可能不准。`
- console.log('IMG_CENTER_MODEL (resolveImgCenterModel default):', img2textReq.resolveImgCenterModel(undefined))
- console.log('request options.model:', model)
- const r = await aiModule.run('img2text', verifyPrompt, [fileToDataUrlPng(screenPath), fileToDataUrlPng(tplPath)], {
- model,
- timeoutMs: 300000,
- })
- if (!r.success) {
- console.error(r.error || '请求失败')
- process.exit(1)
- }
- const resp = r.data
- console.log('response.model (authoritative):', resp.model)
- const content = resp?.choices?.[0]?.message?.content
- console.log('assistant (self-report, not authoritative):\n---\n', content, '\n---')
- const ok =
- String(resp.model || '')
- .toLowerCase()
- .includes('gpt-5.4') || String(resp.model || '').toLowerCase().includes('5.4')
- console.log('response.model looks like gpt-5.4:', ok ? 'YES' : 'NO (check gateway mapping)')
- console.log('BASE_URL:', aiConfig.BASE_URL)
- }
- main().catch((e) => {
- console.error(e)
- process.exit(1)
- })
|