This library provides basic axioms for building and managing GPT prompts. It helps you build small and resuable prompt components and then let you compose them together to build larger ones.
NodeJS:
npm install prompt-compose
Creates a simple line of text. It is a basic building block for building larger prompts.
const question = Statement("How to make a website?");
question();
// "How to make a website?"
Creates a new section of text with title
and content
.
const problemSection = Section(
Statement("Problem Statement"),
Statement("How to make a website?")
);
problemSection();
//
// Problem Statement:
// How to make a website?
Asks for a data structure and creates a prompt where it asks GPT to return the response in the given format.
const formatTheReponse = Format([
{
stepIndex: "<number>",
stepDetails: "<string>"
}
]);
formatTheReponse();
// `Answer should be in a valid JSON, use the following structure:
// ResponseJSON: [{"stepIndex":"<number>","stepDetails":"<string>"}]`
const systemStatement = System(
Statement(`
You are an AI assistant, you help users solve the given problem.
- Your answeres are brief and to the point.
- You only answer in the format given by the user.
- If you don't know the answer to a question, you truthfully say that I don't know it.
- You can end your answer with "END_END_END" text.`)
);
systemStatement();
// `System:
//
// You are an AI assistant, you help users solve the given problem.
// - Your answeres are brief and to the point.
// - You only answer in the format given by the user.
// - If you don't know the answer to a question, you truthfully say that I don't know it.
// - You can end your answer with "END_END_END" text.`
Let you compose multiple prompts together.
const makePrompt = compose(
systemStatement,
problemSection,
);
makePrompt();
// System:
//
// You are an AI assistant, you help users solve the given problem.
// - Your answeres are brief and to the point.
// - You only answer in the format given by the user.
// - If you don't know the answer to a question, you truthfully say that I don't know it.
// - You can end your answer with "END_END_END" text.
// Problem Statement:
// How to make a website?
Configurable, adds a division between 2 given prompts.
const promptWithDivider = compose(
Statement("Do task 1."),
Divider(),
Statement("Do task 2.")
);
promptWithDivider()
// Do task 1.
//
// Do task 2.
An empty input.
const expectedResponse = Section(
Statement("AI"),
None()
);
expectedResponse();
// AI:
//
import { System, Section, Format, compose, Statement, None } from "prompt-compose";
const SystemStatement = System(Statement(`
You are an AI assistant, you help users solve the given problem.
- Your answeres are brief and to the point.
- You only answer in the format given by the user.
- If you don't know the answer to a question, you truthfully say that I don't know it.
- You can end your answer with "END_END_END" text.
`));
const ResponseFormater = Section(
Statement("Format"),
Format([
{
stepIndex: "<number>",
stepDetails: "<string>"
}
]),
);
const getProblemSolverPromptMaker = ()=>{
const solverPrompt = compose(
SystemStatement,
Section(
Statement("User"),
ResponseFormater,
Section(Statement("Problem")),
),
Section(
Statement("AI"),
None()
)
);
return (problemStatement)=>{
return solverPrompt(Statement(problemStatement));
};
}
const problemSolverPromptMaker = getProblemSolverPromptMaker();
const promptGenerated = problemSolverPromptMaker("How to build a website?");
console.log(promptGenerated);
// O/P:
// System:
// You are an AI assistant, you help users solve the given problem.
// - Your answeres are brief and to the point.
// - You only answer in the format given by the user.
// - If you don't know the answer to a question, you truthfully say that I don't know it.
// - You can end your answer with "END_END_END" text.
// User:
// Format:
// Answer should be in a valid JSON, use the following structure:
// ResponseJSON: [{"stepIndex":"<number>","stepDetails":"<string>"}]
// Problem:
// How to build a website?
// AI:
//
prompt-compose's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.