支持直连google\baidu搜索引擎 (#30)

* 支持直连google\baidu搜索引擎

* 删除无用参数
This commit is contained in:
hang666
2023-09-22 09:35:38 +08:00
committed by GitHub
parent 61e00ed0ad
commit 83f5dc48d1
5 changed files with 201 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ import { WebBrowser } from "langchain/tools/webbrowser";
import { Calculator } from "langchain/tools/calculator";
import { DynamicTool, Tool } from "langchain/tools";
import { DallEAPIWrapper } from "@/app/api/langchain-tools/dalle_image_generator";
import { BaiduSearch } from "@/app/api/langchain-tools/baidu_search";
import { GoogleSearch } from "@/app/api/langchain-tools/google_search";
const serverConfig = getServerSideConfig();
@@ -173,6 +175,16 @@ async function handle(req: NextRequest) {
});
let searchTool: Tool = new DuckDuckGo();
if (process.env.CHOOSE_SEARCH_ENGINE) {
switch (process.env.CHOOSE_SEARCH_ENGINE) {
case "google":
searchTool = new GoogleSearch();
break;
case "baidu":
searchTool = new BaiduSearch();
break;
}
}
if (process.env.BING_SEARCH_API_KEY) {
let bingSearchTool = new langchainTools["BingSerpAPI"](
process.env.BING_SEARCH_API_KEY,