# `LangchainPrompt.Attachment`
[🔗](https://github.com/exfoundry/langchain_prompt/blob/v0.1.0/lib/langchain_prompt/attachment.ex#L1)

A file attachment to be sent alongside a prompt to the LLM.

Attachments are adapter-agnostic containers for binary data (images, PDFs,
etc.) that get merged into the user message by `LangchainPrompt.execute/4`.

## Creating attachments

    # From raw base64 data
    %Attachment{type: :image, content: base64_data, media: :jpg}

    # From a file on disk (reads, base64-encodes, infers media type)
    Attachment.from_file!("/path/to/menu.jpg")

## Supported extensions

| Extension        | `:type`  | `:media` |
|------------------|----------|----------|
| `.jpg` / `.jpeg` | `:image` | `:jpg`   |
| `.png`           | `:image` | `:png`   |
| `.gif`           | `:image` | `:gif`   |
| `.webp`          | `:image` | `:webp`  |
| `.pdf`           | `:file`  | `:pdf`   |

# `t`

```elixir
@type t() :: %LangchainPrompt.Attachment{
  content: binary(),
  media: atom() | String.t(),
  type: :image | :file
}
```

# `from_file!`

```elixir
@spec from_file!(path :: String.t()) :: t() | no_return()
```

Creates an `Attachment` from a file path.

Reads the file, base64-encodes the content, and infers the `:type` and
`:media` from the file extension.

Raises `ArgumentError` on unsupported extensions and re-raises any
`File.Error` from reading the file.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
