Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Examples

Runnable Go programs that show how to use pkg/filters from your own code.

Folder What it shows
basic/ The smallest possible use — one prompt in, compressed prompt out, with the saving metrics
configured/ Turning filters on/off per pipeline, discovering languages and filter names
llm-wrapper/ Wrapping an LLM client so every outgoing prompt is compressed automatically (LLM call is stubbed — replace with your provider)

Run any example

From the repo root:

go run ./examples/basic
go run ./examples/configured
go run ./examples/llm-wrapper

Use from your own project

go get github.com/bladysh/exprompt

Then in your code:

import "github.com/bladysh/exprompt/pkg/exprompt"

p := filters.NewPipeline("en")
r, err := p.Compress("Actually you should test the API")
if err != nil { /* unknown language, malformed dicts */ }

fmt.Println(r.Text)     // "u shld test the API"
fmt.Println(r.Savings)  // 0.32
fmt.Println(r.Anchors)  // ["API"]

See the main README for the full public API.

One thing worth knowing

Reuse the pipeline. NewPipeline parses dictionaries and compiles regexes — building it once and reusing the *Pipeline across every call keeps each compression sub-millisecond. The pipeline is safe to use from many goroutines at the same time (just don't change filter settings concurrently with Compress).