Jibu.Content (Jibu v0.2.1)

Copy Markdown View Source

Builds image and document content blocks for the Messages API.

Extra options are merged into the block unchanged, for example title:, context:, citations: %{enabled: true} or cache_control: %{type: "ephemeral"}.

content = [
  Jibu.Content.document("contract.pdf", title: "Contract"),
  %{type: "text", text: "Summarize the termination clauses."}
]

Summary

Functions

Reads a PDF or plain text file into a document block.

Builds a document block from a binary. text/plain becomes a text source, anything else base64.

References a document uploaded through Jibu.Files.

Reads an image file into a base64 image block.

Builds a base64 image block from a binary.

References an image uploaded through Jibu.Files.

Functions

document(path, opts \\ [])

@spec document(Path.t(), keyword()) :: map()

Reads a PDF or plain text file into a document block.

document_data(data, media_type, opts \\ [])

@spec document_data(binary(), String.t(), keyword()) :: map()

Builds a document block from a binary. text/plain becomes a text source, anything else base64.

document_file(file_id, opts \\ [])

@spec document_file(String.t(), keyword()) :: map()

References a document uploaded through Jibu.Files.

image(path, opts \\ [])

@spec image(Path.t(), keyword()) :: map()

Reads an image file into a base64 image block.

image_data(data, media_type, opts \\ [])

@spec image_data(binary(), String.t(), keyword()) :: map()

Builds a base64 image block from a binary.

image_file(file_id, opts \\ [])

@spec image_file(String.t(), keyword()) :: map()

References an image uploaded through Jibu.Files.