chat

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer interface {
	Newer
	Unmarshal([]byte) error
}

type AnswerChunk

type AnswerChunk interface {
	New() any
	Unmarshal([]byte) error
	SetError(err error)
}

type AnswerChunks

type AnswerChunks[A Answer] interface {
	Combine() A
}

type Chat

type Chat[Q Question, A Answer, AC AnswerChunk] interface {
	Ask(ctx context.Context, q Q) (A, error)
	Stream(ctx context.Context, q Q) (chan AC, error)
}

type Client

type Client[Q Question, A Answer, AC AnswerChunk] struct {
	// contains filtered or unexported fields
}

func New

func New[Q Question, A Answer, AC AnswerChunk](cli *http.Client, url string, apikey string) *Client[Q, A, AC]

func (*Client[Q, A, _]) Ask

func (c *Client[Q, A, _]) Ask(ctx context.Context, q Q) (A, error)

func (*Client[Q, _, AC]) Stream

func (c *Client[Q, _, AC]) Stream(ctx context.Context, q Q) (chan AC, error)

type Error

type Error struct {
	Type    string
	Message string
}

type Newer

type Newer interface {
	New() any
}

type Question

type Question interface {
	Newer
	Marshal() ([]byte, error)
}

type QuestionAnswer

type QuestionAnswer[Q Question, A Answer, AC AnswerChunk] struct {
	Question     Q
	Answer       A
	AnswerChunks []AC
}

Jump to

Keyboard shortcuts

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