openwebui

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError represents an error from the Open WebUI API

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface for APIError

type AddFileRequest

type AddFileRequest struct {
	FileID string `json:"file_id"`
}

AddFileRequest represents the request to add a file to knowledge base

type Client

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

Client represents an HTTP client for the Open WebUI API

func NewClient

func NewClient(baseURL, apiKey string) *Client

NewClient creates a new API client instance

func (*Client) AddFileToKnowledge

func (c *Client) AddFileToKnowledge(knowledgeID, fileID string) error

AddFileToKnowledge associates an uploaded file with a knowledge base

func (*Client) CreateKnowledge

func (c *Client) CreateKnowledge(form *KnowledgeForm) (*KnowledgeCreateResponse, error)

CreateKnowledge creates a new knowledge base

func (*Client) ExportModels added in v0.2.0

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

ExportModels fetches all models via /api/v1/models/export

func (*Client) GetFile

func (c *Client) GetFile(fileID string) (*FileData, error)

GetFile fetches a single file by ID

func (*Client) GetKnowledgeByID

func (c *Client) GetKnowledgeByID(id string) (*KnowledgeBase, error)

GetKnowledgeByID fetches a specific knowledge base with its files

func (*Client) GetModelByID added in v0.2.0

func (c *Client) GetModelByID(id string) (*Model, error)

GetModelByID fetches a specific model by ID

func (*Client) ImportModels added in v0.2.0

func (c *Client) ImportModels(models []Model) error

ImportModels posts models to /api/v1/models/import

func (*Client) ListKnowledge

func (c *Client) ListKnowledge() ([]KnowledgeBase, error)

ListKnowledge fetches all knowledge bases from the API

func (*Client) RemoveFileFromKnowledge

func (c *Client) RemoveFileFromKnowledge(knowledgeID, fileID string) error

RemoveFileFromKnowledge removes a file from a knowledge base

func (*Client) UpdateKnowledge

func (c *Client) UpdateKnowledge(id string, form *KnowledgeForm) error

UpdateKnowledge updates an existing knowledge base

func (*Client) UploadFile

func (c *Client) UploadFile(filename string, content []byte) (*FileUploadResponse, error)

UploadFile uploads a file via multipart/form-data

type FileContent

type FileContent struct {
	Status  string `json:"status"`
	Content string `json:"content"`
}

FileContent contains the actual file content

type FileData

type FileData struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	Hash          string                 `json:"hash"`
	Filename      string                 `json:"filename"`
	Path          string                 `json:"path"`
	Data          *FileContent           `json:"data"`
	Meta          FileMeta               `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control"`
	CreatedAt     int64                  `json:"created_at"`
	UpdatedAt     int64                  `json:"updated_at"`
}

FileData represents a complete file with content from the API

type FileExistsError

type FileExistsError struct {
	Path string
}

FileExistsError indicates a backup file already exists

func (*FileExistsError) Error

func (e *FileExistsError) Error() string

Error implements the error interface for FileExistsError

type FileMeta

type FileMeta struct {
	Name           string                 `json:"name"`
	ContentType    string                 `json:"content_type"`
	Size           int64                  `json:"size"`
	Data           map[string]interface{} `json:"data"`
	CollectionName string                 `json:"collection_name"`
}

FileMeta contains file-specific metadata

type FileMetadata

type FileMetadata struct {
	ID        string   `json:"id"`
	Meta      FileMeta `json:"meta"`
	CreatedAt int64    `json:"created_at"`
	UpdatedAt int64    `json:"updated_at"`
}

FileMetadata represents file metadata from the API

type FileUploadResponse

type FileUploadResponse struct {
	ID        string   `json:"id"`
	UserID    string   `json:"user_id"`
	Filename  string   `json:"filename"`
	Meta      FileMeta `json:"meta"`
	CreatedAt int64    `json:"created_at"`
	UpdatedAt int64    `json:"updated_at"`
}

FileUploadResponse represents the response from uploading a file

type KnowledgeBase

type KnowledgeBase struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	Name          string                 `json:"name"`
	Description   string                 `json:"description"`
	Data          *KnowledgeData         `json:"data"`
	Meta          map[string]interface{} `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control"`
	CreatedAt     int64                  `json:"created_at"`
	UpdatedAt     int64                  `json:"updated_at"`
	Files         []FileMetadata         `json:"files"`
}

KnowledgeBase represents a knowledge base from the API

type KnowledgeCreateResponse

type KnowledgeCreateResponse struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	Name          string                 `json:"name"`
	Description   string                 `json:"description"`
	Data          *KnowledgeData         `json:"data"`
	Meta          map[string]interface{} `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control"`
	CreatedAt     int64                  `json:"created_at"`
	UpdatedAt     int64                  `json:"updated_at"`
}

KnowledgeCreateResponse represents the response from creating a knowledge base

type KnowledgeData

type KnowledgeData struct {
	FileIDs []string `json:"file_ids"`
}

KnowledgeData contains file IDs associated with the knowledge base

type KnowledgeExistsError

type KnowledgeExistsError struct {
	Name string
}

KnowledgeExistsError indicates a knowledge base with the name already exists

func (*KnowledgeExistsError) Error

func (e *KnowledgeExistsError) Error() string

Error implements the error interface for KnowledgeExistsError

type KnowledgeForm

type KnowledgeForm struct {
	Name          string                 `json:"name"`
	Description   string                 `json:"description"`
	Data          *KnowledgeData         `json:"data,omitempty"`
	AccessControl map[string]interface{} `json:"access_control,omitempty"`
}

KnowledgeForm represents the request body for creating/updating knowledge

type KnowledgeItem added in v0.2.0

type KnowledgeItem struct {
	Type string                 `json:"type"` // "file" or "collection"
	Data map[string]interface{} `json:"-"`    // Raw data for flexibility
}

KnowledgeItem represents a single knowledge item (file or collection)

type Model added in v0.2.0

type Model struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	BaseModelID   *string                `json:"base_model_id"`
	Name          string                 `json:"name"`
	Params        map[string]interface{} `json:"params"`
	Meta          ModelMeta              `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control"`
	IsActive      bool                   `json:"is_active"`
	UpdatedAt     int64                  `json:"updated_at"`
	CreatedAt     int64                  `json:"created_at"`
}

Model represents a model from the Open WebUI API

type ModelForm added in v0.2.0

type ModelForm struct {
	ID            string                 `json:"id"`
	BaseModelID   *string                `json:"base_model_id,omitempty"`
	Name          string                 `json:"name"`
	Params        map[string]interface{} `json:"params"`
	Meta          ModelMeta              `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control,omitempty"`
	IsActive      bool                   `json:"is_active"`
}

ModelForm for creating/updating models

type ModelMeta added in v0.2.0

type ModelMeta struct {
	ProfileImageURL string                   `json:"profile_image_url,omitempty"`
	Description     *string                  `json:"description,omitempty"`
	Capabilities    map[string]interface{}   `json:"capabilities,omitempty"`
	Knowledge       []map[string]interface{} `json:"knowledge,omitempty"` // Can be files or collections
	Tags            []string                 `json:"tags,omitempty"`
}

ModelMeta contains model metadata including knowledge base references

Jump to

Keyboard shortcuts

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