Gemini.Types.Document (GeminiEx v0.8.4)

View Source

Type definitions for RAG document management.

Documents are stored in RAG stores and used for semantic search and retrieval-augmented generation (RAG) workflows.

Document Lifecycle

  1. Upload a file to a RAG store
  2. Document is created with metadata
  3. Document is indexed for search
  4. Use in generation with grounding

Example

# List documents in a store
{:ok, response} = Gemini.APIs.Documents.list("ragStores/my-store")

# Get document metadata
{:ok, doc} = Gemini.APIs.Documents.get("ragStores/my-store/documents/doc123")

# Delete when no longer needed
:ok = Gemini.APIs.Documents.delete(doc.name)

Summary

Types

Document metadata for custom properties.

Document state enumeration.

t()

Represents a document in a RAG store.

Functions

Checks if the document is ready for use.

Checks if the document processing failed.

Creates a Document from API response.

Extracts the document ID from the full resource name.

Extracts the store ID from the document's full resource name.

Parses document state from API string.

Checks if the document is still processing.

Converts state atom to API string.

Types

document_metadata()

@type document_metadata() :: %{optional(String.t()) => String.t()}

Document metadata for custom properties.

document_state()

@type document_state() :: :state_unspecified | :processing | :active | :failed

Document state enumeration.

t()

@type t() :: %Gemini.Types.Document{
  chunk_count: integer() | nil,
  create_time: String.t() | nil,
  display_name: String.t() | nil,
  error: map() | nil,
  metadata: document_metadata() | nil,
  mime_type: String.t() | nil,
  name: String.t() | nil,
  size_bytes: integer() | nil,
  source_uri: String.t() | nil,
  state: document_state() | nil,
  update_time: String.t() | nil
}

Represents a document in a RAG store.

Fields

  • name - Resource name (e.g., "ragStores/abc/documents/xyz")
  • display_name - Human-readable name
  • state - Processing state
  • create_time - When the document was created
  • update_time - Last update timestamp
  • size_bytes - Document size in bytes
  • source_uri - Original source URI (if applicable)
  • mime_type - MIME type of the document
  • metadata - Custom metadata key-value pairs
  • error - Error details if processing failed
  • chunk_count - Number of chunks the document was split into

Functions

active?(arg1)

@spec active?(t()) :: boolean()

Checks if the document is ready for use.

failed?(arg1)

@spec failed?(t()) :: boolean()

Checks if the document processing failed.

from_api_response(response)

@spec from_api_response(map()) :: t()

Creates a Document from API response.

get_id(document)

@spec get_id(t()) :: String.t() | nil

Extracts the document ID from the full resource name.

get_store_id(document)

@spec get_store_id(t()) :: String.t() | nil

Extracts the store ID from the document's full resource name.

parse_state(arg1)

@spec parse_state(String.t() | nil) :: document_state() | nil

Parses document state from API string.

processing?(arg1)

@spec processing?(t()) :: boolean()

Checks if the document is still processing.

state_to_api(atom)

@spec state_to_api(document_state()) :: String.t()

Converts state atom to API string.