UNPKG

langcode

Version:

A Plugin-Based Framework for Managing and Using LangChain

39 lines (38 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = require("../../types"); const prompts_1 = require("@langchain/core/prompts"); class PromptTemplatePlugin { constructor() { this.name = "prompttemplate"; this.description = "LangChain PromptTemplate formatter"; this.type = types_1.PluginType.Prompt; this.RunConfigExample = { template: "", inputVariables: {} }; this.InitConfigExample = {}; } expose() { return { name: this.name, description: this.description, type: this.type, InitConfigExample: this.InitConfigExample, RunConfigExample: this.RunConfigExample, }; } async init(_) { // Bu plugin için init'e ihtiyaç yok } async run(args) { const { template, inputVariables } = args; const prompt = new prompts_1.PromptTemplate({ template, inputVariables: Object.keys(inputVariables), }); const result = await prompt.format(inputVariables); return result; } } exports.default = PromptTemplatePlugin;