jkomoros / prompt-garden

A framework for gardening LLM prompts
Apache License 2.0
9 stars 0 forks source link

Add caching and intermediate results #25

Open jkomoros opened 1 year ago

jkomoros commented 1 year ago

Currently seed.grow() returns the final result, and there's no good way (other than turning on verbose and looking at logs) to see what the intermediate results are.

Also, seeds, when grown with the same environment, should reuse the same result unless force is passed.

.grow() should return a Plant, which is a particular instantiated version of a seed with a given environment. seed.plant(env).grow(force). Seeds have a WeakMap memoization of env -> plant.

Garden should gain a plant(seedId, env) convenience wrapper and grow(seedID, env) convenience wrapper.

(Ensure that environments truly are readonly with typescript types)

See also a few comments in #3.

jkomoros commented 1 year ago

Perhaps profile should have a cache file that caches embed, prompt, and seed values unless force is true.

jkomoros commented 1 year ago

Add a notion of deterministic to seed-types where the output is fully implied by their inputs + environment. Everything but now, random, prompt, recall, retrieve, input are deterministic. (Others?)

Create a SeedCalculation type. An environment can be cloned and add a calculation (which fails if the environment already has a calculation). seed.growIncremental() returns the Calculation immediately. A Calculation has a .result : Promise<value> which can be awaited for the final value. A Calculation also has an events which is a generator function that returns a string of events as things happen.

The events are various types, a discriminated union.