prompt

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package prompt provides shared types and utilities for working with .prompt.yml files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAzureChatMessageRole

func GetAzureChatMessageRole(role string) (azuremodels.ChatMessageRole, error)

GetAzureChatMessageRole converts a role string to azuremodels.ChatMessageRole

func TemplateString

func TemplateString(templateStr string, data interface{}) (string, error)

TemplateString templates a string with the given data using simple {{variable}} replacement

Types

type Choice

type Choice struct {
	Choice string  `yaml:"choice"`
	Score  float64 `yaml:"score"`
}

Choice represents a scoring choice for LLM evaluation

type Evaluator

type Evaluator struct {
	Name   string           `yaml:"name"`
	String *StringEvaluator `yaml:"string,omitempty"`
	LLM    *LLMEvaluator    `yaml:"llm,omitempty"`
	Uses   string           `yaml:"uses,omitempty"`
}

Evaluator represents an evaluation method (only used by eval command)

type File

type File struct {
	Name            string          `yaml:"name"`
	Description     string          `yaml:"description"`
	Model           string          `yaml:"model"`
	ModelParameters ModelParameters `yaml:"modelParameters"`
	Messages        []Message       `yaml:"messages"`
	// TestData and Evaluators are only used by eval command
	TestData   []map[string]interface{} `yaml:"testData,omitempty"`
	Evaluators []Evaluator              `yaml:"evaluators,omitempty"`
}

File represents the structure of a .prompt.yml file

func LoadFromFile

func LoadFromFile(filePath string) (*File, error)

LoadFromFile loads and parses a prompt file from the given path

func (*File) BuildChatCompletionOptions

func (f *File) BuildChatCompletionOptions(messages []azuremodels.ChatMessage) azuremodels.ChatCompletionOptions

BuildChatCompletionOptions creates a ChatCompletionOptions with the file's model and parameters

type LLMEvaluator

type LLMEvaluator struct {
	ModelID      string   `yaml:"modelId"`
	Prompt       string   `yaml:"prompt"`
	Choices      []Choice `yaml:"choices"`
	SystemPrompt string   `yaml:"systemPrompt,omitempty"`
}

LLMEvaluator represents LLM-based evaluation

type Message

type Message struct {
	Role    string `yaml:"role"`
	Content string `yaml:"content"`
}

Message represents a conversation message

type ModelParameters

type ModelParameters struct {
	MaxTokens   *int     `yaml:"maxTokens"`
	Temperature *float64 `yaml:"temperature"`
	TopP        *float64 `yaml:"topP"`
}

ModelParameters represents model configuration parameters

type StringEvaluator

type StringEvaluator struct {
	EndsWith   string `yaml:"endsWith,omitempty"`
	StartsWith string `yaml:"startsWith,omitempty"`
	Contains   string `yaml:"contains,omitempty"`
	Equals     string `yaml:"equals,omitempty"`
}

StringEvaluator represents string-based evaluation

Jump to

Keyboard shortcuts

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