From aee9d33964165f2902ae9bc50d03d5b9ad65c650 Mon Sep 17 00:00:00 2001 From: sxjeru Date: Wed, 31 Jul 2024 15:03:07 +0800 Subject: [PATCH] Update index.ts --- src/libs/agent-runtime/google/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/agent-runtime/google/index.ts b/src/libs/agent-runtime/google/index.ts index e69d09147b5c..6fee7fe5ee51 100644 --- a/src/libs/agent-runtime/google/index.ts +++ b/src/libs/agent-runtime/google/index.ts @@ -9,9 +9,9 @@ import { } from '@google/generative-ai'; import { JSONSchema7 } from 'json-schema'; import { transform } from 'lodash-es'; -import * as fs from 'node:fs'; import { Buffer } from 'node:buffer'; + import { LobeRuntimeAI } from '../BaseAI'; import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '../error'; import { @@ -53,6 +53,7 @@ export class LobeGoogleAI implements LobeRuntimeAI { async chat(payload: ChatStreamPayload, options?: ChatCompetitionOptions) { async function imageUrlToBase64(imageUrl: string): Promise { try { + const fs = await import('node:fs'); const imageData = await fs.promises.readFile(imageUrl); const base64Image = Buffer.from(imageData).toString('base64'); return base64Image;