SuperPi.AI.VirtualModel (super_pi v0.1.0)

Copy Markdown View Source

Virtual Model Router and Prompt-Cache Session Affinity Manager (spec.md §4, Step 5).

Provides:

  • Virtual model aliases ("fast", "balanced", "deep", "coding") that dynamically resolve to concrete {provider, model_id, thinking_budget} tuples based on task phase, complexity, or fallback health.
  • Prompt-cache session affinity via pi.provider (UUIDv7): preserves the same sessionId across linear turns and allocates a fresh UUIDv7 when a conversation forks.

Summary

Functions

Ensures the conversation has a pi.provider document with a stable sessionId (UUIDv7) for LLM prompt-cache affinity (spec.md §4.3).

Resolves a virtual model name (or explicit "provider/model" string) into a normalized routing descriptor %{provider: atom(), model: String.t(), thinking_budget: non_neg_integer()}.

Functions

ensure_provider_session!(conversation_id, provider, model)

Ensures the conversation has a pi.provider document with a stable sessionId (UUIDv7) for LLM prompt-cache affinity (spec.md §4.3).

resolve(model_spec, opts \\ [])

Resolves a virtual model name (or explicit "provider/model" string) into a normalized routing descriptor %{provider: atom(), model: String.t(), thinking_budget: non_neg_integer()}.