chat

package
v0.0.8-alpha1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package chat provides a chat prompt template. Sometimes you need to define a chat prompt, this package provides a way to do that.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChatMessages = errors.New("unable to convert chat messages")
)

Functions

This section is empty.

Types

type Chat

type Chat struct {
	// contains filtered or unexported fields
}

func New

func New(promptMessages ...PromptMessage) *Chat

func (*Chat) PromptMessages

func (c *Chat) PromptMessages() PromptMessages

func (*Chat) ToMessages

func (p *Chat) ToMessages() (Messages, error)

ToMessages converts the chat prompt template to a list of messages.

type Message

type Message struct {
	Type    MessageType
	Content string
}

type MessageType

type MessageType string
const (
	MessageTypeSystem    MessageType = "system"
	MessageTypeUser      MessageType = "user"
	MessageTypeAssistant MessageType = "assistant"
)

type Messages

type Messages []Message

type Prompt

type Prompt interface {
	String() string
	Format(input types.M) error
}

type PromptMessage

type PromptMessage struct {
	Type   MessageType
	Prompt Prompt
}

type PromptMessages

type PromptMessages []PromptMessage

Jump to

Keyboard shortcuts

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