目前的 alma image 命令行工具强绑定gemini API,即使指定了openrouter的模型,post请求的host还是google的host,图片提取相关的逻辑也仅支持google(提取response中的url链接);
openrouter的google文生图模型response会包含 data:image/png;base64 字符串,直接放在output会爆context,vibe了一下,alma修好了,可以parse后调用send_file发到会话中处理下
base64图片提取:
// 识别并处理 Base64 图片数据,避免打印到控制台
if (responseBody.includes("data:image")) {
const base64Match = responseBody.match(/data:image\/([a-zA-Z]+);base64,([^"\s\)]+)/);
if (base64Match) {
const [_, ext, data] = base64Match;
const tempPath = path.join(os.tmpdir(), alma-img-${Date.now()}.${ext});
fs.writeFileSync(tempPath, data, 'base64');
// 只返回路径,不要打印原始 JSON
return tempPath;
}
}
Please authenticate to join the conversation.
In Review
Feature Request
About 2 hours ago

name my
Get notified by email when there are changes.
In Review
Feature Request
About 2 hours ago

name my
Get notified by email when there are changes.