pharos-agent-kit
Version:
Connect AI Agents to Pharos protocols
38 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PharosCreateImageTool = void 0;
const tools_1 = require("langchain/tools");
const agent_1 = require("../../tools/agent");
class PharosCreateImageTool extends tools_1.Tool {
constructor(pharosKit) {
super();
this.pharosKit = pharosKit;
this.name = "pharos_create_image";
this.description = "Create an image using OpenAI's DALL-E. Input should be a string prompt for the image.";
}
validateInput(input) {
if (typeof input !== "string" || input.trim().length === 0) {
throw new Error("Input must be a non-empty string prompt");
}
}
async _call(input) {
try {
this.validateInput(input);
const result = await (0, agent_1.create_image)(this.pharosKit, input.trim());
return JSON.stringify({
status: "success",
message: "Image created successfully",
...result,
});
}
catch (error) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}
exports.PharosCreateImageTool = PharosCreateImageTool;
//# sourceMappingURL=create_image.js.map