Prompts

All about prompts.

Prompt templates serve as predefined recipes for generating prompts tailored for language models within the GoLC project. These templates encompass instructions, few-shot examples, and contextual questions, specifically designed for various tasks. GoLC offers dedicated tools for crafting and utilizing prompt templates. The project emphasizes model-agnostic templates, fostering their seamless reuse across diverse language models. Conventionally, language models anticipate prompts in the form of either a string or a list of chat messages.

package main

import (
	"fmt"
	"log"

	"github.com/hupe1980/golc/prompt"
)

func main() {
	pt := prompt.NewTemplate(`Tell me a {{.adjective}} joke about {{.content}}.`)

	s, err := pt.Format(map[string]any{
		"adjective": "funny",
		"content":   "chickens",
	})
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(s)
}

Output:

Tell me a funny joke about chickens.
Last modified December 21, 2023: Update docs (e92768b)