string.cjs 1.1 KB

12345678910111213141516171819202122232425
  1. "use strict";
  2. // Default generic "any" values are for backwards compatibility.
  3. // Replace with "string" when we are comfortable with a breaking change.
  4. Object.defineProperty(exports, "__esModule", { value: true });
  5. exports.BaseStringPromptTemplate = void 0;
  6. const prompt_values_js_1 = require("../prompt_values.cjs");
  7. const base_js_1 = require("./base.cjs");
  8. /**
  9. * Base class for string prompt templates. It extends the
  10. * BasePromptTemplate class and overrides the formatPromptValue method to
  11. * return a StringPromptValue.
  12. */
  13. class BaseStringPromptTemplate extends base_js_1.BasePromptTemplate {
  14. /**
  15. * Formats the prompt given the input values and returns a formatted
  16. * prompt value.
  17. * @param values The input values to format the prompt.
  18. * @returns A Promise that resolves to a formatted prompt value.
  19. */
  20. async formatPromptValue(values) {
  21. const formattedPrompt = await this.format(values);
  22. return new prompt_values_js_1.StringPromptValue(formattedPrompt);
  23. }
  24. }
  25. exports.BaseStringPromptTemplate = BaseStringPromptTemplate;