textgen

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: CC0-1.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Character

type Character struct {
	CharName        string `json:"char_name"`
	CharPersona     string `json:"char_persona"`
	CharGreeting    string `json:"char_greeting"`
	WorldScenario   string `json:"world_scenario"`
	ExampleDialogue string `json:"example_dialogue"`
}

type ChatRequest

type ChatRequest struct {
	Input              string  `json:"input"`
	MaxNewTokens       int     `json:"max_new_tokens"`
	DoSample           bool    `json:"do_sample"`
	Temp               float64 `json:"temperature"`
	TopP               float64 `json:"top_p"`
	TypicalP           float64 `json:"typical_p"`
	RepetitionPenalty  float64 `json:"repetition_penalty"`
	TopK               float64 `json:"top_k"`
	MinLength          int     `json:"min_length"`
	NoRepeatNgramSize  int     `json:"no_repeat_ngram_size"`
	NumBeams           int     `json:"num_beams"`
	PenaltyAlpha       float64 `json:"penalty_alpha"`
	LengthPenalty      float64 `json:"length_penalty"`
	EarlyStopping      bool    `json:"early_stopping"`
	YourName           string  `json:"your_name"`
	BotName            string  `json:"bot_name"`
	Context            string  `json:"context"`
	StopAfterNewline   bool    `json:"stop_after_newline"`
	MaxPromptSize      int     `json:"max_prompt_size"`
	GenerationAttempts int     `json:"generation_attempts"`
}

func (*ChatRequest) ApplyCharacter

func (cr *ChatRequest) ApplyCharacter(name string) error

func (*ChatRequest) ApplyPreset

func (cr *ChatRequest) ApplyPreset(name string) error

ApplyPreset mutates cr with the details in the preset by name.

func (*ChatRequest) MarshalJSON

func (cr *ChatRequest) MarshalJSON() ([]byte, error)

type ChatResponse

type ChatResponse struct {
	Data         []string `json:"data"` // [0] is user input, [1] is bot output
	Duration     float64  `json:"duration"`
	IsGenerating bool     `json:"is_generating"`
}

func Generate

func Generate(ctx context.Context, inp *ChatRequest) (*ChatResponse, error)

type Client

type Client struct {
	HTTP *http.Client
}
var (
	Default *Client = &Client{
		HTTP: http.DefaultClient,
	}
)

func (*Client) Generate

func (c *Client) Generate(ctx context.Context, cr *ChatRequest) (*ChatResponse, error)

Jump to

Keyboard shortcuts

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