Skip to content

montyanderson/incant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

incant

JSR

Add magic spells to your code.

dancing

usage

Incant gives you primtivies to integrate language model invocations safely.

Warning

All data provided as input to incant primitives will be sent to upstream inference providers. Avoid sending personal and sensitive information.

// incant looks in your env array for an OPENAI_API_KEY & other vars
// easy for end users to configure for your cli
const { createSelector, createFilter } = createIncant({
	env: Deno.env.toObject(),
});

selectors

// create a function to pick the highest number
const pickHighestNumber = createSelector<number>("Pick the highest number");

const input = [
	1,
	10,
	3,
	10000,
	5,
	999,
];

// type-safe and hallucination-safe – output is guaranteed to be one of input array
const highestNumber = await pickHighestNumber(input);

filters

// make a function to filter only male names
const filterMaleNames = createFilter<string>("Return male names");

const maleNames = await filterMaleNames([
	"John",
	"Jack",
	"Jane",
	"Beatrice",
	"Mike",
	"Emily",
	"Charlie",
	"Robin",
	"Alex",
]);

// original array ordering is preserved
// no hallucinations possible – output is guaranteed to be subset of input array
// [ "John", "Jack", "Mike", "Charlie", "Alex" ]

About

Add magic spells to your code.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •