model

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateModelRequest

type CreateModelRequest struct {
	ProviderType string          `json:"provider_type" validate:"required,oneof=OpenAI Anthropic Gemini xAI"`
	Name         string          `json:"name" validate:"required,min=1,max=255"`
	ModelID      string          `json:"model_id" validate:"required,min=1,max=255"`
	Parameters   ModelParameters `json:"parameters,omitempty"`
}

CreateModelRequest represents the request to create a new model

type Model

type Model struct {
	ID           uuid.UUID       `json:"id" db:"id"`
	ProjectID    uuid.UUID       `json:"project_id" db:"project_id"`
	ProviderType string          `json:"provider_type" db:"provider_type"`
	Name         string          `json:"name" db:"name"`
	ModelID      string          `json:"model_id" db:"model_id"` // e.g., "gpt-4.1", "gpt-4o"
	Parameters   ModelParameters `json:"parameters" db:"parameters"`
	CreatedAt    time.Time       `json:"created_at" db:"created_at"`
	UpdatedAt    time.Time       `json:"updated_at" db:"updated_at"`
}

Model represents a model configuration

type ModelParameters

type ModelParameters map[string]interface{}

ModelParameters represents model parameters as a flexible JSON map

func (ModelParameters) MarshalJSON

func (m ModelParameters) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*ModelParameters) Scan

func (m *ModelParameters) Scan(value interface{}) error

Scan implements the sql.Scanner interface for database/sql

func (*ModelParameters) UnmarshalJSON

func (m *ModelParameters) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

func (ModelParameters) Value

func (m ModelParameters) Value() (driver.Value, error)

Value implements the driver.Valuer interface for database/sql

type ModelRepo

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

ModelRepo handles database operations for models

func NewModelRepo

func NewModelRepo(db *sqlx.DB) *ModelRepo

NewModelRepo creates a new model repository

func (*ModelRepo) Create

func (r *ModelRepo) Create(ctx context.Context, projectID uuid.UUID, req *CreateModelRequest) (*Model, error)

Create creates a new model

func (*ModelRepo) Delete

func (r *ModelRepo) Delete(ctx context.Context, projectID, id uuid.UUID) error

Delete deletes a model

func (*ModelRepo) GetByID

func (r *ModelRepo) GetByID(ctx context.Context, projectID, id uuid.UUID) (*Model, error)

GetByID retrieves a model by ID

func (*ModelRepo) GetByName

func (r *ModelRepo) GetByName(ctx context.Context, projectID uuid.UUID, name string) (*Model, error)

GetByName retrieves a model by name

func (*ModelRepo) List

func (r *ModelRepo) List(ctx context.Context, projectID uuid.UUID, providerType *string) ([]*ModelWithProvider, error)

List retrieves all models with optional filtering by provider_type

func (*ModelRepo) Update

func (r *ModelRepo) Update(ctx context.Context, projectID, id uuid.UUID, req *UpdateModelRequest) (*Model, error)

Update updates a model

type ModelService

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

ModelService handles business logic for models

func NewModelService

func NewModelService(repo *ModelRepo) *ModelService

NewModelService creates a new model service

func (*ModelService) Create

func (s *ModelService) Create(ctx context.Context, projectID uuid.UUID, req *CreateModelRequest) (*Model, error)

Create creates a new model

func (*ModelService) Delete

func (s *ModelService) Delete(ctx context.Context, projectID, id uuid.UUID) error

Delete deletes a model

func (*ModelService) GetByID

func (s *ModelService) GetByID(ctx context.Context, projectID, id uuid.UUID) (*Model, error)

GetByID retrieves a model by ID

func (*ModelService) GetByName

func (s *ModelService) GetByName(ctx context.Context, projectID uuid.UUID, name string) (*Model, error)

GetByName retrieves a model by name

func (*ModelService) List

func (s *ModelService) List(ctx context.Context, projectID uuid.UUID, providerType *string) ([]*ModelWithProvider, error)

List retrieves all models with optional filtering

func (*ModelService) Update

func (s *ModelService) Update(ctx context.Context, projectID, id uuid.UUID, req *UpdateModelRequest) (*Model, error)

Update updates a model

type ModelWithProvider

type ModelWithProvider struct {
	Model
	ProviderType string `json:"provider_type" db:"provider_type"`
}

ModelWithProvider includes provider information

type UpdateModelRequest

type UpdateModelRequest struct {
	ProviderType *string          `json:"provider_type,omitempty" validate:"omitempty,oneof=OpenAI Anthropic Gemini xAI"`
	Name         *string          `json:"name,omitempty" validate:"omitempty,min=1,max=255"`
	ModelID      *string          `json:"model_id,omitempty" validate:"omitempty,min=1,max=255"`
	Parameters   *ModelParameters `json:"parameters,omitempty"`
}

UpdateModelRequest represents the request to update a model

Jump to

Keyboard shortcuts

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