utils

package
v0.0.0-...-b80bf06 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// please change the version when the version is updated
	WREN_PRODUCT_VERSION    string = "0.15.2"
	DOCKER_COMPOSE_YAML_URL string = "https://raw.githubusercontent.com/Canner/WrenAI/" + WREN_PRODUCT_VERSION + "/docker/docker-compose.yaml"
	DOCKER_COMPOSE_ENV_URL  string = "https://raw.githubusercontent.com/Canner/WrenAI/" + WREN_PRODUCT_VERSION + "/docker/.env.example"
	AI_SERVICE_CONFIG_URL   string = "https://raw.githubusercontent.com/Canner/WrenAI/" + WREN_PRODUCT_VERSION + "/docker/config.example.yaml"
)

Variables

This section is empty.

Functions

func CheckAIServiceStarted

func CheckAIServiceStarted(url string) error

func CheckDockerDaemonRunning

func CheckDockerDaemonRunning() (bool, error)

func CheckUIServiceStarted

func CheckUIServiceStarted(url string) error

func FindAvailablePort

func FindAvailablePort(defaultPort int) int

func IfPortUsedByAIService

func IfPortUsedByAIService(port int) bool

func IfPortUsedByWrenUI

func IfPortUsedByWrenUI(port int) bool

func OpenDockerDaemon

func OpenDockerDaemon() error

func Openbrowser

func Openbrowser(url string) error

func PrepareConfigFileForOpenAI

func PrepareConfigFileForOpenAI(projectDir string, generationModel string) error

func PrepareDockerFiles

func PrepareDockerFiles(openaiApiKey string, openaiGenerationModel string, hostPort int, aiPort int, projectDir string, telemetryEnabled bool, llmProvider string) error

func RunDockerCompose

func RunDockerCompose(projectName string, projectDir string, llmProvider string) error

RunDockerCompose starts Docker services for a project using docker-compose. It initializes Docker CLI, checks Docker engine availability, and runs docker-compose up. For custom LLM providers, it specifically recreates the wren-ai-service container.

Parameters:

  • projectName: Name of the Docker Compose project
  • projectDir: Directory containing docker-compose.yaml and .env files
  • llmProvider: Type of LLM provider (e.g., "custom" or default)

Returns an error if Docker initialization, configuration, or service startup fails. Supports both default and custom LLM provider configurations.

Example:

err := RunDockerCompose("wren", "/path/to/project", "openai")

Types

type OS

type OS int
const (
	// Windows is the Windows operating system.
	Windows OS = iota
	// Darwin is the Apple operating system.
	Darwin
	// Linux is the Linux operating system.
	Linux
	// Unknown is an unknown operating system.
	Unknown
)

func DetectOS

func DetectOS() OS

type WrenRC

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

func (*WrenRC) Read

func (w *WrenRC) Read(key string) (string, error)

read the value of a key from the rc file

func (*WrenRC) Set

func (w *WrenRC) Set(key string, value string, override bool) error

set a key value pair to the rc file

Jump to

Keyboard shortcuts

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