langcode
Version:
A Plugin-Based Framework for Managing and Using LangChain
37 lines (36 loc) • 1.11 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tools_1 = require("langchain/tools");
const types_1 = require("../../types");
class RequestsPostToolPlugin {
constructor() {
this.name = "requestsPostTool";
this.description = "Send HTTP POST requests to a given URL with a JSON body.";
this.type = types_1.PluginType.Tool;
this.RunConfigExample = {
url: "",
data: {}
};
this.InitConfigExample = {};
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 tools_1.RequestsPostTool();
}
async run(args) {
if (!this.tool)
throw new Error("Tool is not initialized.");
return await this.tool.invoke(args);
}
}
exports.default = RequestsPostToolPlugin;