Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - func AliasFromModelID(modelID string) string
 - func EnsureGeminiWebAliasMap()
 - func EqualMessages(a, b []Message) bool
 - func GetGeminiWebAliasedModels() []*registry.ModelInfo
 - func HashConversationForAccount(clientID, model string, msgs []StoredMessage) string
 - func HashConversationGlobal(model string, msgs []StoredMessage) string
 - func HashConversationWithPrefix(prefix, model string, msgs []StoredMessage) string
 - func MapAliasToUnderlying(name string) string
 - func NormalizeModel(model string) string
 - func RemoveMatch(hash string) error
 - func RemoveMatchForLabel(hash, label string) error
 - func RemoveMatchesByLabel(label string) error
 - func RemoveThinkTags(s string) string
 - func Sha256Hex(s string) string
 - func StoreConversation(label, model string, msgs []Message, metadata []string) error
 - func StoreMatch(hash string, record MatchRecord) error
 - type MatchRecord
 - type MatchResult
 - type Message
 - type PrefixHash
 - type StoredMessage
 
Constants ¶
const ( MetadataMessagesKey = "gemini_web_messages" MetadataMatchKey = "gemini_web_match" )
Variables ¶
This section is empty.
Functions ¶
func AliasFromModelID ¶
AliasFromModelID mirrors the original helper for deriving alias IDs.
func EnsureGeminiWebAliasMap ¶
func EnsureGeminiWebAliasMap()
EnsureGeminiWebAliasMap populates the alias map once.
func EqualMessages ¶
EqualMessages compares two message slices for equality.
func GetGeminiWebAliasedModels ¶
GetGeminiWebAliasedModels returns alias metadata for registry exposure.
func HashConversationForAccount ¶
func HashConversationForAccount(clientID, model string, msgs []StoredMessage) string
HashConversationForAccount keeps compatibility with the per-account hash previously used.
func HashConversationGlobal ¶
func HashConversationGlobal(model string, msgs []StoredMessage) string
HashConversationGlobal produces a hash suitable for cross-account lookups.
func HashConversationWithPrefix ¶
func HashConversationWithPrefix(prefix, model string, msgs []StoredMessage) string
HashConversationWithPrefix computes a conversation hash using the provided prefix (client identifier) and model.
func MapAliasToUnderlying ¶
MapAliasToUnderlying normalizes a model alias to its underlying identifier.
func NormalizeModel ¶
NormalizeModel returns the canonical identifier used for hashing.
func RemoveMatch ¶
RemoveMatch deletes all mappings for the given hash (all labels and legacy key).
func RemoveMatchForLabel ¶
RemoveMatchForLabel deletes the mapping for the given hash and label only.
func RemoveMatchesByLabel ¶
RemoveMatchesByLabel removes all entries associated with the specified label.
func RemoveThinkTags ¶
RemoveThinkTags strips <think>...</think> blocks and trims whitespace.
func StoreConversation ¶
StoreConversation updates all hashes representing the provided conversation snapshot.
func StoreMatch ¶
func StoreMatch(hash string, record MatchRecord) error
StoreMatch persists or updates a conversation hash mapping.
Types ¶
type MatchRecord ¶
type MatchRecord struct {
	AccountLabel string   `json:"account_label"`
	Metadata     []string `json:"metadata,omitempty"`
	PrefixLen    int      `json:"prefix_len"`
	UpdatedAt    int64    `json:"updated_at"`
}
    MatchRecord stores persisted mapping metadata for a conversation prefix.
func LookupMatch ¶
func LookupMatch(hash string) (MatchRecord, bool, error)
LookupMatch retrieves a stored mapping. It prefers namespaced entries (hash:label). If multiple labels exist for the same hash, it returns not found to avoid redirecting to the wrong credential. Falls back to legacy single-key entries if present.
type MatchResult ¶
type MatchResult struct {
	Hash   string
	Record MatchRecord
	Model  string
}
    MatchResult combines a persisted record with the hash that produced it.
type Message ¶
Message represents a minimal role-text pair used for hashing and comparison.
func ExtractMessages ¶
ExtractMessages attempts to build a message list from the inbound request payload.
func SanitizeAssistantMessages ¶
SanitizeAssistantMessages removes think tags from assistant messages while leaving others untouched.
func StoredToMessages ¶
func StoredToMessages(msgs []StoredMessage) []Message
StoredToMessages converts stored messages back into the in-memory representation.
type PrefixHash ¶
PrefixHash represents a hash candidate for a specific prefix length.
func BuildLookupHashes ¶
func BuildLookupHashes(model string, msgs []Message) []PrefixHash
BuildLookupHashes generates hash candidates ordered from longest to shortest prefix.
func BuildStorageHashes ¶
func BuildStorageHashes(model string, msgs []Message) []PrefixHash
BuildStorageHashes returns hashes representing the full conversation snapshot.
type StoredMessage ¶
type StoredMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
	Name    string `json:"name,omitempty"`
}
    StoredMessage mirrors the persisted conversation message structure.
func ToStoredMessages ¶
func ToStoredMessages(msgs []Message) []StoredMessage
ToStoredMessages converts in-memory messages into the persisted representation.