Skip to main content
Home

Built and signed on GitHub Actions

Add magic spells to your code.

This package works with Cloudflare Workers, Node.js, Deno, BunIt is unknown whether this package works with Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
6 months ago (0.1.1)

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 inferene 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" ]
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@monty/incant

Import symbol

import * as incant from "@monty/incant";
or

Import directly with a jsr specifier

import * as incant from "jsr:@monty/incant";

Add Package

pnpm i jsr:@monty/incant
or (using pnpm 10.8 or older)
pnpm dlx jsr add @monty/incant

Import symbol

import * as incant from "@monty/incant";

Add Package

yarn add jsr:@monty/incant
or (using Yarn 4.8 or older)
yarn dlx jsr add @monty/incant

Import symbol

import * as incant from "@monty/incant";

Add Package

vlt install jsr:@monty/incant

Import symbol

import * as incant from "@monty/incant";

Add Package

npx jsr add @monty/incant

Import symbol

import * as incant from "@monty/incant";

Add Package

bunx jsr add @monty/incant

Import symbol

import * as incant from "@monty/incant";