image.d.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { MessageContentComplex } from "../messages/index.js";
  2. import { ImagePromptValue, ImageContent } from "../prompt_values.js";
  3. import type { InputValues, PartialValues } from "../utils/types/index.js";
  4. import { BasePromptTemplate, BasePromptTemplateInput, TypedPromptInputValues } from "./base.js";
  5. import { TemplateFormat } from "./template.js";
  6. /**
  7. * Inputs to create a {@link ImagePromptTemplate}
  8. * @augments BasePromptTemplateInput
  9. */
  10. export interface ImagePromptTemplateInput<RunInput extends InputValues = any, PartialVariableName extends string = any> extends BasePromptTemplateInput<RunInput, PartialVariableName> {
  11. /**
  12. * The prompt template
  13. */
  14. template: Record<string, unknown>;
  15. /**
  16. * The format of the prompt template. Options are 'f-string'
  17. *
  18. * @defaultValue 'f-string'
  19. */
  20. templateFormat?: TemplateFormat;
  21. /**
  22. * Whether or not to try validating the template on initialization
  23. *
  24. * @defaultValue `true`
  25. */
  26. validateTemplate?: boolean;
  27. /**
  28. * Additional fields which should be included inside
  29. * the message content array if using a complex message
  30. * content.
  31. */
  32. additionalContentFields?: MessageContentComplex;
  33. }
  34. /**
  35. * An image prompt template for a multimodal model.
  36. */
  37. export declare class ImagePromptTemplate<RunInput extends InputValues = any, PartialVariableName extends string = any> extends BasePromptTemplate<RunInput, ImagePromptValue, PartialVariableName> {
  38. static lc_name(): string;
  39. lc_namespace: string[];
  40. template: Record<string, unknown>;
  41. templateFormat: TemplateFormat;
  42. validateTemplate: boolean;
  43. /**
  44. * Additional fields which should be included inside
  45. * the message content array if using a complex message
  46. * content.
  47. */
  48. additionalContentFields?: MessageContentComplex;
  49. constructor(input: ImagePromptTemplateInput<RunInput, PartialVariableName>);
  50. _getPromptType(): "prompt";
  51. /**
  52. * Partially applies values to the prompt template.
  53. * @param values The values to be partially applied to the prompt template.
  54. * @returns A new instance of ImagePromptTemplate with the partially applied values.
  55. */
  56. partial<NewPartialVariableName extends string>(values: PartialValues<NewPartialVariableName>): Promise<ImagePromptTemplate<InputValues<Exclude<Extract<keyof RunInput, string>, NewPartialVariableName>>, any>>;
  57. /**
  58. * Formats the prompt template with the provided values.
  59. * @param values The values to be used to format the prompt template.
  60. * @returns A promise that resolves to a string which is the formatted prompt.
  61. */
  62. format<FormatOutput = ImageContent>(values: TypedPromptInputValues<RunInput>): Promise<FormatOutput>;
  63. /**
  64. * Formats the prompt given the input values and returns a formatted
  65. * prompt value.
  66. * @param values The input values to format the prompt.
  67. * @returns A Promise that resolves to a formatted prompt value.
  68. */
  69. formatPromptValue(values: TypedPromptInputValues<RunInput>): Promise<ImagePromptValue>;
  70. }