Documentation
¶
Index ¶
- type ChatCompletionRequest
- type ChatCompletionResponse
- type ChatCompletionStreamResponse
- type Choice
- type Delta
- type Handler
- type Message
- type Model
- type OpenAIModelsResponse
- type Registry
- type Service
- func (s *Service) GetHandler() *Handler
- func (s *Service) GetModel(id string) *VirtualModel
- func (s *Service) GetRegistry() *Registry
- func (s *Service) ListModels() []Model
- func (s *Service) RegisterModel(vm *VirtualModel) error
- func (s *Service) SetupRoutes(group *gin.RouterGroup)
- func (s *Service) UnregisterModel(id string)
- type StreamChoice
- type Usage
- type VirtualModel
- type VirtualModelConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Messages []Message `json:"messages"`
Model string `json:"model"`
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
Stream bool `json:"stream,omitempty"`
}
ChatCompletionRequest represents an OpenAI-compatible chat completion request
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []Choice `json:"choices"`
Usage Usage `json:"usage"`
}
ChatCompletionResponse represents an OpenAI-compatible chat completion response
type ChatCompletionStreamResponse ¶
type ChatCompletionStreamResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []StreamChoice `json:"choices"`
}
ChatCompletionStreamResponse represents a streaming chunk in OpenAI format
type Choice ¶
type Choice struct {
Index int `json:"index"`
Message Message `json:"message"`
FinishReason string `json:"finish_reason"`
}
Choice represents a choice in the response
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles HTTP requests for virtual models
func NewHandler ¶
NewHandler creates a new virtual model handler
func (*Handler) ChatCompletions ¶
ChatCompletions handles the POST /virtual/v1/chat/completions endpoint
func (*Handler) ListModels ¶
ListModels handles the GET /virtual/v1/models endpoint
type Model ¶
type Model struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
OwnedBy string `json:"owned_by"`
}
Model represents a virtual model in the models list (OpenAI-compatible format)
type OpenAIModelsResponse ¶
OpenAIModelsResponse represents OpenAI's models API response format
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages virtual models
func (*Registry) Get ¶
func (r *Registry) Get(id string) *VirtualModel
Get retrieves a virtual model by ID
func (*Registry) List ¶
func (r *Registry) List() []*VirtualModel
List returns all registered virtual models
func (*Registry) ListModels ¶
ListModels returns all registered models as Model slices
func (*Registry) Register ¶
func (r *Registry) Register(vm *VirtualModel) error
Register registers a virtual model
func (*Registry) RegisterDefaults ¶
func (r *Registry) RegisterDefaults()
RegisterDefaults registers default virtual models
func (*Registry) Unregister ¶
Unregister unregisters a virtual model
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages the virtual model service
func (*Service) GetHandler ¶
GetHandler returns the HTTP handler
func (*Service) GetModel ¶
func (s *Service) GetModel(id string) *VirtualModel
GetModel retrieves a virtual model by ID
func (*Service) GetRegistry ¶
GetRegistry returns the model registry
func (*Service) ListModels ¶
ListModels returns all registered models
func (*Service) RegisterModel ¶
func (s *Service) RegisterModel(vm *VirtualModel) error
RegisterModel registers a new virtual model
func (*Service) SetupRoutes ¶
func (s *Service) SetupRoutes(group *gin.RouterGroup)
SetupRoutes sets up the virtual model routes on a Gin router group
func (*Service) UnregisterModel ¶
UnregisterModel unregisters a virtual model
type StreamChoice ¶
type StreamChoice struct {
Index int `json:"index"`
Delta Delta `json:"delta"`
FinishReason *string `json:"finish_reason"`
}
StreamChoice represents a choice in a streaming response
type Usage ¶
type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
}
Usage represents token usage information
type VirtualModel ¶
type VirtualModel struct {
// contains filtered or unexported fields
}
VirtualModel represents a registered virtual model
func NewVirtualModel ¶
func NewVirtualModel(cfg *VirtualModelConfig) *VirtualModel
NewVirtualModel creates a new virtual model
func (*VirtualModel) GetContent ¶
func (vm *VirtualModel) GetContent() string
GetContent returns the response content
func (*VirtualModel) GetDelay ¶
func (vm *VirtualModel) GetDelay() time.Duration
GetDelay returns the response delay
func (*VirtualModel) GetName ¶
func (vm *VirtualModel) GetName() string
GetName returns the model name
func (*VirtualModel) GetStreamChunks ¶
func (vm *VirtualModel) GetStreamChunks() []string
GetStreamChunks returns the streaming chunks
func (*VirtualModel) ToModel ¶
func (vm *VirtualModel) ToModel() Model
ToModel converts to Model type for API response