repo stringlengths 6 47 | file_url stringlengths 77 269 | file_path stringlengths 5 186 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-07 08:35:43 2026-01-07 08:55:24 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/focus.go | focus.go | package tea
// FocusMsg represents a terminal focus message.
// This occurs when the terminal gains focus.
type FocusMsg struct{}
// BlurMsg represents a terminal blur message.
// This occurs when the terminal loses focus.
type BlurMsg struct{}
| go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/options_test.go | options_test.go | package tea
import (
"bytes"
"context"
"os"
"sync/atomic"
"testing"
)
func TestOptions(t *testing.T) {
t.Run("output", func(t *testing.T) {
var b bytes.Buffer
p := NewProgram(nil, WithOutput(&b))
if f, ok := p.output.(*os.File); ok {
t.Errorf("expected output to custom, got %v", f.Fd())
}
})
t.Run... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/options.go | options.go | package tea
import (
"context"
"io"
"sync/atomic"
)
// ProgramOption is used to set options when initializing a Program. Program can
// accept a variable number of options.
//
// Example usage:
//
// p := NewProgram(model, WithInput(someInput), WithOutput(someOutput))
type ProgramOption func(*Program)
// WithCont... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/key_windows.go | key_windows.go | //go:build windows
// +build windows
package tea
import (
"context"
"fmt"
"io"
"time"
"github.com/erikgeiser/coninput"
localereader "github.com/mattn/go-localereader"
"github.com/muesli/cancelreader"
)
func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
if coninReader, ok := input... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/inputreader_other.go | inputreader_other.go | //go:build !windows
// +build !windows
package tea
import (
"fmt"
"io"
"github.com/muesli/cancelreader"
)
func newInputReader(r io.Reader, _ bool) (cancelreader.CancelReader, error) {
cr, err := cancelreader.NewReader(r)
if err != nil {
return nil, fmt.Errorf("bubbletea: error creating cancel reader: %w", er... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/tty_windows.go | tty_windows.go | //go:build windows
// +build windows
package tea
import (
"fmt"
"os"
"github.com/charmbracelet/x/term"
"golang.org/x/sys/windows"
)
func (p *Program) initInput() (err error) {
// Save stdin state and enable VT input
// We also need to enable VT
// input here.
if f, ok := p.input.(term.File); ok && term.IsTe... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/tty_unix.go | tty_unix.go | //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || aix || zos
// +build darwin dragonfly freebsd linux netbsd openbsd solaris aix zos
package tea
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/charmbracelet/x/term"
)
func (p *Program) initInput() (err error) {
// Chec... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/key.go | key.go | package tea
import (
"context"
"fmt"
"io"
"regexp"
"strings"
"unicode/utf8"
)
// KeyMsg contains information about a keypress. KeyMsgs are always sent to
// the program's update function. There are a couple general patterns you could
// use to check for keypresses:
//
// // Switch on the string representation o... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/logging_test.go | logging_test.go | package tea
import (
"log"
"os"
"path/filepath"
"testing"
)
func TestLogToFile(t *testing.T) {
path := filepath.Join(t.TempDir(), "log.txt")
prefix := "logprefix"
f, err := LogToFile(path, prefix)
if err != nil {
t.Error(err)
}
log.SetFlags(log.Lmsgprefix)
log.Println("some test log")
if err := f.Close(... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/tutorials/commands/main.go | tutorials/commands/main.go | package main
import (
"fmt"
"net/http"
"os"
"time"
tea "github.com/charmbracelet/bubbletea"
)
const url = "https://charm.sh/"
type model struct {
status int
err error
}
func checkServer() tea.Msg {
c := &http.Client{Timeout: 10 * time.Second}
res, err := c.Get(url)
if err != nil {
return errMsg{err}... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/tutorials/basics/main.go | tutorials/basics/main.go | package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
)
type model struct {
cursor int
choices []string
selected map[int]struct{}
}
func initialModel() model {
return model{
choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},
// A map which indicates which choices are ... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/textarea/main.go | examples/textarea/main.go | package main
// A simple program demonstrating the textarea component from the Bubbles
// component library.
import (
"fmt"
"log"
"github.com/charmbracelet/bubbles/textarea"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
p := tea.NewProgram(initialModel())
if _, err := p.Run(); err != nil {
log.F... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/chat/main.go | examples/chat/main.go | package main
// A simple program demonstrating the text area component from the Bubbles
// component library.
import (
"fmt"
"log"
"strings"
"github.com/charmbracelet/bubbles/textarea"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
c... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/table-resize/main.go | examples/table-resize/main.go | package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/lipgloss/table"
)
type model struct {
table *table.Table
}
func (m model) Init() tea.Cmd { return nil }
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd te... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/eyes/main.go | examples/eyes/main.go | // roughly converted to Go from https://github.com/dmtrKovalenko/esp32-smooth-eye-blinking/blob/main/src/main.cpp
package main
import (
"fmt"
"math"
"math/rand"
"strings"
"time"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
const (
// Eye dimensions (corresponding to original... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/focus-blur/main.go | examples/focus-blur/main.go | package main
// A simple program that handled losing and acquiring focus.
import (
"log"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
p := tea.NewProgram(model{
// assume we start focused...
focused: true,
reporting: true,
}, tea.WithReportFocus())
if _, err := p.Run(); err != nil {
log.F... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/autocomplete/main.go | examples/autocomplete/main.go | package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
func main() {
p := tea.NewProgram(ini... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/tui-daemon-combo/main.go | examples/tui-daemon-combo/main.go | package main
import (
"flag"
"fmt"
"io"
"log"
"math/rand"
"os"
"time"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/mattn/go-isatty"
)
var (
helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render
main... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/list-simple/main.go | examples/list-simple/main.go | package main
import (
"fmt"
"io"
"os"
"strings"
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
const listHeight = 14
var (
titleStyle = lipgloss.NewStyle().MarginLeft(2)
itemStyle = lipgloss.NewStyle().PaddingLeft(4)
se... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/progress-download/tui.go | examples/progress-download/tui.go | package main
import (
"strings"
"time"
"github.com/charmbracelet/bubbles/progress"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render
const (
padding = 2
maxWidth = 80
)
type progressMsg float64
ty... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/progress-download/main.go | examples/progress-download/main.go | package main
import (
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"path/filepath"
"github.com/charmbracelet/bubbles/progress"
tea "github.com/charmbracelet/bubbletea"
)
var p *tea.Program
type progressWriter struct {
total int
downloaded int
file *os.File
reader io.Reader
onProgress func(fl... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/split-editors/main.go | examples/split-editors/main.go | package main
import (
"fmt"
"os"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textarea"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
const (
initialInputs = 2
maxInputs = 6
minInputs = 1
helpHeigh... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/help/main.go | examples/help/main.go | package main
import (
"fmt"
"os"
"strings"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
// keyMap defines a set of keybindings. To work for help it must satisfy
// key.Map. It could also very easil... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/cellbuffer/main.go | examples/cellbuffer/main.go | package main
// A simple example demonstrating how to draw and animate on a cellular grid.
// Note that the cellbuffer implementation in this example does not support
// double-width runes.
import (
"fmt"
"os"
"strings"
"time"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/harmonica"
)
con... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/list-default/main.go | examples/list-default/main.go | package main
import (
"fmt"
"os"
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
var docStyle = lipgloss.NewStyle().Margin(1, 2)
type item struct {
title, desc string
}
func (i item) Title() string { return i.title }
func (i item) D... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/progress-animated/main.go | examples/progress-animated/main.go | package main
// A simple example that shows how to render an animated progress bar. In this
// example we bump the progress by 25% every two seconds, animating our
// progress bar to its new target state.
//
// It's also possible to render a progress bar in a more static fashion without
// transitions. For details on ... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/set-window-title/main.go | examples/set-window-title/main.go | package main
// A simple example illustrating how to set a window title.
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
)
type model struct{}
func (m model) Init() tea.Cmd {
return tea.SetWindowTitle("Bubble Tea Example")
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.(t... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/exec/main.go | examples/exec/main.go | package main
import (
"fmt"
"os"
"os/exec"
tea "github.com/charmbracelet/bubbletea"
)
type editorFinishedMsg struct{ err error }
func openEditor() tea.Cmd {
editor := os.Getenv("EDITOR")
if editor == "" {
editor = "vim"
}
c := exec.Command(editor) //nolint:gosec
return tea.ExecProcess(c, func(err error) ... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/altscreen-toggle/main.go | examples/altscreen-toggle/main.go | package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
var (
keywordStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("204")).Background(lipgloss.Color("235"))
helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241"))
)
type model struct ... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/result/main.go | examples/result/main.go | package main
// A simple example that shows how to retrieve a value from a Bubble Tea
// program after the Bubble Tea has exited.
import (
"fmt"
"os"
"strings"
tea "github.com/charmbracelet/bubbletea"
)
var choices = []string{"Taro", "Coffee", "Lychee"}
type model struct {
cursor int
choice string
}
func (m... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/spinners/main.go | examples/spinners/main.go | package main
import (
"fmt"
"os"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
var (
// Available spinners
spinners = []spinner.Spinner{
spinner.Line,
spinner.Dot,
spinner.MiniDot,
spinner.Jump,
spinner.Pulse,
spinner.Poin... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/views/main.go | examples/views/main.go | package main
// An example demonstrating an application with multiple views.
//
// Note that this example was produced before the Bubbles progress component
// was available (github.com/charmbracelet/bubbles/progress) and thus, we're
// implementing a progress bar from scratch here.
import (
"fmt"
"math"
"strconv"... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/send-msg/main.go | examples/send-msg/main.go | package main
// A simple example that shows how to send messages to a Bubble Tea program
// from outside the program using Program.Send(Msg).
import (
"fmt"
"math/rand"
"os"
"strings"
"time"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/composable-views/main.go | examples/composable-views/main.go | package main
import (
"fmt"
"log"
"time"
"github.com/charmbracelet/bubbles/spinner"
"github.com/charmbracelet/bubbles/timer"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
/*
This example assumes an existing understanding of commands and messages. If you
haven't already read ou... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/timer/main.go | examples/timer/main.go | package main
import (
"fmt"
"os"
"time"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/timer"
tea "github.com/charmbracelet/bubbletea"
)
const timeout = time.Second * 5
type model struct {
timer timer.Model
keymap keymap
help help.... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/fullscreen/main.go | examples/fullscreen/main.go | package main
// A simple program that opens the alternate screen buffer then counts down
// from 5 and then exits.
import (
"fmt"
"log"
"time"
tea "github.com/charmbracelet/bubbletea"
)
type model int
type tickMsg time.Time
func main() {
p := tea.NewProgram(model(5), tea.WithAltScreen())
if _, err := p.Run(... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/list-fancy/randomitems.go | examples/list-fancy/randomitems.go | package main
import (
"math/rand"
"sync"
)
type randomItemGenerator struct {
titles []string
descs []string
titleIndex int
descIndex int
mtx *sync.Mutex
shuffle *sync.Once
}
func (r *randomItemGenerator) reset() {
r.mtx = &sync.Mutex{}
r.shuffle = &sync.Once{}
r.titles = []string{
"... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/list-fancy/delegate.go | examples/list-fancy/delegate.go | package main
import (
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
)
func newItemDelegate(keys *delegateKeyMap) list.DefaultDelegate {
d := list.NewDefaultDelegate()
d.UpdateFunc = func(msg tea.Msg, m *list.Model) tea.Cmd {
var title s... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/list-fancy/main.go | examples/list-fancy/main.go | package main
import (
"fmt"
"math/rand"
"os"
"time"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
var (
appStyle = lipgloss.NewStyle().Padding(1, 2)
titleStyle = lipgloss.NewStyle().
Foregrou... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/package-manager/packages.go | examples/package-manager/packages.go | package main
import (
"fmt"
"math/rand"
)
var packages = []string{
"vegeutils",
"libgardening",
"currykit",
"spicerack",
"fullenglish",
"eggy",
"bad-kitty",
"chai",
"hojicha",
"libtacos",
"babys-monads",
"libpurring",
"currywurst-devel",
"xmodmeow",
"licorice-utils",
"cashew-apple",
"rock-lobster",... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/package-manager/main.go | examples/package-manager/main.go | package main
import (
"fmt"
"math/rand"
"os"
"strings"
"time"
"github.com/charmbracelet/bubbles/progress"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
type model struct {
packages []string
index int
width int
height int... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/paginator/main.go | examples/paginator/main.go | package main
// A simple program demonstrating the paginator component from the Bubbles
// component library.
import (
"fmt"
"log"
"strings"
"github.com/charmbracelet/bubbles/paginator"
"github.com/charmbracelet/lipgloss"
tea "github.com/charmbracelet/bubbletea"
)
func newModel() model {
var items []string
... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/pager/main.go | examples/pager/main.go | package main
// An example program demonstrating the pager component from the Bubbles
// component library.
import (
"fmt"
"os"
"strings"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
var (
titleStyle = func() lipgloss.Style {
b :... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/prevent-quit/main.go | examples/prevent-quit/main.go | package main
// A program demonstrating how to use the WithFilter option to intercept events.
import (
"fmt"
"log"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textarea"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgl... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/tabs/main.go | examples/tabs/main.go | package main
import (
"fmt"
"os"
"strings"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
type model struct {
Tabs []string
TabContent []string
activeTab int
}
func (m model) Init() tea.Cmd {
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
swi... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/mouse/main.go | examples/mouse/main.go | package main
// A simple program that opens the alternate screen buffer and displays mouse
// coordinates and events.
import (
"log"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
p := tea.NewProgram(model{}, tea.WithMouseAllMotion())
if _, err := p.Run(); err != nil {
log.Fatal(err)
}
}
type mode... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/sequence/main.go | examples/sequence/main.go | package main
// A simple example illustrating how to run a series of commands in order.
import (
"fmt"
"os"
"time"
tea "github.com/charmbracelet/bubbletea"
)
type model struct{}
func (m model) Init() tea.Cmd {
return tea.Sequence(
tea.Batch(
tea.Sequence(
SleepPrintln("1-1-1", 1000),
SleepPrintln... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/simple/main_test.go | examples/simple/main_test.go | package main
import (
"bytes"
"io"
"regexp"
"testing"
"time"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/x/exp/teatest"
)
func TestApp(t *testing.T) {
m := model(10)
tm := teatest.NewTestModel(
t, m,
teatest.WithInitialTermSize(70, 30),
)
t.Cleanup(func() {
if err := tm.Quit()... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/simple/main.go | examples/simple/main.go | package main
// A simple program that counts down from 5 and then exits.
import (
"fmt"
"log"
"os"
"time"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
// Log to a file. Useful in debugging since you can't really log to stdout.
// Not required.
logfilePath := os.Getenv("BUBBLETEA_LOG")
if logfil... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/stopwatch/main.go | examples/stopwatch/main.go | package main
import (
"fmt"
"os"
"time"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/stopwatch"
tea "github.com/charmbracelet/bubbletea"
)
type model struct {
stopwatch stopwatch.Model
keymap keymap
help help.Model
quitting bool
... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/realtime/main.go | examples/realtime/main.go | package main
// A simple example that shows how to send activity to Bubble Tea in real-time
// through a channel.
import (
"fmt"
"math/rand"
"os"
"time"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
)
// A message used to indicate that activity has occurred. In the real w... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/debounce/main.go | examples/debounce/main.go | package main
// This example illustrates how to debounce commands.
//
// When the user presses a key we increment the "tag" value on the model and,
// after a short delay, we include that tag value in the message produced
// by the Tick command.
//
// In a subsequent Update, if the tag in the Msg matches current tag o... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/spinner/main.go | examples/spinner/main.go | package main
// A simple program demonstrating the spinner component from the Bubbles
// component library.
import (
"fmt"
"os"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
type errMsg error
type model struct {
spinner spinner.Mode... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/window-size/main.go | examples/window-size/main.go | package main
// A simple program that queries and displays the window-size.
import (
"log"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
p := tea.NewProgram(model{})
if _, err := p.Run(); err != nil {
log.Fatal(err)
}
}
type model struct{}
func (m model) Init() tea.Cmd {
return nil
}
func (m m... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/glamour/main.go | examples/glamour/main.go | package main
import (
"fmt"
"os"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/lipgloss"
)
const content = `
# Today’s Menu
## Appetizers
| Name | Price | Notes |
| --- ... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/file-picker/main.go | examples/file-picker/main.go | package main
import (
"errors"
"fmt"
"os"
"strings"
"time"
"github.com/charmbracelet/bubbles/filepicker"
tea "github.com/charmbracelet/bubbletea"
)
type model struct {
filepicker filepicker.Model
selectedFile string
quitting bool
err error
}
type clearErrorMsg struct{}
func clearErrorAfte... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/pipe/main.go | examples/pipe/main.go | package main
// An example illustrating how to pipe in data to a Bubble Tea application.
// More so, this serves as proof that Bubble Tea will automatically listen for
// keystrokes when input is not a TTY, such as when data is piped or redirected
// in.
import (
"bufio"
"fmt"
"io"
"os"
"strings"
"github.com/c... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/progress-static/main.go | examples/progress-static/main.go | package main
// A simple example that shows how to render a progress bar in a "pure"
// fashion. In this example we bump the progress by 25% every second,
// maintaining the progress state on our top level model using the progress bar
// model's ViewAs method only for rendering.
//
// The signature for ViewAs is:
//
/... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/table/main.go | examples/table/main.go | package main
import (
"fmt"
"os"
"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
var baseStyle = lipgloss.NewStyle().
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("240"))
type model struct {
table table.Model
}
... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/suspend/main.go | examples/suspend/main.go | package main
import (
"errors"
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
)
type model struct {
quitting bool
suspending bool
}
func (m model) Init() tea.Cmd {
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.ResumeMsg:
m.suspending = ... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/textinput/main.go | examples/textinput/main.go | package main
// A simple program demonstrating the text input component from the Bubbles
// component library.
import (
"fmt"
"log"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
p := tea.NewProgram(initialModel())
if _, err := p.Run(); err != nil {
log... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/credit-card-form/main.go | examples/credit-card-form/main.go | package main
import (
"fmt"
"log"
"strconv"
"strings"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
func main() {
p := tea.NewProgram(initialModel())
if _, err := p.Run(); err != nil {
log.Fatal(err)
}
}
type (
errMsg error
... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/textinputs/main.go | examples/textinputs/main.go | package main
// A simple example demonstrating the use of multiple text input components
// from the Bubbles component library.
import (
"fmt"
"os"
"strings"
"github.com/charmbracelet/bubbles/cursor"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracele... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
charmbracelet/bubbletea | https://github.com/charmbracelet/bubbletea/blob/f9233d51192293dadda7184a4de347738606c328/examples/http/main.go | examples/http/main.go | package main
// A simple program that makes a GET request and prints the response status.
import (
"fmt"
"log"
"net/http"
"time"
tea "github.com/charmbracelet/bubbletea"
)
const url = "https://charm.sh/"
type model struct {
status int
err error
}
type statusMsg int
type errMsg struct{ error }
func (e ... | go | MIT | f9233d51192293dadda7184a4de347738606c328 | 2026-01-07T08:35:58.083951Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/.github/ci/modelslist.go | .github/ci/modelslist.go | package main
import (
"fmt"
"html/template"
"io/ioutil"
"os"
"github.com/microcosm-cc/bluemonday"
"gopkg.in/yaml.v3"
)
var modelPageTemplate string = `
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LocalAI models</... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/.github/gallery-agent/agent.go | .github/gallery-agent/agent.go | package main
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"regexp"
"slices"
"strings"
"github.com/ghodss/yaml"
hfapi "github.com/mudler/LocalAI/pkg/huggingface-api"
cogito "github.com/mudler/cogito"
"github.com/mudler/cogito/structures"
"github.com/sashabaranov/go-openai/jsonschema"
)
... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/.github/gallery-agent/tools.go | .github/gallery-agent/tools.go | package main
import (
"fmt"
hfapi "github.com/mudler/LocalAI/pkg/huggingface-api"
openai "github.com/sashabaranov/go-openai"
jsonschema "github.com/sashabaranov/go-openai/jsonschema"
)
// Get repository README from HF
type HFReadmeTool struct {
client *hfapi.Client
}
func (s *HFReadmeTool) Execute(args map[str... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/.github/gallery-agent/gallery.go | .github/gallery-agent/gallery.go | package main
import (
"context"
"encoding/json"
"fmt"
"os"
"strings"
"github.com/ghodss/yaml"
"github.com/mudler/LocalAI/core/gallery/importers"
)
func formatTextContent(text string) string {
return formatTextContentWithIndent(text, 4, 6)
}
// formatTextContentWithIndent formats text content with specified ... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/.github/gallery-agent/testing.go | .github/gallery-agent/testing.go | package main
import (
"context"
"fmt"
"math/rand"
"strings"
"time"
)
// runSyntheticMode generates synthetic test data and appends it to the gallery
func runSyntheticMode() error {
generator := NewSyntheticDataGenerator()
// Generate a random number of synthetic models (1-3)
numModels := generator.rand.Intn(... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/.github/gallery-agent/main.go | .github/gallery-agent/main.go | package main
import (
"context"
"encoding/json"
"fmt"
"os"
"strconv"
"strings"
"time"
hfapi "github.com/mudler/LocalAI/pkg/huggingface-api"
)
// ProcessedModelFile represents a processed model file with additional metadata
type ProcessedModelFile struct {
Path string `json:"path"`
Size int64 `json... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/system/capabilities.go | pkg/system/capabilities.go | // Package system provides system detection utilities, including GPU/vendor detection
// and capability classification used to select optimal backends at runtime.
package system
import (
"os"
"path/filepath"
"runtime"
"strings"
"github.com/jaypipes/ghw/pkg/gpu"
"github.com/mudler/xlog"
)
const (
defaultCapabi... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/system/state.go | pkg/system/state.go | package system
import (
"github.com/jaypipes/ghw/pkg/gpu"
"github.com/mudler/LocalAI/pkg/xsysinfo"
"github.com/mudler/xlog"
)
type Backend struct {
BackendsPath string
BackendsSystemPath string
}
type Model struct {
ModelsPath string
}
type SystemState struct {
GPUVendor string
Backend Backend
Mode... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/xsysinfo/gguf.go | pkg/xsysinfo/gguf.go | package xsysinfo
import (
gguf "github.com/gpustack/gguf-parser-go"
)
type VRAMEstimate struct {
TotalVRAM uint64
AvailableVRAM uint64
ModelSize uint64
EstimatedLayers int
EstimatedVRAM uint64
IsFullOffload bool
}
func EstimateGGUFVRAMUsage(f *gguf.GGUFFile, availableVRAM uint64) (*VRAMEstim... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/xsysinfo/memory.go | pkg/xsysinfo/memory.go | package xsysinfo
import (
"github.com/mudler/memory"
"github.com/mudler/xlog"
)
// SystemRAMInfo contains system RAM usage information
type SystemRAMInfo struct {
Total uint64 `json:"total"`
Used uint64 `json:"used"`
Free uint64 `json:"free"`
Available uint64 `json:"available"`
Us... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/xsysinfo/gpu.go | pkg/xsysinfo/gpu.go | package xsysinfo
import (
"bytes"
"encoding/json"
"os/exec"
"strconv"
"strings"
"sync"
"github.com/jaypipes/ghw"
"github.com/jaypipes/ghw/pkg/gpu"
"github.com/mudler/xlog"
)
// GPU vendor constants
const (
VendorNVIDIA = "nvidia"
VendorAMD = "amd"
VendorIntel = "intel"
VendorVulkan = "vulkan"
V... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/xsysinfo/cpu.go | pkg/xsysinfo/cpu.go | package xsysinfo
import (
"sort"
"github.com/jaypipes/ghw"
"github.com/klauspost/cpuid/v2"
)
func CPUCapabilities() ([]string, error) {
cpu, err := ghw.CPU()
if err != nil {
return nil, err
}
caps := map[string]struct{}{}
for _, proc := range cpu.Processors {
for _, c := range proc.Capabilities {
c... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/xio/copy.go | pkg/xio/copy.go | package xio
import (
"context"
"io"
)
type readerFunc func(p []byte) (n int, err error)
func (rf readerFunc) Read(p []byte) (n int, err error) { return rf(p) }
func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int64, error) {
return io.Copy(dst, readerFunc(func(p []byte) (int, error) {
select {
c... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/loader.go | pkg/model/loader.go | package model
import (
"context"
"fmt"
"maps"
"os"
"path/filepath"
"strings"
"sync"
"time"
"github.com/mudler/LocalAI/pkg/system"
"github.com/mudler/LocalAI/pkg/utils"
"github.com/mudler/xlog"
)
// new idea: what if we declare a struct of these here, and use a loop to check?
// TODO: Split ModelLoader a... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/initializers.go | pkg/model/initializers.go | package model
import (
"context"
"errors"
"fmt"
"os"
"strings"
"time"
grpc "github.com/mudler/LocalAI/pkg/grpc"
"github.com/mudler/xlog"
"github.com/phayes/freeport"
)
const (
LLamaCPP = "llama-cpp"
)
var Aliases map[string]string = map[string]string{
"go-llama": LLamaCPP,
"llama": ... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/watchdog_options_test.go | pkg/model/watchdog_options_test.go | package model_test
import (
"time"
"github.com/mudler/LocalAI/pkg/model"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("WatchDogOptions", func() {
Context("DefaultWatchDogOptions", func() {
It("should return sensible defaults", func() {
opts := model.DefaultWatchDogOptions()
... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/watchdog_options.go | pkg/model/watchdog_options.go | package model
import (
"time"
)
const (
DefaultWatchdogInterval = 500 * time.Millisecond
DefaultMemoryReclaimerThreshold = 0.80
)
// WatchDogOptions contains all configuration for the WatchDog
type WatchDogOptions struct {
processManager ProcessManager
// Timeout settings
busyTimeout time.Duratio... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/watchdog_test.go | pkg/model/watchdog_test.go | package model_test
import (
"sync"
"time"
"github.com/mudler/LocalAI/pkg/model"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
// mockProcessManager implements ProcessManager for testing
type mockProcessManager struct {
mu sync.Mutex
shutdownCalls []string
shutdownErrors map[string]e... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/model.go | pkg/model/model.go | package model
import (
"sync"
grpc "github.com/mudler/LocalAI/pkg/grpc"
process "github.com/mudler/go-processmanager"
)
type Model struct {
ID string `json:"id"`
address string
client grpc.Backend
process *process.Process
sync.Mutex
}
func NewModel(ID, address string, process *process.Process) *Model ... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/watchdog.go | pkg/model/watchdog.go | package model
import (
"sort"
"sync"
"time"
"github.com/mudler/LocalAI/pkg/xsysinfo"
process "github.com/mudler/go-processmanager"
"github.com/mudler/xlog"
)
// WatchDog tracks all the requests from GRPC clients.
// All GRPC Clients created by ModelLoader should have an associated injected
// watchdog that wil... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/process.go | pkg/model/process.go | package model
import (
"errors"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/hpcloud/tail"
"github.com/mudler/LocalAI/pkg/signals"
process "github.com/mudler/go-processmanager"
"github.com/mudler/xlog"
)
var forceBackendShutdown bool = os.Getenv("LOCALAI_FORCE_BACKEND_SHUTDOWN") == "t... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/loader_options.go | pkg/model/loader_options.go | package model
import (
"context"
pb "github.com/mudler/LocalAI/pkg/grpc/proto"
)
type Options struct {
backendString string
model string
modelID string
context context.Context
gRPCOptions *pb.ModelOptions
externalBackends map[string]string
grpcAttempts int
grpcAttemptsDelay int
... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/model_suite_test.go | pkg/model/model_suite_test.go | package model_test
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestModel(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "LocalAI model test")
}
| go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/filters.go | pkg/model/filters.go | package model
import (
process "github.com/mudler/go-processmanager"
)
type GRPCProcessFilter = func(id string, p *process.Process) bool
func all(_ string, _ *process.Process) bool {
return true
}
func allExcept(s string) GRPCProcessFilter {
return func(id string, p *process.Process) bool {
return id != s
}
}... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/model/loader_test.go | pkg/model/loader_test.go | package model_test
import (
"errors"
"os"
"path/filepath"
"sync"
"sync/atomic"
"time"
"github.com/mudler/LocalAI/pkg/model"
"github.com/mudler/LocalAI/pkg/system"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("ModelLoader", func() {
var (
modelLoader *model.ModelLoader
mo... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/store/client.go | pkg/store/client.go | package store
import (
"context"
"fmt"
grpc "github.com/mudler/LocalAI/pkg/grpc"
"github.com/mudler/LocalAI/pkg/grpc/proto"
)
// Wrapper for the GRPC client so that simple use cases are handled without verbosity
// SetCols sets multiple key-value pairs in the store
// It's in columnar format so that keys[i] is ... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/huggingface-api/client.go | pkg/huggingface-api/client.go | package hfapi
import (
"encoding/json"
"fmt"
"io"
"net/http"
"path/filepath"
"strings"
)
// Model represents a model from the Hugging Face API
type Model struct {
ModelID string `json:"modelId"`
Author string `json:"author"`
Downloads int ... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/huggingface-api/hfapi_suite_test.go | pkg/huggingface-api/hfapi_suite_test.go | package hfapi_test
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestHfapi(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "HuggingFace API Suite")
}
| go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/huggingface-api/client_test.go | pkg/huggingface-api/client_test.go | package hfapi_test
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
hfapi "github.com/mudler/LocalAI/pkg/huggingface-api"
)
var _ = Describe("HuggingFace API Client", func() {
var (
client *hfapi.Client
server *httptest.Server
)
BeforeEa... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/concurrency/jobresult_test.go | pkg/concurrency/jobresult_test.go | package concurrency_test
import (
"context"
"fmt"
"time"
. "github.com/mudler/LocalAI/pkg/concurrency"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("pkg/concurrency unit tests", func() {
It("can be used to receive a result across goroutines", func() {
jr, wjr := NewJobResult[s... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/concurrency/jobresult.go | pkg/concurrency/jobresult.go | package concurrency
import (
"context"
"sync"
)
// This is a Read-ONLY structure that contains the result of an arbitrary asynchronous action
type JobResult[RequestType any, ResultType any] struct {
request *RequestType
result *ResultType
err error
once sync.Once
done *chan struct{}
}
// This struc... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/concurrency/concurrency_suite_test.go | pkg/concurrency/concurrency_suite_test.go | package concurrency
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestConcurrency(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Concurrency test suite")
}
| go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/utils/json.go | pkg/utils/json.go | package utils
import "regexp"
var matchNewlines = regexp.MustCompile(`[\r\n]`)
const doubleQuote = `"[^"\\]*(?:\\[\s\S][^"\\]*)*"`
func EscapeNewLines(s string) string {
return regexp.MustCompile(doubleQuote).ReplaceAllStringFunc(s, func(s string) string {
return matchNewlines.ReplaceAllString(s, "\\n")
})
}
| go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/utils/logging.go | pkg/utils/logging.go | package utils
import (
"time"
"github.com/mudler/xlog"
)
var lastProgress time.Time = time.Now()
var startTime time.Time = time.Now()
func ResetDownloadTimers() {
lastProgress = time.Now()
startTime = time.Now()
}
func DisplayDownloadFunction(fileName string, current string, total string, percentage float64) {... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/utils/ffmpeg.go | pkg/utils/ffmpeg.go | package utils
import (
"fmt"
"os"
"os/exec"
"strings"
"github.com/go-audio/wav"
)
func ffmpegCommand(args []string) (string, error) {
cmd := exec.Command("ffmpeg", args...) // Constrain this to ffmpeg to permit security scanner to see that the command is safe.
cmd.Env = []string{}
out, err := cmd.CombinedOut... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
mudler/LocalAI | https://github.com/mudler/LocalAI/blob/23df29fbd3eec1af3944521205fd62b20d4149e5/pkg/utils/path.go | pkg/utils/path.go | package utils
import (
"fmt"
"os"
"path/filepath"
"strings"
)
func ExistsInPath(path string, s string) bool {
_, err := os.Stat(filepath.Join(path, s))
return err == nil
}
func InTrustedRoot(path string, trustedRoot string) error {
for path != "/" {
path = filepath.Dir(path)
if path == trustedRoot {
re... | go | MIT | 23df29fbd3eec1af3944521205fd62b20d4149e5 | 2026-01-07T08:35:47.749878Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.