Status: alpha
htmx provides an incredible amount of functionality through hypertext attributes. What if we can do the same prompts?
dataprompt allows you to declare data sources and actions right from a .prompt
files, that are wired out to a file based routing system based on Next.js' syntax.
- Single File Prompts: Contain everything a prompt needs from model choice, structured output, data sources, and post-generation actions, right in a single prompt file.
- dotprompt format:: Extends the dotprompt prompt.
- File based routing: All prompts are served over an api server based on file based routing conventions:
prompts/items/[id].prompt
. - Scheduled Tasks:: Set prompt files to run on a schedule with node-cron expressions.
- JavaScript API: Use dataprompt right inside your app by getting dataprompt files as Genkit flows.
- Structured Output: Use Zod schema's to set structured output.
- Plugin System: Create your own data sources, actions, and triggers.
- Powered by Genkit: Every prompt file exports out to a Genkit flow.
npm install dataprompt genkit
npx dataprompt create <project-directory>
Create dotprompt, .prompt
, files that combine Handlebars templating with data sources.
// schema.ts
export const SharkFact = z.object({
fact: z.string(),
dateString: z.string().describe('ISO Date String')
})
Optionally create a dataprompt.config.js
file to customize dataprompt
:
// dataprompt.config.js
export default {
promptsDir: 'prompts',
schemaFile: 'myschema.ts',
plugins: [
]
}
import { dataprompt } from 'dataprompt';
const store = dataprompt({
promptsDir: 'prompts',
// schemaFile: 'schema.ts', // Optional: Path to your schema file
// plugins: [...] // Optional: Array of plugins
});
// Generate a prompt based on a URL or request object
const sharkFact = await store.generate({
url: '/sharks/great-white' // Or: request: Request object
});
console.log({ sharkFact });
Spins up a development server that serves your prompts and handles data fetching.
dataprompt dev