gen

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FullRequest

type FullRequest struct {
	Request
	Prompts []prompt.Prompt `json:"prompts"`
}

type Gen

type Gen interface {
	Generator(options ...Option) *Generator
}

type Generator

type Generator struct {
	Prompter Prompter
	Request  Request
}

func (*Generator) AddTools

func (g *Generator) AddTools(tool ...tools.Tool) *Generator

func (*Generator) MaxTokens

func (b *Generator) MaxTokens(maxTokens int) *Generator

func (*Generator) Model

func (b *Generator) Model(model Model) *Generator

func (*Generator) Prompt

func (b *Generator) Prompt(prompts ...prompt.Prompt) (*Response, error)

func (*Generator) SetConfig

func (b *Generator) SetConfig(config Request) *Generator

func (*Generator) SetOutputSchema

func (b *Generator) SetOutputSchema(element any) *Generator

func (*Generator) SetToolConfig

func (b *Generator) SetToolConfig(tool tools.Tool) *Generator

func (*Generator) SetTools

func (b *Generator) SetTools(tool ...tools.Tool) *Generator

func (*Generator) StopAt

func (b *Generator) StopAt(stop ...string) *Generator

func (*Generator) System

func (b *Generator) System(prompt string) *Generator

func (*Generator) Temperature

func (b *Generator) Temperature(temperature float64) *Generator

func (*Generator) Tools

func (g *Generator) Tools() []tools.Tool

func (*Generator) TopP

func (b *Generator) TopP(topP float64) *Generator

type Model

type Model struct {
	Provider    string `json:"provider"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`

	InputContentTypes []string `json:"input_content_types,omitempty"`

	InputMaxToken  int `json:"input_max_token,omitempty"`
	OutputMaxToken int `json:"output_max_token,omitempty"`

	SupportTools            bool `json:"support_tools,omitempty"`
	SupportStructuredOutput bool `json:"support_structured_output,omitempty"`
}

func (Model) FQN

func (m Model) FQN() string

func (Model) String

func (m Model) String() string

type Option

type Option func(generator *Generator) *Generator

func WithMaxTokens

func WithMaxTokens(maxTokens int) Option

func WithModel

func WithModel(model Model) Option

func WithOutput

func WithOutput(element any) Option

func WithRequest

func WithRequest(requset Request) Option

func WithStopAt

func WithStopAt(stop ...string) Option

func WithSystem

func WithSystem(prompt string) Option

func WithTemperature

func WithTemperature(temperature float64) Option

func WithToolConfig

func WithToolConfig(tool tools.Tool) Option

func WithTools

func WithTools(tools ...tools.Tool) Option

func WithTopP

func WithTopP(topP float64) Option

type Prompter

type Prompter interface {
	SetRequest(request Request)
	Prompt(prompts ...prompt.Prompt) (*Response, error)
}

type Request

type Request struct {
	Model Model `json:"model"`

	SystemPrompt string `json:"system_prompt"`

	StopSequences []string `json:"stop_sequences"`
	TopP          float64  `json:"top_p"`
	Temperature   float64  `json:"temperature"`
	MaxTokens     int      `json:"max_tokens"`

	OutputSchema *schema.JSON `json:"output_schema"`

	Tools      []tools.Tool `json:"tools"`
	ToolConfig *tools.Tool  `json:"tool"`
}

type Response

type Response struct {
	Texts []string     `json:"texts,omitempty"`
	Tools []tools.Call `json:"tools,omitempty"`

	Metadata models.Metadata `json:"metadata,omitempty"`
}

func (*Response) AsText

func (r *Response) AsText() (string, error)

func (*Response) AsTools

func (r *Response) AsTools() ([]tools.Call, error)

func (*Response) Eval

func (r *Response) Eval() (err error)

func (*Response) IsText

func (r *Response) IsText() bool

func (*Response) IsTools

func (r *Response) IsTools() bool

func (*Response) Unmarshal

func (r *Response) Unmarshal(ref any) error

Jump to

Keyboard shortcuts

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