cache

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "cache/v0.1.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Getter
	Putter
}

Cache interface

type Client

type Client struct {
	chatter.Chatter
	// contains filtered or unexported fields
}

func New

func New(cache Cache, chatter chatter.Chatter) *Client

Creates caching layer for LLM client.

Use github.com/akrylysov/pogreb to cache chatter on local file systems:

llm, err := /* create LLM client */
db, err := pogreb.Open("llm.cache", nil)
text := cache.New(db, llm)

func (*Client) HashKey

func (c *Client) HashKey(prompt string) []byte

func (*Client) Prompt

func (c *Client) Prompt(ctx context.Context, prompt []fmt.Stringer, opts ...chatter.Opt) (chatter.Reply, error)

type Getter

type Getter interface{ Get([]byte) ([]byte, error) }

Getter interface abstract storage

type Putter

type Putter interface{ Put([]byte, []byte) error }

Setter interface abstract storage

Jump to

Keyboard shortcuts

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