registry

package
v6.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package registry provides model definitions for various AI service providers. This file contains static model definitions that can be used by clients when registering their supported models.

Package registry provides centralized model management for all AI service providers. It implements a dynamic model registry with reference counting to track active clients and automatically hide models when no clients are available or when quota is exceeded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModelInfo

type ModelInfo struct {
	// ID is the unique identifier for the model
	ID string `json:"id"`
	// Object type for the model (typically "model")
	Object string `json:"object"`
	// Created timestamp when the model was created
	Created int64 `json:"created"`
	// OwnedBy indicates the organization that owns the model
	OwnedBy string `json:"owned_by"`
	// Type indicates the model type (e.g., "claude", "gemini", "openai")
	Type string `json:"type"`
	// DisplayName is the human-readable name for the model
	DisplayName string `json:"display_name,omitempty"`
	// Name is used for Gemini-style model names
	Name string `json:"name,omitempty"`
	// Version is the model version
	Version string `json:"version,omitempty"`
	// Description provides detailed information about the model
	Description string `json:"description,omitempty"`
	// InputTokenLimit is the maximum input token limit
	InputTokenLimit int `json:"inputTokenLimit,omitempty"`
	// OutputTokenLimit is the maximum output token limit
	OutputTokenLimit int `json:"outputTokenLimit,omitempty"`
	// SupportedGenerationMethods lists supported generation methods
	SupportedGenerationMethods []string `json:"supportedGenerationMethods,omitempty"`
	// ContextLength is the context window size
	ContextLength int `json:"context_length,omitempty"`
	// MaxCompletionTokens is the maximum completion tokens
	MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
	// SupportedParameters lists supported parameters
	SupportedParameters []string `json:"supported_parameters,omitempty"`
}

ModelInfo represents information about an available model

func GetClaudeModels

func GetClaudeModels() []*ModelInfo

GetClaudeModels returns the standard Claude model definitions

func GetGeminiCLIModels

func GetGeminiCLIModels() []*ModelInfo

GetGeminiCLIModels returns the standard Gemini model definitions

func GetGeminiModels

func GetGeminiModels() []*ModelInfo

GetGeminiModels returns the standard Gemini model definitions

func GetIFlowModels added in v6.1.0

func GetIFlowModels() []*ModelInfo

func GetOpenAIModels

func GetOpenAIModels() []*ModelInfo

GetOpenAIModels returns the standard OpenAI model definitions

func GetQwenModels

func GetQwenModels() []*ModelInfo

GetQwenModels returns the standard Qwen model definitions

type ModelRegistration

type ModelRegistration struct {
	// Info contains the model metadata
	Info *ModelInfo
	// Count is the number of active clients that can provide this model
	Count int
	// LastUpdated tracks when this registration was last modified
	LastUpdated time.Time
	// QuotaExceededClients tracks which clients have exceeded quota for this model
	QuotaExceededClients map[string]*time.Time
	// Providers tracks available clients grouped by provider identifier
	Providers map[string]int
	// SuspendedClients tracks temporarily disabled clients keyed by client ID
	SuspendedClients map[string]string
}

ModelRegistration tracks a model's availability

type ModelRegistry

type ModelRegistry struct {
	// contains filtered or unexported fields
}

ModelRegistry manages the global registry of available models

func GetGlobalRegistry

func GetGlobalRegistry() *ModelRegistry

GetGlobalRegistry returns the global model registry instance

func (*ModelRegistry) CleanupExpiredQuotas

func (r *ModelRegistry) CleanupExpiredQuotas()

CleanupExpiredQuotas removes expired quota tracking entries

func (*ModelRegistry) ClearModelQuotaExceeded

func (r *ModelRegistry) ClearModelQuotaExceeded(clientID, modelID string)

ClearModelQuotaExceeded removes quota exceeded status for a model and client Parameters:

  • clientID: The client to clear quota status for
  • modelID: The model to clear quota status for

func (*ModelRegistry) GetAvailableModels

func (r *ModelRegistry) GetAvailableModels(handlerType string) []map[string]any

GetAvailableModels returns all models that have at least one available client Parameters:

  • handlerType: The handler type to filter models for (e.g., "openai", "claude", "gemini")

Returns:

  • []map[string]any: List of available models in the requested format

func (*ModelRegistry) GetModelCount

func (r *ModelRegistry) GetModelCount(modelID string) int

GetModelCount returns the number of available clients for a specific model Parameters:

  • modelID: The model ID to check

Returns:

  • int: Number of available clients for the model

func (*ModelRegistry) GetModelProviders

func (r *ModelRegistry) GetModelProviders(modelID string) []string

GetModelProviders returns provider identifiers that currently supply the given model Parameters:

  • modelID: The model ID to check

Returns:

  • []string: Provider identifiers ordered by availability count (descending)

func (*ModelRegistry) RegisterClient

func (r *ModelRegistry) RegisterClient(clientID, clientProvider string, models []*ModelInfo)

RegisterClient registers a client and its supported models Parameters:

  • clientID: Unique identifier for the client
  • clientProvider: Provider name (e.g., "gemini", "claude", "openai")
  • models: List of models that this client can provide

func (*ModelRegistry) ResumeClientModel

func (r *ModelRegistry) ResumeClientModel(clientID, modelID string)

ResumeClientModel clears a previous suspension so the client counts toward availability again. Parameters:

  • clientID: The client to resume
  • modelID: The model being resumed

func (*ModelRegistry) SetModelQuotaExceeded

func (r *ModelRegistry) SetModelQuotaExceeded(clientID, modelID string)

SetModelQuotaExceeded marks a model as quota exceeded for a specific client Parameters:

  • clientID: The client that exceeded quota
  • modelID: The model that exceeded quota

func (*ModelRegistry) SuspendClientModel

func (r *ModelRegistry) SuspendClientModel(clientID, modelID, reason string)

SuspendClientModel marks a client's model as temporarily unavailable until explicitly resumed. Parameters:

  • clientID: The client to suspend
  • modelID: The model affected by the suspension
  • reason: Optional description for observability

func (*ModelRegistry) UnregisterClient

func (r *ModelRegistry) UnregisterClient(clientID string)

UnregisterClient removes a client and decrements counts for its models Parameters:

  • clientID: Unique identifier for the client to remove

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL