Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultMaxTokens = 256
View Source
const DefaultTemperature = 0.7
Variables ¶
View Source
var ChatCmd = &cobra.Command{ Use: "chat", Short: "read a chat from stdin and send to LLM chat", Run: func(cmd *cobra.Command, args []string) { input, err := io.ReadAll(os.Stdin) if err != nil { slog.Error("failed to read input", "err", err) return } lines := strings.Split(string(input), "\n") var temperature float32 = DefaultTemperature maxTokens := DefaultMaxTokens if strings.HasPrefix(lines[0], "#") { temperature = getTemperature(lines[0]) maxTokens = getMaxTokens(lines[0]) lines = lines[0:] } chatClient := vichat.New().WithTemperature(temperature).WithMaxTokens(maxTokens) messages := chat.New(CreatePrompts(lines)...) res, err := chatClient.Chat(context.TODO(), messages) if err != nil { slog.Error("failed", "err", err.Error()) return } println(res) }, }
View Source
var InstallCmd = &cobra.Command{ Use: "install-vim-plugin", Short: "install the vim plugin", Aliases: []string{"i"}, Run: func(cmd *cobra.Command, args []string) { installVim() }, }
View Source
var TokCmd = &cobra.Command{ Use: "tok", Short: "given a piece of text, tok estimate the num of tokens for a given model offline", Run: func(cmd *cobra.Command, args []string) { f := cmd.Flags() model, err := f.GetString("model") if err != nil { slog.Error("failed", "err", err) } text, err := io.ReadAll(os.Stdin) if err != nil { slog.Error("failed", "err", err) } toks, err := vichat.Tokenize(string(text), model) if err != nil { slog.Error("failed", "err", err) return } fmt.Println(len(toks)) }, }
Functions ¶
func CreatePrompts ¶
func CreatePrompts(lines []string) []chat.PromptMessage
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.