no message
This commit is contained in:
parent
f38e54dea8
commit
f1a96967c3
@ -7,12 +7,13 @@ export default async (input: ImageConfig, config: AIConfig): Promise<string> =>
|
|||||||
if (!config.apiKey) throw new Error("缺少API Key");
|
if (!config.apiKey) throw new Error("缺少API Key");
|
||||||
if (!input.prompt) throw new Error("缺少提示词");
|
if (!input.prompt) throw new Error("缺少提示词");
|
||||||
|
|
||||||
|
const options: any = {};
|
||||||
|
if (config.apiKey) options.apiKey = config.apiKey;
|
||||||
|
if (config?.baseURL) options.baseURL = config.baseURL;
|
||||||
const google = createGoogleGenerativeAI({
|
const google = createGoogleGenerativeAI({
|
||||||
apiKey: config.apiKey,
|
...options,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// 构建完整的提示词
|
// 构建完整的提示词
|
||||||
const fullPrompt = input.systemPrompt ? `${input.systemPrompt}\n\n${input.prompt}` : input.prompt;
|
const fullPrompt = input.systemPrompt ? `${input.systemPrompt}\n\n${input.prompt}` : input.prompt;
|
||||||
let promptData: ModelMessage[] | string = [];
|
let promptData: ModelMessage[] | string = [];
|
||||||
@ -44,8 +45,6 @@ export default async (input: ImageConfig, config: AIConfig): Promise<string> =>
|
|||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!result.files.length) {
|
if (!result.files.length) {
|
||||||
console.error(JSON.stringify(result.response, null, 2));
|
console.error(JSON.stringify(result.response, null, 2));
|
||||||
throw new Error("图片生成失败");
|
throw new Error("图片生成失败");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user