Class Attachment

java.lang.Object
com.github.copilot.sdk.json.Attachment

public class Attachment extends Object
Represents a file attachment to include with a message.

Attachments provide additional context to the AI assistant, such as source code files, documents, or other relevant content. All setter methods return this for method chaining.

Example Usage


 var attachment = new Attachment().setType("file").setPath("/path/to/source.java").setDisplayName("Main Source File");
 
Since:
1.0.0
See Also:
  • Constructor Details

    • Attachment

      public Attachment()
  • Method Details

    • getType

      public String getType()
      Gets the attachment type.
      Returns:
      the type (e.g., "file")
    • setType

      public Attachment setType(String type)
      Sets the attachment type.

      Currently supported types:

      • "file" - A file from the filesystem
      Parameters:
      type - the attachment type
      Returns:
      this attachment for method chaining
    • getPath

      public String getPath()
      Gets the file path.
      Returns:
      the absolute path to the file
    • setPath

      public Attachment setPath(String path)
      Sets the file path.

      This should be an absolute path to the file on the filesystem.

      Parameters:
      path - the absolute file path
      Returns:
      this attachment for method chaining
    • getDisplayName

      public String getDisplayName()
      Gets the display name.
      Returns:
      the display name for the attachment
    • setDisplayName

      public Attachment setDisplayName(String displayName)
      Sets a human-readable display name for the attachment.

      This name is shown to the assistant and may be used when referring to the file in responses.

      Parameters:
      displayName - the display name
      Returns:
      this attachment for method chaining