
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@gpt-mind/prompts
Advanced tools
This repository contains a collection of prompts for the GPT-3 API.
npm install @gpt-mind/prompts
const prompts = require('@gpt-mind/prompts');
const definition = prompts.getPromptDefinition(`given the following three statements:
"{{statement1}}"
"{{statement2}}", and
"{{statement3}}", which top two statements are most likely to be true?`);
const statements = {
statement1: 'The sky is blue.',
statement2: 'The sky is green.',
statement3: 'The sky is red.',
};
if (definition.validate(statements)) { // check that all required params are present
const response = await definition.complete(params, apiKey, {}, ['mostlikely', 'nextmostlikely']);
console.log(response); // { "mostlikely": "The sky is blue.", "nextmostlikely": "The sky is green." }
}
function getPromptDefinition(prompt: string): PromptDefinition
This function gets the prompt definition object based on a given prompt string. It extracts replacement tokens from the prompt string, and creates an object with properties for prompt, params, validate, replace, and complete.
The validate property checks if all required parameters are present in the params object. The replace property replaces all replacement tokens in the prompt string with their corresponding values from the params object. The complete property uses an OpenAI API to complete the given prompt with a valid response.
prompt - A string representing the prompt to generate the prompt definition object for. Return Value Returns an object of type PromptDefinition which contains the following properties:
A string representing the original prompt.
A function that validates the params object to make sure all required params are present. It takes one parameter:
A function that replaces all replacement tokens in the prompt string with their corresponding values from the params object. It takes one parameter:
A function that uses the OpenAI API to complete the given prompt with a valid response. It takes three parameters:
const apiKey = 'my-api-key';
const prompt = 'My name is {{name}} and I like {{food}}.';
const params = { name: 'John', food: 'pizza' };
const promptDefinition = getPromptDefinition(prompt);
if (promptDefinition.validate(params)) {
const completedPrompt = await promptDefinition.complete(params, apiKey);
console.log(promptDefinition.replace(params) + completedPrompt);
}
Contributions are welcome! Please see CONTRIBUTING.md for more information.
summary with usage:
A library for generating prompts for the GPT-3 API. contains a number of pre-generated prompts as well as a function for generating your own. The function allows you to create prompts with replacement tokens that can be replaced with values from a params object, giving an easy programmatic interface for calling propmpts.
npm install @gpt-mind/prompts
const prompts = require('@gpt-mind/prompts');
const definition = prompts.getPromptDefinition(prompts.meaningOfStatement);
const params = {
statement: 'The sky is blue.',
};
if (definition.validate(params)) {
const completedPrompt = await definition.complete(params, apiKey);
console.log(definition.replace(params) + completedPrompt);
}
const prompts = require('@gpt-mind/prompts');
const definition = prompts.getPromptDefinition(`My name is {{name}} and I like {{food}}.`);
const params = { name: 'John', food: 'pizza' };
if (definition.validate(params)) {
const completedPrompt = await definition.complete(params, apiKey);
console.log(definition.replace(params) + completedPrompt);
}
FAQs
A collection of prompts for the gpt-mind library
The npm package @gpt-mind/prompts receives a total of 4 weekly downloads. As such, @gpt-mind/prompts popularity was classified as not popular.
We found that @gpt-mind/prompts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.