Documentation
¶
Index ¶
- Variables
- func ChainOfThought(ctx context.Context, l LLM, question string, opts ...PromptOption) (string, error)
- func QuestionAnswer(ctx context.Context, l LLM, question string, opts ...PromptOption) (string, error)
- func Summarize(ctx context.Context, l LLM, text string, opts ...PromptOption) (string, error)
- type ConfigOption
- type Example
- type LLM
- type Prompt
- type PromptOption
- type PromptTemplate
- type PromptTemplateOption
Constants ¶
This section is empty.
Variables ¶
var QuestionAnswerTemplate = NewPromptTemplate( "QuestionAnswer", "Answer the given question", "Answer the following question:\n\n{{.Question}}", WithPromptOptions( WithDirectives("Provide a clear and concise answer"), WithOutput("Answer:"), ), )
Functions ¶
func ChainOfThought ¶
func ChainOfThought(ctx context.Context, l LLM, question string, opts ...PromptOption) (string, error)
ChainOfThought performs a chain of thought reasoning
func QuestionAnswer ¶
func QuestionAnswer(ctx context.Context, l LLM, question string, opts ...PromptOption) (string, error)
QuestionAnswer performs question answering
Types ¶
type ConfigOption ¶ added in v0.0.3
ConfigOption is a function type that modifies a Config
func SetAPIKey ¶ added in v0.0.3
func SetAPIKey(key string) ConfigOption
SetAPIKey sets the API key for the current provider in the Config
func SetMaxTokens ¶ added in v0.0.3
func SetMaxTokens(maxTokens int) ConfigOption
SetMaxTokens sets the max tokens in the Config
func SetModel ¶ added in v0.0.3
func SetModel(model string) ConfigOption
SetModel sets the model in the Config
func SetProvider ¶ added in v0.0.3
func SetProvider(provider string) ConfigOption
SetProvider sets the provider in the Config
func SetTemperature ¶ added in v0.0.3
func SetTemperature(temperature float64) ConfigOption
SetTemperature sets the temperature in the Config
func SetTimeout ¶ added in v0.0.3
func SetTimeout(timeout time.Duration) ConfigOption
SetTimeout sets the timeout in the Config
type LLM ¶
type LLM interface {
Generate(ctx context.Context, prompt string) (response string, fullPrompt string, err error)
SetOption(key string, value interface{})
}
func NewLLM ¶
func NewLLM(opts ...ConfigOption) (LLM, error)
NewLLM creates a new LLM instance with the provided config options
type Prompt ¶
type Prompt struct {
Input string
Output string
Directives []string
Context string
MaxLength int
Examples []string
}
Prompt represents a structured prompt for an LLM
func NewPrompt ¶
func NewPrompt(input string, opts ...PromptOption) *Prompt
NewPrompt creates a new Prompt with the given input and applies any provided options
func (*Prompt) Apply ¶ added in v0.0.3
func (p *Prompt) Apply(opts ...PromptOption)
Apply applies the given options to the Prompt
type PromptOption ¶ added in v0.0.3
type PromptOption func(*Prompt)
PromptOption is a function type that modifies a Prompt
func WithContext ¶ added in v0.0.3
func WithContext(context string) PromptOption
WithContext adds context to the Prompt
func WithDirectives ¶ added in v0.0.3
func WithDirectives(directives ...string) PromptOption
WithDirectives adds directives to the Prompt
func WithExamples ¶ added in v0.0.3
func WithExamples(examples ...string) PromptOption
WithExamples adds examples to the Prompt
func WithMaxLength ¶ added in v0.0.3
func WithMaxLength(length int) PromptOption
WithMaxLength sets the maximum length for the output
func WithOutput ¶ added in v0.0.3
func WithOutput(output string) PromptOption
WithOutput adds an output specification to the Prompt
type PromptTemplate ¶ added in v0.0.3
type PromptTemplate struct {
Name string
Description string
Template string
Options []PromptOption
}
PromptTemplate represents a template for generating prompts
func NewPromptTemplate ¶ added in v0.0.3
func NewPromptTemplate(name, description, template string, opts ...PromptTemplateOption) *PromptTemplate
NewPromptTemplate creates a new PromptTemplate with the given name, description, and template
type PromptTemplateOption ¶ added in v0.0.3
type PromptTemplateOption func(*PromptTemplate)
PromptTemplateOption is a function type that modifies a PromptTemplate
func WithPromptOptions ¶ added in v0.0.3
func WithPromptOptions(options ...PromptOption) PromptTemplateOption
WithPromptOptions adds PromptOptions to the PromptTemplate