ConfluenceLoader.Document (confluence_loader v0.1.1)

View Source

Document struct that represents a Confluence page in a format similar to llama-index documents.

Summary

Functions

Returns a formatted string representation of the document suitable for LLM consumption.

Creates a Document from a map.

Creates a new Document.

Converts the document to a map format suitable for JSON serialization.

Types

t()

@type t() :: %ConfluenceLoader.Document{
  id: String.t(),
  metadata: map(),
  text: String.t()
}

Functions

format_for_llm(document)

@spec format_for_llm(t()) :: String.t()

Returns a formatted string representation of the document suitable for LLM consumption.

Examples

iex> doc = ConfluenceLoader.Document.new("123", "Content here", %{title: "My Page", space_id: "SPACE1"})
iex> ConfluenceLoader.Document.format_for_llm(doc)

from_map(map)

@spec from_map(map()) :: {:ok, t()} | {:error, String.t()}

Creates a Document from a map.

Examples

iex> ConfluenceLoader.Document.from_map(%{id: "123", text: "Content", metadata: %{title: "Page"}})
{:ok, %ConfluenceLoader.Document{id: "123", text: "Content", metadata: %{title: "Page"}}}

new(id, text, metadata \\ %{})

@spec new(String.t(), String.t(), map()) :: t()

Creates a new Document.

Parameters

  • id: The unique identifier of the document
  • text: The text content of the document
  • metadata: Optional metadata map

Examples

iex> doc = ConfluenceLoader.Document.new("123", "This is the content", %{title: "My Page"})
%ConfluenceLoader.Document{id: "123", text: "This is the content", metadata: %{title: "My Page"}}

to_map(document)

@spec to_map(t()) :: map()

Converts the document to a map format suitable for JSON serialization.

Examples

iex> doc = ConfluenceLoader.Document.new("123", "Content", %{title: "Page"})
iex> ConfluenceLoader.Document.to_map(doc)
%{id: "123", text: "Content", metadata: %{title: "Page"}}