nfrax logonfrax

Infrastructure that just works. Ship products, not boilerplate.

Frameworks

  • svc-infra
  • ai-infra
  • fin-infra
  • robo-infra

Resources

  • Getting Started
  • What's New
  • Contributing

Community

  • GitHub

© 2026 nfrax. All rights reserved.

nfrax logonfrax
Start HereWhat's New
GitHub
fin-infra / API Reference

LLMCategorizer

from fin_infra.categorization.llm_layer import LLMCategorizer
View source
fin_infra.categorization.llm_layer

LLM-based transaction categorization (Layer 4). Uses ai-infra.llm.LLM with few-shot prompting and structured output. Caches predictions via svc-infra.cache to minimize API costs.

Args

provider: LLM provider ("google_genai", "openai", "anthropic") model_name: Model name (e.g., "gemini-2.5-flash", "gpt-4.1-mini") max_cost_per_day: Daily budget cap in USD (default $0.10) max_cost_per_month: Monthly budget cap in USD (default $2.00) cache_ttl: Cache TTL in seconds (default 24 hours) enable_personalization: Enable user context injection (default False)

Example

>>> categorizer = LLMCategorizer( ... provider="google_genai", ... model_name="gemini-2.5-flash", ... ) >>> prediction = await categorizer.categorize("UNKNOWN COFFEE CO") >>> print(prediction.category, prediction.confidence) Coffee Shops 0.85

Constructor
LLMCategorizer(provider: str = 'google_genai', model_name: str = 'gemini-2.5-flash', max_cost_per_day: float = 0.1, max_cost_per_month: float = 2.0, cache_ttl: int = 86400, enable_personalization: bool = False)
ParameterTypeDefaultDescription
providerstr'google_genai'—
model_namestr'gemini-2.5-flash'—
max_cost_per_dayfloat0.1—
max_cost_per_monthfloat2.0—
cache_ttlint86400—
enable_personalizationboolFalse—

Methods

On This Page

Constructorcategorizereset_daily_costreset_monthly_cost