34119e5a00
Five OpenAI-compatible providers join the library as first-class constructors (llm.DeepSeek, llm.Moonshot, llm.XAI, llm.Groq, llm.Ollama). Their wire-level implementation is shared via a new v2/openaicompat package which is the extracted guts of the old v2/openai provider; each provider supplies its own Rules value to declare per-model constraints (e.g., DeepSeek Reasoner rejects tools and temperature, Moonshot/xAI accept images only on *-vision* models, Groq rejects audio input). v2/openai itself becomes a thin wrapper that sets RestrictTemperature for o-series and gpt-5 models. A new provider registry (v2/registry.go) exposes llm.Providers() and drives the TUI's provider picker so adding a provider in future is a single-file change. The TUI at cmd/llm was migrated from v1 to v2 and moved to v2/cmd/llm. With nothing else depending on v1, the v1 code at the repo root (all .go files, schema/, internal/, provider/, root go.mod/go.sum) is deleted. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
114 lines
2.4 KiB
Go
114 lines
2.4 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/charmbracelet/lipgloss"
|
|
)
|
|
|
|
var (
|
|
// Colors
|
|
primaryColor = lipgloss.Color("205")
|
|
secondaryColor = lipgloss.Color("39")
|
|
accentColor = lipgloss.Color("212")
|
|
mutedColor = lipgloss.Color("241")
|
|
errorColor = lipgloss.Color("196")
|
|
successColor = lipgloss.Color("82")
|
|
|
|
// App styles
|
|
appStyle = lipgloss.NewStyle().Padding(1, 2)
|
|
|
|
// Header
|
|
headerStyle = lipgloss.NewStyle().
|
|
Bold(true).
|
|
Foreground(primaryColor).
|
|
BorderStyle(lipgloss.NormalBorder()).
|
|
BorderBottom(true).
|
|
BorderForeground(mutedColor).
|
|
Padding(0, 1)
|
|
|
|
// Provider badge
|
|
providerBadgeStyle = lipgloss.NewStyle().
|
|
Background(secondaryColor).
|
|
Foreground(lipgloss.Color("0")).
|
|
Padding(0, 1).
|
|
Bold(true)
|
|
|
|
// Messages
|
|
systemMsgStyle = lipgloss.NewStyle().
|
|
Foreground(mutedColor).
|
|
Italic(true).
|
|
Padding(0, 1)
|
|
|
|
userMsgStyle = lipgloss.NewStyle().
|
|
Foreground(secondaryColor).
|
|
Padding(0, 1)
|
|
|
|
assistantMsgStyle = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color("255")).
|
|
Padding(0, 1)
|
|
|
|
roleLabelStyle = lipgloss.NewStyle().
|
|
Bold(true).
|
|
Width(12)
|
|
|
|
// Tool calls
|
|
toolCallStyle = lipgloss.NewStyle().
|
|
Foreground(accentColor).
|
|
Italic(true).
|
|
Padding(0, 1)
|
|
|
|
toolResultStyle = lipgloss.NewStyle().
|
|
Foreground(successColor).
|
|
Padding(0, 1)
|
|
|
|
// Input area
|
|
inputStyle = lipgloss.NewStyle().
|
|
BorderStyle(lipgloss.RoundedBorder()).
|
|
BorderForeground(primaryColor).
|
|
Padding(0, 1)
|
|
|
|
inputHelpStyle = lipgloss.NewStyle().
|
|
Foreground(mutedColor).
|
|
Italic(true)
|
|
|
|
// Error
|
|
errorStyle = lipgloss.NewStyle().
|
|
Foreground(errorColor).
|
|
Bold(true)
|
|
|
|
// Loading
|
|
loadingStyle = lipgloss.NewStyle().
|
|
Foreground(accentColor).
|
|
Italic(true)
|
|
|
|
// List selection
|
|
selectedItemStyle = lipgloss.NewStyle().
|
|
Foreground(primaryColor).
|
|
Bold(true)
|
|
|
|
normalItemStyle = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color("255"))
|
|
|
|
// Settings panel
|
|
settingLabelStyle = lipgloss.NewStyle().
|
|
Foreground(secondaryColor).
|
|
Width(15)
|
|
|
|
settingValueStyle = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color("255"))
|
|
|
|
// Help text
|
|
helpStyle = lipgloss.NewStyle().
|
|
Foreground(mutedColor).
|
|
Padding(1, 0)
|
|
|
|
// Image indicator
|
|
imageIndicatorStyle = lipgloss.NewStyle().
|
|
Foreground(accentColor).
|
|
Bold(true)
|
|
|
|
// Viewport
|
|
viewportStyle = lipgloss.NewStyle().
|
|
BorderStyle(lipgloss.NormalBorder()).
|
|
BorderForeground(mutedColor)
|
|
)
|