Documentation
¶
Index ¶
- Constants
- Variables
- func Fatalf(msg string, args ...any)
- func GitCommit(commitMsg string) error
- func GitDiffStaged(ctx context.Context, files ...string) ([]byte, error)
- func InitDiscardLogging()
- func InitFileLogging(dirs ...string) error
- func MustGitStatus() string
- func NewGitRepo() (*git.Repository, error)
- func Printf(msg string, args ...any)
- type CompletionQuery
- type GitFiles
- type LlamaModel
- type PromptFormat
- func (p PromptFormat) CharContent(content string) string
- func (p PromptFormat) CharMessage(content string) TextMessage
- func (p PromptFormat) History(textMsgs []TextMessage) (string, error)
- func (p PromptFormat) MustPrompt(system string, textMsgs ...TextMessage) string
- func (p PromptFormat) Prompt(system string, textMsgs ...TextMessage) (string, error)
- func (p PromptFormat) UserContent(content string) string
- func (p PromptFormat) UserMessage(content string) TextMessage
- type PromptFormats
- type StreamData
- type StreamResponse
- type TextMessage
Constants ¶
View Source
const ( GitCommitSubjectCharsMin = 50 GitCommiBodyCharsMax = 72 )
The 50/72 rule is a guideline for writing clear and concise Git commit messages:
View Source
const DebugLogFileName = "llame_debug.log"
View Source
const RecommendedCommitCharLen = 50
Variables ¶
View Source
var ( Errorf = logFuncWithStack(slog.Error) Debugf = logFuncWithStack(slog.Debug) )
View Source
var DefaultDebugDirs = []string{"/tmp/", "/tmp/var/"}
View Source
var NoStagedFilesErr = errors.New("no staged files")
Functions ¶
func GitDiffStaged ¶
GitDiffStaged gets a diff for all staged files (if only called with context) or for the specified ones.
func InitDiscardLogging ¶
func InitDiscardLogging()
func InitFileLogging ¶
func MustGitStatus ¶
func MustGitStatus() string
func NewGitRepo ¶
func NewGitRepo() (*git.Repository, error)
Types ¶
type CompletionQuery ¶
type CompletionQuery struct {
Prompt string `json:"prompt"`
Temperature float32 `json:"float,omitempty"`
NPredict int `json:"n_predict,omitempty"` // Default: `-1`, where `-1` is infinity. Set the maximum number of tokens to predict when generating text.
Stream bool `json:"stream,omitempty"`
}
CompletionQuery is a subset of all allowed options of llama-server /completion. TODO: make it compatible with: https://github.com/openai/openai-openapi/blob/master/openapi.yaml
type GitFiles ¶
func FilesInCommit ¶
type LlamaModel ¶
func NewLlamaCppModel ¶
func NewLlamaCppModel(url string, reqTimeout time.Duration) *LlamaModel
func (*LlamaModel) ReadStream ¶
func (this *LlamaModel) ReadStream(ctx context.Context, completion CompletionQuery) (<-chan StreamResponse, error)
type PromptFormat ¶
type PromptFormat struct {
Template string `json:"template"`
HistoryTemplate string `json:"historyTemplate"`
Char string `json:"char"`
CharMsgPrefix string `json:"charMsgPrefix"`
CharMsgSuffix string `json:"charMsgSuffix"`
User string `json:"user"`
UserMsgPrefix string `json:"userMsgPrefix"`
UserMsgSuffix string `json:"userMsgSuffix"`
Stops string `json:"stops"`
}
func (PromptFormat) CharContent ¶
func (p PromptFormat) CharContent(content string) string
func (PromptFormat) CharMessage ¶
func (p PromptFormat) CharMessage(content string) TextMessage
func (PromptFormat) History ¶
func (p PromptFormat) History(textMsgs []TextMessage) (string, error)
func (PromptFormat) MustPrompt ¶
func (p PromptFormat) MustPrompt(system string, textMsgs ...TextMessage) string
func (PromptFormat) Prompt ¶
func (p PromptFormat) Prompt(system string, textMsgs ...TextMessage) (string, error)
func (PromptFormat) UserContent ¶
func (p PromptFormat) UserContent(content string) string
func (PromptFormat) UserMessage ¶
func (p PromptFormat) UserMessage(content string) TextMessage
type PromptFormats ¶
type PromptFormats map[string]PromptFormat
func GetPromptFormats ¶
func GetPromptFormats() PromptFormats
type StreamData ¶
type StreamData struct {
Content string `json:"content"` // The content being streamed
Stop bool `json:"stop"` // Indicates whether the stream should stop
IdSlot int `json:"id_slot"` // Slot to which the task is assigned
Multimodal bool `json:"multimodal"` // Indicates if the response is multimodal
Index int `json:"index"` // Index of the response in the stream
}
type StreamResponse ¶
type StreamResponse struct {
StreamData
Error error
}
type TextMessage ¶
Click to show internal directories.
Click to hide internal directories.
