Skip to contents

Configures an httr2-based translator targeting a local Ollama /api/chat server with JSON-only output formatting, URL validation (HTTPS or local loopback HTTP only, blocking invalid ports and metadata hosts), strict model and temperature validation, bounded timeouts and response sizes, and strict validation via validate_spec_ir().

Usage

translator_ollama(
  model = "llama3.1",
  base_url = "http://localhost:11434",
  temperature = 0,
  timeout = 120,
  max_response_bytes = 524288L
)

Arguments

model

Local Ollama model name (e.g., "llama3.1").

base_url

Ollama server URL (defaults to "http://localhost:11434").

temperature

Numeric sampling temperature in [0, 2] (defaults to 0).

timeout

Numeric HTTP timeout in seconds (1 to 600).

max_response_bytes

Maximum permitted HTTP response size in bytes (defaults to 524288L, i.e., 512 KB).

Value

An S3 object of class c("spec_translator_ollama", "spec_translator").

Examples

tr <- translator_ollama(model = "llama3.1")
print(tr)
#> <spec_translator:ollama>
#> model: llama3.1 | endpoint: http://localhost:11434
#> timeout: 120s | max_bytes: 524288