fix: Codex 自动压缩不触发 —— 接管时链接模型目录(绝对路径)进 config.toml (hot 1.5.83)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const media = require("../electron/lib/media-understanding");
|
||||
const { gatewayConfig } = require("../electron/lib/multimodal-config");
|
||||
|
||||
const imagePath = process.argv[2] || path.join(__dirname, "..", "renderer", "logo.png");
|
||||
const config = gatewayConfig();
|
||||
|
||||
if (!config.key) {
|
||||
console.error("缺少多模态网关 Key:请先生成 resources/multimodal-gateway.json,或设置 TD_MULTIMODAL_GATEWAY_KEY。");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const ext = path.extname(imagePath).toLowerCase();
|
||||
const mime =
|
||||
ext === ".jpg" || ext === ".jpeg" ? "image/jpeg" :
|
||||
ext === ".webp" ? "image/webp" :
|
||||
"image/png";
|
||||
const data = fs.readFileSync(imagePath).toString("base64");
|
||||
const request = {
|
||||
input: [{
|
||||
type: "message",
|
||||
role: "user",
|
||||
content: [
|
||||
{ type: "input_text", text: "请识别这张图片里的主要内容和可见文字。" },
|
||||
{ type: "input_image", image_url: `data:${mime};base64,${data}` },
|
||||
],
|
||||
}],
|
||||
};
|
||||
|
||||
media.enrichResponsesRequest(request, { instruction: "请识别这张图片里的主要内容和可见文字。" })
|
||||
.then((result) => {
|
||||
if (!result.processed) throw new Error("没有检测到可处理的图片附件");
|
||||
const evidence = result.evidence || {};
|
||||
console.log(JSON.stringify({
|
||||
provider: evidence.provider,
|
||||
modality: evidence.modality,
|
||||
summary: evidence.summary,
|
||||
items: evidence.items,
|
||||
unsupported: evidence.unsupported,
|
||||
}, null, 2));
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(String((error && error.message) || error));
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user