llame

package module
v0.0.0-...-43c60f8 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 18 Imported by: 0

README

llame

llame generates commit messages for you with the help of LLMs.

llame demo

For now only the llama-server hosted models (from llama.cpp project) are supported.

Documentation

Index

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 Fatalf

func Fatalf(msg string, args ...any)

func GitCommit

func GitCommit(commitMsg string) error

func GitDiffStaged

func GitDiffStaged(ctx context.Context, files ...string) ([]byte, error)

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 InitFileLogging(dirs ...string) error

func MustGitStatus

func MustGitStatus() string

func NewGitRepo

func NewGitRepo() (*git.Repository, error)

func Printf

func Printf(msg string, args ...any)

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

type GitFiles struct {
	Tracked   []string
	Untracked []string
}

func FilesInCommit

func FilesInCommit() (*GitFiles, error)

type LlamaModel

type LlamaModel struct {
	RequestTimeout time.Duration
	// contains filtered or unexported fields
}

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

type TextMessage struct {
	Name    string // User or Assistant
	Message string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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