Documentation
¶
Index ¶
- func Cmdize[T any](t T) tea.Cmd
- func ConvertTerminalTextToImage(terminalText string, convertConfig *ansitoimage.Config) ([]byte, error)
- func DefaultHost() string
- func DefaultModel() string
- func DefaultPrompt() string
- func DefaultSystemPrompt() string
- func FetchModelList(ollamaHost string, id int64) tea.Msg
- func GetNextModelChooserID() int64
- type ChatPanelModel
- func (m ChatPanelModel) GetInputHeight() int
- func (m ChatPanelModel) GetPlaceholder() string
- func (m ChatPanelModel) Init() tea.Cmd
- func (m ChatPanelModel) SetHeight(height int) ChatPanelModel
- func (m ChatPanelModel) SetInputHeight(inputHeight int) ChatPanelModel
- func (m ChatPanelModel) SetPlaceholder(s string) ChatPanelModel
- func (m ChatPanelModel) SetWidth(w int) ChatPanelModel
- func (m ChatPanelModel) Update(msg tea.Msg) (ChatPanelModel, tea.Cmd)
- func (m ChatPanelModel) View() string
- type FetchModelListErrorMsg
- type FetchModelListResponseMsg
- type GenerateDoneMsg
- type GenerateResponseMsg
- type ImageData
- type ListModelResponse
- type ModelChooser
- func (m ModelChooser) GetHost() string
- func (m ModelChooser) GetLastError() error
- func (m ModelChooser) GetSelectedModel() *ollama.ListModelResponse
- func (m ModelChooser) GetStyles() list.Styles
- func (m ModelChooser) ID() int64
- func (m ModelChooser) Init() tea.Cmd
- func (m ModelChooser) IsFetching() bool
- func (m ModelChooser) SetStyles(styles list.Styles) ModelChooser
- func (m ModelChooser) Update(msg tea.Msg) (ModelChooser, tea.Cmd)
- func (m ModelChooser) View() string
- type ModelChooserAbortedMsg
- type ModelChooserSelectedMsg
- type Session
- func (s *Session) ClearError()
- func (s *Session) ClearResponse()
- func (s *Session) Error() error
- func (s *Session) ID() int64
- func (m *Session) Init() tea.Cmd
- func (s *Session) IsGenerating() bool
- func (s *Session) Response() string
- func (s *Session) StartGenerateMsg() tea.Msg
- func (m *Session) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m *Session) View() string
- type StartGenerateMsg
- type StopGenerateMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cmdize ¶
Cmdize is a utility function to convert a given value into a `tea.Cmd` https://github.com/KevM/bubbleo/blob/main/utils/utils.go
func ConvertTerminalTextToImage ¶
func ConvertTerminalTextToImage(terminalText string, convertConfig *ansitoimage.Config) ([]byte, error)
ConvertTerminalTextToImage converts the [terminalText] to a PNG image returned as a []byte. Returns nil with an error, if any. Uses the passed [go-ansi-to-image Config](https://github.com/pavelpatrin/go-ansi-to-image/blob/main/config.go#L4) or otherwise the [DefaultConfig](https://github.com/pavelpatrin/go-ansi-to-image/blob/main/config.go#L28).
func DefaultHost ¶
func DefaultHost() string
func DefaultModel ¶
func DefaultModel() string
func DefaultPrompt ¶
func DefaultPrompt() string
func DefaultSystemPrompt ¶
func DefaultSystemPrompt() string
func FetchModelList ¶
FetchModelList fetches a list of models from the Ollama server and returns a [FetchListResponseMsg]. If there is an error, a [FetchListErrorMsg] is returned.
It is independent of any Model, so can be used as an independent tea.Msg generator to implement one's own model selection interfaces.
func GetNextModelChooserID ¶
func GetNextModelChooserID() int64
GetNextFetchModelListID atomically returns the next FetchModelList ID. Call this to get a unique ID for a FetchModelList request.
Types ¶
type ChatPanelModel ¶
type ChatPanelModel struct {
Width int // Width is the width of the ollamatea.ChatPanelModel
Height int // Height is the height of the ollamatea.ChatPanelModel
InputHeight int // Height of the Input Box, other heights derive from this
InputOnTop bool // InputOnTop indicates whether the input box is at the top of screen
Session *Session
// contains filtered or unexported fields
}
ollamatea.ChatPanelModel holds a simple Panel TUI for an Ollama chat
func NewChatPanel ¶
func NewChatPanel(session Session) ChatPanelModel
func (ChatPanelModel) GetInputHeight ¶
func (m ChatPanelModel) GetInputHeight() int
func (ChatPanelModel) GetPlaceholder ¶
func (m ChatPanelModel) GetPlaceholder() string
func (ChatPanelModel) Init ¶
func (m ChatPanelModel) Init() tea.Cmd
Init handles the initialization of an ChatPanelModel
func (ChatPanelModel) SetHeight ¶
func (m ChatPanelModel) SetHeight(height int) ChatPanelModel
func (ChatPanelModel) SetInputHeight ¶
func (m ChatPanelModel) SetInputHeight(inputHeight int) ChatPanelModel
SetInputHeight sets the height of the input window. This is clamped to [0,Height)
func (ChatPanelModel) SetPlaceholder ¶
func (m ChatPanelModel) SetPlaceholder(s string) ChatPanelModel
func (ChatPanelModel) SetWidth ¶
func (m ChatPanelModel) SetWidth(w int) ChatPanelModel
func (ChatPanelModel) Update ¶
func (m ChatPanelModel) Update(msg tea.Msg) (ChatPanelModel, tea.Cmd)
Update handles BubbleTea messages for the ChatPanelModel
func (ChatPanelModel) View ¶
func (m ChatPanelModel) View() string
View renders the ChatPanelModel's view.
type FetchModelListErrorMsg ¶
type FetchModelListErrorMsg struct {
ID int64 // ID of the original request
OllamaHost string // Ollama Host generating the error
Error error // Error returned
}
FetchModelListErrorMsg is sent when a FetchModelList fails.
type FetchModelListResponseMsg ¶
type FetchModelListResponseMsg struct {
ID int64 // ID of the original request
OllamaHost string // Ollama Host generating the response
Models []ListModelResponse // Models delivered
}
FetchModelListResponseMsg is sent when a FetchModelList succeeds.
type GenerateDoneMsg ¶
type GenerateDoneMsg struct {
ID int64 // ID is the generation session ID corresponding to the Response
Response string // Full resposne from the Ollama generation
CreatedAt time.Time // CreatedAt is the timestamp of the response.
DoneReason string // DoneReason is the reason the model stopped generating text.
// Context is an encoding of the conversation used in this response; this
// can be sent in the next request to keep a conversational memory.
Context []int
}
GenerateDoneMsg is the message generated when the generation is complete. It contains the complete response along with [Context], which may be set on [Session.Context] to carry on the conversation.
type GenerateResponseMsg ¶
type GenerateResponseMsg struct {
ID int64 // ID is the generation session ID corresponding to the Response
CreatedAt time.Time // CreatedAt is the timestamp of the response.
// Response is the textual response in this specific call.
// Use [GenerateDoneMsg] or [Session.GetResponse()] for fuller responses.
Response string
}
GenerateResponseMsg is the message generated each time there is a reply from Ollama. The information contained is only partial. To check what has been received so far in the request, check [OllamataTeaSession.GetResponse()] To focus solely on full responses, listen for GenerateDoneMsg.
type ListModelResponse ¶
type ListModelResponse = ollama.ListModelResponse
Type alias in this package for convenience
type ModelChooser ¶
type ModelChooser struct {
Waiting string // Waiting to load message (default is "Loading models..")
MenuPrompt string // Menu prompt (default is "Select Ollama model")
// contains filtered or unexported fields
}
ModelChooser is a Terminal UX for selecting a local LLM model from Ollama.
func NewModelChooser ¶
func NewModelChooser(ollamaHost string) ModelChooser
NewModelChooser returns a new ModelChooser for the given Ollama Host.
func (ModelChooser) GetHost ¶
func (m ModelChooser) GetHost() string
GetHost returns the Ollama Host URL for the ModelChooser.
func (ModelChooser) GetLastError ¶
func (m ModelChooser) GetLastError() error
GetLastError returns the last error encountered from fetching the model list. Returns nil if there is no error.
func (ModelChooser) GetSelectedModel ¶
func (m ModelChooser) GetSelectedModel() *ollama.ListModelResponse
GetSelectedModel returns the selected model from the ModelChooser. Returns nil if there is no selected model.
func (ModelChooser) GetStyles ¶
func (m ModelChooser) GetStyles() list.Styles
GetStyles returns the list.Styles for the ModelChooser.
func (ModelChooser) Init ¶
func (m ModelChooser) Init() tea.Cmd
Init handles the initialization of an Session
func (ModelChooser) IsFetching ¶
func (m ModelChooser) IsFetching() bool
IsFetching returns true if the ModelChooser is fetching the model list.
func (ModelChooser) SetStyles ¶
func (m ModelChooser) SetStyles(styles list.Styles) ModelChooser
SetStyles sets a list.Styles for the TUI. The Spinner is set to the list.Styles.Spinner Returns nil if there is no selected model.
func (ModelChooser) Update ¶
func (m ModelChooser) Update(msg tea.Msg) (ModelChooser, tea.Cmd)
Update handles BubbleTea messages for the Session This is for starting/stopping/updating generation.
func (ModelChooser) View ¶
func (m ModelChooser) View() string
View renders the ModelChooser's view.
type ModelChooserAbortedMsg ¶
type ModelChooserSelectedMsg ¶
type ModelChooserSelectedMsg struct {
ID int64 // ID of the original request
OllamaHost string // Ollama Host generating the list
Selection ollama.ListModelResponse
}
type Session ¶
type Session struct {
Host string // Ollama Host -- really the service's URL
Model string // Ollama LLM model. See https://ollama.com/library
System string // Ollama System prompt
Template string // Ollama System prompt
Context []int // Ollama Context
Prompt string // Ollama Prompt
Suffix string // Ollama Prompt Suffix
Images []ImageData // List of base64-encoded images
Options map[string]interface{} // Options lists model-specific options
// contains filtered or unexported fields
}
Session holds the data for an OllamaTea Generate, both its request and built response See https://github.com/ollama/ollama/blob/main/api/types.go#L42
func NewSession ¶
func NewSession() Session
NewSession returns a new Session with the default values.
func (*Session) ClearError ¶
func (s *Session) ClearError()
func (*Session) ClearResponse ¶
func (s *Session) ClearResponse()
func (*Session) IsGenerating ¶
func (*Session) StartGenerateMsg ¶
type StartGenerateMsg ¶
type StartGenerateMsg struct {
ID int64 // ID is the session ID to start
}
type StopGenerateMsg ¶
type StopGenerateMsg struct {
ID int64 // ID is the session ID to stop
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
ot-ansi-to-png
command
|
|
|
ot-model-chooser
command
|
|
|
ot-png-prompt
command
|
|
|
ot-simplegen
command
|
|
|
ot-timechart
command
|