langcode
Version:
A Plugin-Based Framework for Managing and Using LangChain
46 lines (45 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("../../types");
const duckduckgo_search_1 = require("@langchain/community/tools/duckduckgo_search");
class DuckduckgoPluginPlugin {
constructor() {
this.name = "duckduckgoPlugin";
this.description = "Search the web using DuckDuckGo search engine.";
this.type = types_1.PluginType.Tool;
this.RunConfigExample = {
query: ""
};
this.InitConfigExample = {
maxResults: 3,
searchOptions: {
safeSearch: 0,
locale: "en-us",
region: "wt-wt",
},
};
this.tool = null;
}
expose() {
return {
name: this.name,
description: this.description,
type: this.type,
InitConfigExample: this.InitConfigExample,
RunConfigExample: this.RunConfigExample,
tool: this.tool,
};
}
async init(config) {
this.tool = new duckduckgo_search_1.DuckDuckGoSearch({
maxResults: config.maxResults,
searchOptions: config.searchOptions,
});
}
async run(args) {
if (!this.tool)
throw new Error("DuckDuckGo aracı başlatılmadı.");
return await this.tool.invoke(args.query);
}
}
exports.default = DuckduckgoPluginPlugin;