feat: support google multiple keys

This commit is contained in:
Hk-Gosuto
2024-05-28 21:26:54 +08:00
parent 11f063fd9e
commit fe9a17693c
7 changed files with 13 additions and 10 deletions

View File

@@ -38,6 +38,7 @@ import {
AIMessage,
} from "@langchain/core/messages";
import { MultimodalContent } from "@/app/client/api";
import { GoogleCustomSearch } from "@/app/api/langchain-tools/langchian-tool-index";
export interface RequestMessage {
role: string;
@@ -284,8 +285,11 @@ export class AgentApi {
func: async (input: string) => serpAPITool.call(input),
});
}
if (process.env.GOOGLE_CSE_ID && process.env.GOOGLE_API_KEY) {
let googleCustomSearchTool = new langchainTools["GoogleCustomSearch"]();
if (process.env.GOOGLE_CSE_ID && process.env.GOOGLE_SEARCH_API_KEY) {
let googleCustomSearchTool = new GoogleCustomSearch({
apiKey: process.env.GOOGLE_SEARCH_API_KEY,
googleCSEId: process.env.GOOGLE_CSE_ID,
});
searchTool = new DynamicTool({
name: "google_custom_search",
description: googleCustomSearchTool.description,