restapi

package
v1.4.132 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewModelsHandler added in v1.4.112

func NewModelsHandler(r *gin.Engine, vendorManager *ai.VendorsManager)

func Serve

func Serve(registry *core.PluginRegistry, address string) (err error)

func ServeOllama added in v1.4.124

func ServeOllama(registry *core.PluginRegistry, address string, version string) (err error)

Types

type APIConvert added in v1.4.124

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

type ChatHandler added in v1.4.112

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

func NewChatHandler added in v1.4.112

func NewChatHandler(r *gin.Engine, registry *core.PluginRegistry, db *fsdb.Db) *ChatHandler

func (*ChatHandler) HandleChat added in v1.4.112

func (h *ChatHandler) HandleChat(c *gin.Context)

type ChatRequest added in v1.4.112

type ChatRequest struct {
	Prompts            []PromptRequest `json:"prompts"`
	common.ChatOptions                 // Embed the ChatOptions from common package
}

type ConfigHandler added in v1.4.112

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

ConfigHandler defines the handler for configuration-related operations

func NewConfigHandler added in v1.4.112

func NewConfigHandler(r *gin.Engine, db *fsdb.Db) *ConfigHandler

func (*ConfigHandler) GetConfig added in v1.4.112

func (h *ConfigHandler) GetConfig(c *gin.Context)

func (*ConfigHandler) UpdateConfig added in v1.4.112

func (h *ConfigHandler) UpdateConfig(c *gin.Context)

type ContextsHandler

type ContextsHandler struct {
	*StorageHandler[fsdb.Context]
	// contains filtered or unexported fields
}

ContextsHandler defines the handler for contexts-related operations

func NewContextsHandler

func NewContextsHandler(r *gin.Engine, contexts *fsdb.ContextsEntity) (ret *ContextsHandler)

NewContextsHandler creates a new ContextsHandler

type FabricResponseFormat added in v1.4.124

type FabricResponseFormat struct {
	Type    string `json:"type"`
	Format  string `json:"format"`
	Content string `json:"content"`
}

type Model added in v1.4.124

type Model struct {
	Details    ModelDetails `json:"details"`
	Digest     string       `json:"digest"`
	Model      string       `json:"model"`
	ModifiedAt string       `json:"modified_at"`
	Name       string       `json:"name"`
	Size       int64        `json:"size"`
}

type ModelDetails added in v1.4.124

type ModelDetails struct {
	Families          []string `json:"families"`
	Family            string   `json:"family"`
	Format            string   `json:"format"`
	ParameterSize     string   `json:"parameter_size"`
	ParentModel       string   `json:"parent_model"`
	QuantizationLevel string   `json:"quantization_level"`
}

type ModelsHandler added in v1.4.112

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

func (*ModelsHandler) GetModelNames added in v1.4.112

func (h *ModelsHandler) GetModelNames(c *gin.Context)

type OllamaMessage added in v1.4.124

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

type OllamaModel added in v1.4.124

type OllamaModel struct {
	Models []Model `json:"models"`
}

type OllamaRequestBody added in v1.4.124

type OllamaRequestBody struct {
	Messages []OllamaMessage `json:"messages"`
	Model    string          `json:"model"`
	Options  struct {
	} `json:"options"`
	Stream bool `json:"stream"`
}

type OllamaResponse added in v1.4.124

type OllamaResponse struct {
	Model     string `json:"model"`
	CreatedAt string `json:"created_at"`
	Message   struct {
		Role    string `json:"role"`
		Content string `json:"content"`
	} `json:"message"`
	DoneReason         string `json:"done_reason,omitempty"`
	Done               bool   `json:"done"`
	TotalDuration      int64  `json:"total_duration,omitempty"`
	LoadDuration       int    `json:"load_duration,omitempty"`
	PromptEvalCount    int    `json:"prompt_eval_count,omitempty"`
	PromptEvalDuration int    `json:"prompt_eval_duration,omitempty"`
	EvalCount          int    `json:"eval_count,omitempty"`
	EvalDuration       int64  `json:"eval_duration,omitempty"`
}

type PatternsHandler

type PatternsHandler struct {
	*StorageHandler[fsdb.Pattern]
	// contains filtered or unexported fields
}

PatternsHandler defines the handler for patterns-related operations

func NewPatternsHandler

func NewPatternsHandler(r *gin.Engine, patterns *fsdb.PatternsEntity) (ret *PatternsHandler)

NewPatternsHandler creates a new PatternsHandler

func (*PatternsHandler) Get

func (h *PatternsHandler) Get(c *gin.Context)

Get handles the GET /patterns/:name route

type PromptRequest added in v1.4.112

type PromptRequest struct {
	UserInput   string `json:"userInput"`
	Vendor      string `json:"vendor"`
	Model       string `json:"model"`
	ContextName string `json:"contextName"`
	PatternName string `json:"patternName"`
}

type SessionsHandler

type SessionsHandler struct {
	*StorageHandler[fsdb.Session]
	// contains filtered or unexported fields
}

SessionsHandler defines the handler for sessions-related operations

func NewSessionsHandler

func NewSessionsHandler(r *gin.Engine, sessions *fsdb.SessionsEntity) (ret *SessionsHandler)

NewSessionsHandler creates a new SessionsHandler

type StorageHandler

type StorageHandler[T any] struct {
	// contains filtered or unexported fields
}

StorageHandler defines the handler for storage-related operations

func NewStorageHandler

func NewStorageHandler[T any](r *gin.Engine, entityType string, storage db.Storage[T]) (ret *StorageHandler[T])

NewStorageHandler creates a new StorageHandler

func (*StorageHandler[T]) Delete

func (h *StorageHandler[T]) Delete(c *gin.Context)

Delete handles the DELETE /storage/:name route

func (*StorageHandler[T]) Exists

func (h *StorageHandler[T]) Exists(c *gin.Context)

Exists handles the GET /storage/exists/:name route

func (*StorageHandler[T]) Get

func (h *StorageHandler[T]) Get(c *gin.Context)

Get handles the GET /storage/:name route

func (*StorageHandler[T]) GetNames

func (h *StorageHandler[T]) GetNames(c *gin.Context)

GetNames handles the GET /storage/names route

func (*StorageHandler[T]) Rename

func (h *StorageHandler[T]) Rename(c *gin.Context)

Rename handles the PUT /storage/rename/:oldName/:newName route

func (*StorageHandler[T]) Save

func (h *StorageHandler[T]) Save(c *gin.Context)

Save handles the POST /storage/save/:name route

type StreamResponse added in v1.4.112

type StreamResponse struct {
	Type    string `json:"type"`    // "content", "error", "complete"
	Format  string `json:"format"`  // "markdown", "mermaid", "plain"
	Content string `json:"content"` // The actual content
}

Jump to

Keyboard shortcuts

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