u
This commit is contained in:
@@ -381,7 +381,10 @@ export function createAnalyzeImageTool({ googleAuthId, model }) {
|
||||
role: 'user',
|
||||
content: [
|
||||
{ type: 'text', text },
|
||||
{ type: 'image_url', imageUrl: { url: `data:image/webp;base64,${webp.toString('base64')}` } },
|
||||
{
|
||||
type: 'image_url',
|
||||
image_url: { url: `data:image/webp;base64,${webp.toString('base64')}` },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -2,7 +2,7 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import sharp from 'sharp';
|
||||
import { defineTool, ToolError } from 'libllmorbiter';
|
||||
import env from '../config/env.js';
|
||||
import * as dbCompanySetting from '../db/companysetting.js';
|
||||
import { prepareVfs, syncVfsToDb } from './vfs.js';
|
||||
|
||||
const SERPER_ENDPOINT = 'https://google.serper.dev/images';
|
||||
@@ -175,10 +175,17 @@ export function createSearchImagesTool({ googleAuthId }) {
|
||||
}
|
||||
const wanted = Math.min(count, MAX_COUNT);
|
||||
|
||||
const apiKey = env.serperApiKey?.trim();
|
||||
let apiKey = null;
|
||||
try {
|
||||
const setting = await dbCompanySetting.getByKey(googleAuthId, 'keys.serper', { maskWriteonly: false });
|
||||
apiKey = setting?.value?.trim() || null;
|
||||
} catch (err) {
|
||||
console.warn('search_images: failed to read company setting keys.serper:', err?.message || err);
|
||||
}
|
||||
|
||||
if (!apiKey) {
|
||||
throw new ToolError(
|
||||
'search_images is unavailable: SERPER_API_KEY is not configured on the server. ' +
|
||||
'search_images is unavailable: Serper API key not configured (companysetting: keys.serper). ' +
|
||||
'Use a direct image URL with javascript_execute instead.'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user