mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-23 14:10:18 +09:00
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { ArxivAPIWrapper } from "@/app/api/langchain-tools/arxiv";
|
|
import { DallEAPIWrapper } from "@/app/api/langchain-tools/dalle_image_generator";
|
|
import { StableDiffusionWrapper } from "@/app/api/langchain-tools/stable_diffusion_image_generator";
|
|
import { BaseLanguageModel } from "langchain/dist/base_language";
|
|
import { Calculator } from "langchain/tools/calculator";
|
|
import { WebBrowser } from "langchain/tools/webbrowser";
|
|
import { Embeddings } from "langchain/dist/embeddings/base.js";
|
|
import { WolframAlphaTool } from "@/app/api/langchain-tools/wolframalpha";
|
|
|
|
export class EdgeTool {
|
|
private apiKey: string | undefined;
|
|
|
|
private baseUrl: string;
|
|
|
|
private model: BaseLanguageModel;
|
|
|
|
private embeddings: Embeddings;
|
|
|
|
private callback?: (data: string) => Promise<void>;
|
|
|
|
constructor(
|
|
apiKey: string | undefined,
|
|
baseUrl: string,
|
|
model: BaseLanguageModel,
|
|
embeddings: Embeddings,
|
|
callback?: (data: string) => Promise<void>,
|
|
) {
|
|
this.apiKey = apiKey;
|
|
this.baseUrl = baseUrl;
|
|
this.model = model;
|
|
this.embeddings = embeddings;
|
|
this.callback = callback;
|
|
}
|
|
|
|
async getCustomTools(): Promise<any[]> {
|
|
const webBrowserTool = new WebBrowser({
|
|
model: this.model,
|
|
embeddings: this.embeddings,
|
|
});
|
|
const calculatorTool = new Calculator();
|
|
const dallEAPITool = new DallEAPIWrapper(
|
|
this.apiKey,
|
|
this.baseUrl,
|
|
this.callback,
|
|
);
|
|
const stableDiffusionTool = new StableDiffusionWrapper();
|
|
const arxivAPITool = new ArxivAPIWrapper();
|
|
const wolframAlphaTool = new WolframAlphaTool();
|
|
let tools = [
|
|
calculatorTool,
|
|
webBrowserTool,
|
|
dallEAPITool,
|
|
stableDiffusionTool,
|
|
arxivAPITool,
|
|
wolframAlphaTool,
|
|
];
|
|
return tools;
|
|
}
|
|
}
|