desktop

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound           = errors.New("model not found")
	ErrServiceUnavailable = errors.New("service unavailable")
)
View Source
var Version = "dev"

Functions

func DockerClientForContext added in v0.1.21

func DockerClientForContext(cli *command.DockerCli, name string) (*clientpkg.Client, error)

DockerClientForContext creates a Docker client for the specified context.

Types

type Client

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

func New

func New(modelRunner *ModelRunnerContext) *Client

func (*Client) Chat

func (c *Client) Chat(model, prompt string) error

func (*Client) Inspect

func (c *Client) Inspect(model string) (Model, error)

func (*Client) InspectOpenAI

func (c *Client) InspectOpenAI(model string) (OpenAIModel, error)

func (*Client) List

func (c *Client) List() ([]Model, error)

func (*Client) ListOpenAI

func (c *Client) ListOpenAI() (OpenAIModelList, error)

func (*Client) Pull

func (c *Client) Pull(model string, progress func(string)) (string, bool, error)

func (*Client) Push

func (c *Client) Push(model string, progress func(string)) (string, bool, error)

func (*Client) Remove

func (c *Client) Remove(models []string, force bool) (string, error)

func (*Client) Status

func (c *Client) Status() Status

func (*Client) Tag

func (c *Client) Tag(source, targetRepo, targetTag string) (string, error)

type Config

type Config struct {
	Format       Format `json:"format,omitempty"`
	Quantization string `json:"quantization,omitempty"`
	Parameters   string `json:"parameters,omitempty"`
	Architecture string `json:"architecture,omitempty"`
	Size         string `json:"size,omitempty"`
}

type DockerHttpClient

type DockerHttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Format

type Format string

TODO: To be replaced by the Model struct from pianta's common/pkg/inference/models/api.go. (https://github.com/docker/pinata/pull/33331)

type Model

type Model struct {
	// ID is the globally unique model identifier.
	ID string `json:"id"`
	// Tags are the list of tags associated with the model.
	Tags []string `json:"tags"`
	// Created is the Unix epoch timestamp corresponding to the model creation.
	Created int64 `json:"created"`
	// Config describes the model.
	Config Config `json:"config"`
}

type ModelRunnerContext added in v0.1.20

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

ModelRunnerContext encodes the operational context of a Model CLI command and provides facilities for inspecting and interacting with the Model Runner.

func DetectContext added in v0.1.20

func DetectContext(cli *command.DockerCli) (*ModelRunnerContext, error)

DetectContext determines the current Docker Model Runner context.

func NewContextForMock added in v0.1.20

func NewContextForMock(client DockerHttpClient) *ModelRunnerContext

NewContextForMock is a ModelRunnerContext constructor exposed only for the purposes of mock testing.

func (*ModelRunnerContext) Client added in v0.1.20

Client returns an HTTP client appropriate for accessing the model runner.

func (*ModelRunnerContext) EngineKind added in v0.1.20

func (c *ModelRunnerContext) EngineKind() ModelRunnerEngineKind

EngineKind returns the Docker engine kind associated with the model runner.

func (*ModelRunnerContext) URL added in v0.1.20

func (c *ModelRunnerContext) URL(path string) string

URL constructs a URL string appropriate for the model runner.

type ModelRunnerEngineKind added in v0.1.20

type ModelRunnerEngineKind uint8

ModelRunnerEngineKind encodes the kind of Docker engine associated with the model runner context.

const (
	// ModelRunnerEngineKindMoby represents a non-Desktop/Cloud engine on which
	// the Model CLI command is responsible for managing a Model Runner.
	ModelRunnerEngineKindMoby ModelRunnerEngineKind = iota
	// ModelRunnerEngineKindMobyManual represents a non-Desktop/Cloud engine
	// that's explicitly targeted by a MODEL_RUNNER_HOST environment variable on
	// which the user is responsible for managing a Model Runner.
	ModelRunnerEngineKindMobyManual
	// ModelRunnerEngineKindDesktop represents a Docker Desktop engine. It only
	// refers to a Docker Desktop Linux engine, i.e. not a Windows container
	// engine in the case of Docker Desktop for Windows.
	ModelRunnerEngineKindDesktop
	// ModelRunnerEngineKindCloud represents a Docker Cloud engine.
	ModelRunnerEngineKindCloud
)

func (ModelRunnerEngineKind) String added in v0.1.20

func (k ModelRunnerEngineKind) String() string

String returns a human-readable engine kind description.

type OpenAIChatMessage

type OpenAIChatMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type OpenAIChatRequest

type OpenAIChatRequest struct {
	Model    string              `json:"model"`
	Messages []OpenAIChatMessage `json:"messages"`
	Stream   bool                `json:"stream"`
}

type OpenAIChatResponse

type OpenAIChatResponse struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Created int64  `json:"created"`
	Model   string `json:"model"`
	Choices []struct {
		Delta struct {
			Content string `json:"content"`
			Role    string `json:"role,omitempty"`
		} `json:"delta"`
		Index        int    `json:"index"`
		FinishReason string `json:"finish_reason"`
	} `json:"choices"`
}

type OpenAIModel

type OpenAIModel struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Created int64  `json:"created"`
	OwnedBy string `json:"owned_by"`
}

type OpenAIModelList

type OpenAIModelList struct {
	Object string         `json:"object"`
	Data   []*OpenAIModel `json:"data"`
}

type ProgressMessage

type ProgressMessage struct {
	Type    string `json:"type"`    // "progress", "success", or "error"
	Message string `json:"message"` // Human-readable message
}

ProgressMessage represents a message sent during model pull operations

type Status

type Status struct {
	Running bool   `json:"running"`
	Status  []byte `json:"status"`
	Error   error  `json:"error"`
}

Jump to

Keyboard shortcuts

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