serde.d.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { MessageContent } from "../messages/index.js";
  2. import type { TemplateFormat } from "./template.js";
  3. /**
  4. * Represents a serialized version of a prompt template. This type is used
  5. * to create dynamic prompts for language models. It contains an optional
  6. * `_type` field which, if present, is set to 'prompt'. It also includes
  7. * `input_variables`, an array of strings representing the variables to be
  8. * used in the prompt, an optional `template_format` specifying the format
  9. * of the template, and an optional `template` which is the actual
  10. * template string.
  11. */
  12. export type SerializedPromptTemplate = {
  13. _type?: "prompt";
  14. input_variables: string[];
  15. template_format?: TemplateFormat;
  16. template?: MessageContent;
  17. };
  18. /**
  19. * Represents a serialized version of a few-shot template. This type
  20. * includes an `_type` field set to 'few_shot', `input_variables` which
  21. * are an array of strings representing the variables to be used in the
  22. * template, `examples` which can be a string or an array of Example
  23. * objects, an optional `example_prompt` which is a
  24. * SerializedPromptTemplate, `example_separator` which is a string,
  25. * optional `prefix` and `suffix` strings, and `template_format` which
  26. * specifies the format of the template.
  27. */
  28. export type SerializedFewShotTemplate = {
  29. _type: "few_shot";
  30. input_variables: string[];
  31. examples: string | any[];
  32. example_prompt?: SerializedPromptTemplate;
  33. example_separator: string;
  34. prefix?: string;
  35. suffix?: string;
  36. template_format: TemplateFormat;
  37. };
  38. /**
  39. * Represents a serialized version of a base prompt template. This type
  40. * can be either a SerializedFewShotTemplate or a
  41. * SerializedPromptTemplate.
  42. */
  43. export type SerializedBasePromptTemplate = SerializedFewShotTemplate | SerializedPromptTemplate;