ads4gpts-langchain
Version:
Ads for AI applications. Enabling the Freemium model for the AI era.
32 lines • 1.65 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ADS4GPTsChatTool = void 0;
const ADS4GPTsTool_1 = require("./ADS4GPTsTool");
const ADS4GPTsAPI_1 = require("../lib/api/ADS4GPTsAPI");
const toolsConfig_1 = __importDefault(require("../lib/config/toolsConfig"));
const utils_1 = require("../lib/utils");
class ADS4GPTsChatTool extends ADS4GPTsTool_1.ADS4GPTsTool {
/**
* Constructs an instance of the ADS4GPTsChatTool.
*
* @param args - A record of key-value pairs, including an optional API key.
* @param args.apiKey - Ads4GPTs API key. If not provided, it will attempt to retrieve it from the `ADS4GPTS_API_KEY` environment variable.
*
* @throws Error if the API key is missing or the chat tool configuration is not found.
*/
constructor(args = {}) {
const baseUrl = args.rootUrl || 'https://with.ads4gpts.com';
const ads4gptsApiKey = (0, utils_1.getConfigValue)(args, 'apiKey', 'ADS4GPTS_API_KEY');
const ads4gptsAPI = new ADS4GPTsAPI_1.ADS4GPTsAPI(ads4gptsApiKey, baseUrl);
const chatToolConfig = toolsConfig_1.default.find((tool) => tool.name === 'ads4gpts_chat_tool');
if (!chatToolConfig) {
throw new Error('Chat tool configuration not found.');
}
super(ads4gptsAPI, chatToolConfig.name, chatToolConfig.url, chatToolConfig.description, chatToolConfig.parameters);
}
}
exports.ADS4GPTsChatTool = ADS4GPTsChatTool;
//# sourceMappingURL=ADS4GPTsChatTool.js.map