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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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