Record Class PromptSpec

java.lang.Object
java.lang.Record
com.tnsai.prompt.PromptSpec

public record PromptSpec(String version, String description, String author, Set<String> requiredVariables, Set<String> tags, Map<String,String> extra, Instant createdAt, Instant updatedAt) extends Record
Spec for prompt templates.

Contains versioning information, descriptions, and other metadata useful for prompt management and debugging.

Usage


 PromptSpec metadata = PromptSpec.builder()
     .version("1.2.0")
     .description("Code review prompt for security analysis")
     .author("security-team")
     .requiredVariables(Set.of("code", "language"))
     .tag("security", "code-review")
     .build();
 
  • Constructor Details

  • Method Details

    • defaults

      public static PromptSpec defaults()
      Creates default metadata.
      Returns:
      default metadata
    • builder

      public static PromptSpec.Builder builder()
      Creates a builder for metadata.
      Returns:
      new builder
    • hasTag

      public boolean hasTag(String tag)
      Returns whether this prompt has a specific tag.
      Parameters:
      tag - the tag to check
      Returns:
      true if tag exists
    • getExtra

      public String getExtra(String key)
      Gets an extra metadata value.
      Parameters:
      key - the key
      Returns:
      value or null
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • version

      public String version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • author

      public String author()
      Returns the value of the author record component.
      Returns:
      the value of the author record component
    • requiredVariables

      public Set<String> requiredVariables()
      Returns the value of the requiredVariables record component.
      Returns:
      the value of the requiredVariables record component
    • tags

      public Set<String> tags()
      Returns the value of the tags record component.
      Returns:
      the value of the tags record component
    • extra

      public Map<String,String> extra()
      Returns the value of the extra record component.
      Returns:
      the value of the extra record component
    • createdAt

      public Instant createdAt()
      Returns the value of the createdAt record component.
      Returns:
      the value of the createdAt record component
    • updatedAt

      public Instant updatedAt()
      Returns the value of the updatedAt record component.
      Returns:
      the value of the updatedAt record component