cli

package
v1.4.316 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 32 Imported by: 0

README

YAML Configuration Support

Overview

Fabric now supports YAML configuration files for commonly used options. This allows users to persist settings and share configurations across multiple runs.

Usage

Use the --config flag to specify a YAML configuration file:

fabric --config ~/.config/fabric/config.yaml "Tell me about APIs"

Configuration Precedence

  1. CLI flags (highest priority)
  2. YAML config values
  3. Default values (lowest priority)

Supported Configuration Options

# Model selection
model: gpt-4
modelContextLength: 4096

# Model parameters
temperature: 0.7
topp: 0.9
presencepenalty: 0.0
frequencypenalty: 0.0
seed: 42

# Pattern selection
pattern: analyze  # Use pattern name or filename

# Feature flags
stream: true
raw: false

Rules and Behavior

  • Only long flag names are supported in YAML (e.g., temperature not -t)
  • CLI flags always override YAML values
  • Unknown YAML declarations are ignored
  • If a declaration appears multiple times in YAML, the last one wins
  • The order of YAML declarations doesn't matter

Type Conversions

The following string-to-type conversions are supported:

  • String to number: "42"42
  • String to float: "42.5"42.5
  • String to boolean: "true"true

Example Config

# ~/.config/fabric/config.yaml
model: gpt-4
temperature: 0.8
pattern: analyze
stream: true
topp: 0.95
presencepenalty: 0.1
frequencypenalty: 0.2

CLI Override Example

# Override temperature from config
fabric --config ~/.config/fabric/config.yaml --temperature 0.9 "Query"

Documentation

Index

Constants

View Source
const ConfigDirPerms os.FileMode = 0755
View Source
const EnvFilePerms os.FileMode = 0644

Variables

This section is empty.

Functions

func AppendMessage

func AppendMessage(message string, newMessage string) (ret string)

func Cli

func Cli(version string) (err error)

Cli Controls the cli. It takes in the flags and runs the appropriate functions

func CopyToClipboard

func CopyToClipboard(message string) (err error)

func CreateAudioOutputFile added in v1.4.267

func CreateAudioOutputFile(audioData []byte, fileName string) (err error)

CreateAudioOutputFile creates a binary file for audio data

func CreateOutputFile

func CreateOutputFile(message string, fileName string) (err error)

func CustomHelpHandler added in v1.4.310

func CustomHelpHandler(parser *flags.Parser, writer io.Writer)

CustomHelpHandler handles help output with translations

func IsAudioFormat added in v1.4.267

func IsAudioFormat(fileName string) bool

IsAudioFormat checks if the filename suggests an audio format

func WriteOutput

func WriteOutput(message string, outputFile string) (err error)

Types

type Flags

type Flags struct {
	Pattern                         string               `short:"p" long:"pattern" yaml:"pattern" description:"Choose a pattern from the available patterns" default:""`
	PatternVariables                map[string]string    `short:"v" long:"variable" description:"Values for pattern variables, e.g. -v=#role:expert -v=#points:30"`
	Context                         string               `short:"C" long:"context" description:"Choose a context from the available contexts" default:""`
	Session                         string               `long:"session" description:"Choose a session from the available sessions"`
	Attachments                     []string             `short:"a" long:"attachment" description:"Attachment path or URL (e.g. for OpenAI image recognition messages)"`
	Setup                           bool                 `short:"S" long:"setup" description:"Run setup for all reconfigurable parts of fabric"`
	Temperature                     float64              `short:"t" long:"temperature" yaml:"temperature" description:"Set temperature" default:"0.7"`
	TopP                            float64              `short:"T" long:"topp" yaml:"topp" description:"Set top P" default:"0.9"`
	Stream                          bool                 `short:"s" long:"stream" yaml:"stream" description:"Stream"`
	PresencePenalty                 float64              `short:"P" long:"presencepenalty" yaml:"presencepenalty" description:"Set presence penalty" default:"0.0"`
	Raw                             bool                 `` /* 191-byte string literal not displayed */
	FrequencyPenalty                float64              `short:"F" long:"frequencypenalty" yaml:"frequencypenalty" description:"Set frequency penalty" default:"0.0"`
	ListPatterns                    bool                 `short:"l" long:"listpatterns" description:"List all patterns"`
	ListAllModels                   bool                 `short:"L" long:"listmodels" description:"List all available models"`
	ListAllContexts                 bool                 `short:"x" long:"listcontexts" description:"List all contexts"`
	ListAllSessions                 bool                 `short:"X" long:"listsessions" description:"List all sessions"`
	UpdatePatterns                  bool                 `short:"U" long:"updatepatterns" description:"Update patterns"`
	Message                         string               `hidden:"true" description:"Messages to send to chat"`
	Copy                            bool                 `short:"c" long:"copy" description:"Copy to clipboard"`
	Model                           string               `short:"m" long:"model" yaml:"model" description:"Choose model"`
	Vendor                          string               `` /* 136-byte string literal not displayed */
	ModelContextLength              int                  `long:"modelContextLength" yaml:"modelContextLength" description:"Model context length (only affects ollama)"`
	Output                          string               `short:"o" long:"output" description:"Output to file" default:""`
	OutputSession                   bool                 `long:"output-session" description:"Output the entire session (also a temporary one) to the output file"`
	LatestPatterns                  string               `short:"n" long:"latest" description:"Number of latest patterns to list" default:"0"`
	ChangeDefaultModel              bool                 `short:"d" long:"changeDefaultModel" description:"Change default model"`
	YouTube                         string               `` /* 190-byte string literal not displayed */
	YouTubePlaylist                 bool                 `long:"playlist" description:"Prefer playlist over video if both ids are present in the URL"`
	YouTubeTranscript               bool                 `long:"transcript" description:"Grab transcript from YouTube video and send to chat (it is used per default)."`
	YouTubeTranscriptWithTimestamps bool                 `long:"transcript-with-timestamps" description:"Grab transcript from YouTube video with timestamps and send to chat"`
	YouTubeComments                 bool                 `long:"comments" description:"Grab comments from YouTube video and send to chat"`
	YouTubeMetadata                 bool                 `long:"metadata" description:"Output video metadata"`
	YtDlpArgs                       string               `` /* 126-byte string literal not displayed */
	Language                        string               `short:"g" long:"language" description:"Specify the Language Code for the chat, e.g. -g=en -g=zh" default:""`
	ScrapeURL                       string               `short:"u" long:"scrape_url" description:"Scrape website URL to markdown using Jina AI"`
	ScrapeQuestion                  string               `short:"q" long:"scrape_question" description:"Search question using Jina AI"`
	Seed                            int                  `short:"e" long:"seed" yaml:"seed" description:"Seed to be used for LMM generation"`
	WipeContext                     string               `short:"w" long:"wipecontext" description:"Wipe context"`
	WipeSession                     string               `short:"W" long:"wipesession" description:"Wipe session"`
	PrintContext                    string               `long:"printcontext" description:"Print context"`
	PrintSession                    string               `long:"printsession" description:"Print session"`
	HtmlReadability                 bool                 `long:"readability" description:"Convert HTML input into a clean, readable view"`
	InputHasVars                    bool                 `long:"input-has-vars" description:"Apply variables to user input"`
	NoVariableReplacement           bool                 `long:"no-variable-replacement" description:"Disable pattern variable replacement"`
	DryRun                          bool                 `long:"dry-run" description:"Show what would be sent to the model without actually sending it"`
	Serve                           bool                 `long:"serve" description:"Serve the Fabric Rest API"`
	ServeOllama                     bool                 `long:"serveOllama" description:"Serve the Fabric Rest API with ollama endpoints"`
	ServeAddress                    string               `long:"address" description:"The address to bind the REST API" default:":8080"`
	ServeAPIKey                     string               `long:"api-key" description:"API key used to secure server routes" default:""`
	Config                          string               `long:"config" description:"Path to YAML config file"`
	Version                         bool                 `long:"version" description:"Print current version"`
	ListExtensions                  bool                 `long:"listextensions" description:"List all registered extensions"`
	AddExtension                    string               `long:"addextension" description:"Register a new extension from config file path"`
	RemoveExtension                 string               `long:"rmextension" description:"Remove a registered extension by name"`
	Strategy                        string               `long:"strategy" description:"Choose a strategy from the available strategies" default:""`
	ListStrategies                  bool                 `long:"liststrategies" description:"List all strategies"`
	ListVendors                     bool                 `long:"listvendors" description:"List all vendors"`
	ShellCompleteOutput             bool                 `long:"shell-complete-list" description:"Output raw list without headers/formatting (for shell completion)"`
	Search                          bool                 `long:"search" description:"Enable web search tool for supported models (Anthropic, OpenAI, Gemini)"`
	SearchLocation                  string               `long:"search-location" description:"Set location for web search results (e.g., 'America/Los_Angeles')"`
	ImageFile                       string               `long:"image-file" description:"Save generated image to specified file path (e.g., 'output.png')"`
	ImageSize                       string               `long:"image-size" description:"Image dimensions: 1024x1024, 1536x1024, 1024x1536, auto (default: auto)"`
	ImageQuality                    string               `long:"image-quality" description:"Image quality: low, medium, high, auto (default: auto)"`
	ImageCompression                int                  `long:"image-compression" description:"Compression level 0-100 for JPEG/WebP formats (default: not set)"`
	ImageBackground                 string               `long:"image-background" description:"Background type: opaque, transparent (default: opaque, only for PNG/WebP)"`
	SuppressThink                   bool                 `long:"suppress-think" yaml:"suppressThink" description:"Suppress text enclosed in thinking tags"`
	ThinkStartTag                   string               `long:"think-start-tag" yaml:"thinkStartTag" description:"Start tag for thinking sections" default:"<think>"`
	ThinkEndTag                     string               `long:"think-end-tag" yaml:"thinkEndTag" description:"End tag for thinking sections" default:"</think>"`
	DisableResponsesAPI             bool                 `long:"disable-responses-api" yaml:"disableResponsesAPI" description:"Disable OpenAI Responses API (default: false)"`
	TranscribeFile                  string               `long:"transcribe-file" yaml:"transcribeFile" description:"Audio or video file to transcribe"`
	TranscribeModel                 string               `long:"transcribe-model" yaml:"transcribeModel" description:"Model to use for transcription (separate from chat model)"`
	SplitMediaFile                  bool                 `long:"split-media-file" yaml:"splitMediaFile" description:"Split audio/video files larger than 25MB using ffmpeg"`
	Voice                           string               `long:"voice" yaml:"voice" description:"TTS voice name for supported models (e.g., Kore, Charon, Puck)" default:"Kore"`
	ListGeminiVoices                bool                 `long:"list-gemini-voices" description:"List all available Gemini TTS voices"`
	ListTranscriptionModels         bool                 `long:"list-transcription-models" description:"List all available transcription models"`
	Notification                    bool                 `long:"notification" yaml:"notification" description:"Send desktop notification when command completes"`
	NotificationCommand             string               `` /* 143-byte string literal not displayed */
	Thinking                        domain.ThinkingLevel `` /* 155-byte string literal not displayed */
	Debug                           int                  `long:"debug" description:"Set debug level (0=off, 1=basic, 2=detailed, 3=trace)" default:"0"`
}

func Init

func Init() (ret *Flags, err error)

Init Initialize flags. returns a Flags struct and an error

func (*Flags) AppendMessage

func (o *Flags) AppendMessage(message string)

func (*Flags) BuildChatOptions

func (o *Flags) BuildChatOptions() (ret *domain.ChatOptions, err error)

func (*Flags) BuildChatRequest

func (o *Flags) BuildChatRequest(Meta string) (ret *domain.ChatRequest, err error)

func (*Flags) IsChatRequest

func (o *Flags) IsChatRequest() (ret bool)

func (*Flags) WriteOutput

func (o *Flags) WriteOutput(message string) (err error)

type TranslatedHelpWriter added in v1.4.310

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

TranslatedHelpWriter provides custom help output with translated descriptions

func NewTranslatedHelpWriter added in v1.4.310

func NewTranslatedHelpWriter(parser *flags.Parser, writer io.Writer) *TranslatedHelpWriter

NewTranslatedHelpWriter creates a new help writer with translations

func (*TranslatedHelpWriter) WriteHelp added in v1.4.310

func (h *TranslatedHelpWriter) WriteHelp()

WriteHelp writes the help output with translated flag descriptions

Jump to

Keyboard shortcuts

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