Gemini.Types.Live.SlidingWindow (GeminiEx v0.9.0)

Copy Markdown View Source

Sliding window context compression configuration.

The SlidingWindow method operates by discarding content at the beginning of the context window. The resulting context will always begin at the start of a USER role turn. System instructions and any prefix turns will always remain at the beginning of the result.

Fields

  • target_tokens - Target number of tokens to keep. Default is trigger_tokens/2

Example

%SlidingWindow{target_tokens: 8000}

Summary

Functions

Parses from API response.

Creates a new SlidingWindow configuration.

Converts to API format (camelCase).

Types

t()

@type t() :: %Gemini.Types.Live.SlidingWindow{target_tokens: integer() | nil}

Functions

from_api(data)

@spec from_api(map() | nil) :: t() | nil

Parses from API response.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new SlidingWindow configuration.

to_api(value)

@spec to_api(t() | map() | nil) :: map() | nil

Converts to API format (camelCase).

Accepts structs, maps with atom keys, or maps with string keys. Uses fetch_value to properly preserve falsey values like 0 or false.