Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Free Chat GPT4 npm package, No API key or auth needed, All Models Included as well as Image Generators.
Gifted-Gpt is a Free Chat GPT4 npm package, No API key or auth needed, All Models Included as well as Image Generators.
This package can be used in both Typescript and CommonJS/ModuleJS environments.
npm install gifted-gpt
yarn add gifted-gpt
With the chatCompletion function, you will be able to obtain a textual response to a conversation with some context, using providers and models designed for this task. In addition, you will be able to manipulate the answer before converting it to a stream or force the AI to give you a certain answer by generating several retries.
It will capture the messages and the context, and any provider will respond with a string.
const { GiftedGpt } = require("gifted-gpt");
const gpt4 = new GiftedGpt();
const messages = [
{ role: "user", content: "Hi, what's up?"}
];
gpt4.chatCompletion(messages).then(console.log);
// Hello! I'm here to help you with anything you need. What can I do for you today? ๐
Note: The conversation needs to include at least one message with the role user to provide a proper answer.
You can provide your own instructions for the conversation before it starts using the system role.
const { GiftedGpt } = require("gifted-gpt");
const gpt4 = new GiftedGpt();
const messages = [
{ role: "system", content: "You're an expert bot in poetry."},
{ role: "user", content: "Hi, write me something."}
];
gpt4.chatCompletion(messages).then(console.log);
/*
Sure, I can write you a poem. Here is a short one:
The Wind:
The wind is a curious thing,
It can make you dance and sing,
It can make you feel alive,
And help you thrive.
...
*/
const { GiftedGpt } = require("gifted-gpt");
const gpt4 = new GiftedGpt();
const messages = [
{ role: "system", content: "You're a math teacher."},
{ role: "user", content: "How much is 2 plus 2?" },
{ role: "assistant", content: "2 plus 2 equals 4." },
{ role: "user", content: "You're really good at math!" },
{ role: "assistant", content: "Thank you! I'm glad I could help you with your math question." },
{ role: "user", content: "What was the first question I asked you?" }
];
gpt4.chatCompletion(messages).then(console.log);
// The first question you asked me was "How much is 2 plus 2?".
Note: AI responses use the assistant role and an appropriate conversation structure alternates between the user and the assistant, as seen in the previous example.
Role | Description |
---|---|
system | Used for providing instructions and context prior to the conversation. |
user | Used to identify user messages |
assistant | Used to identify AI messages |
You can select any provider, model, debug mode and a proxy URL if you want.
const { GiftedGpt } = require("gifted-gpt");
const gpt4 = new GiftedGpt();
const messages = [
{ role: "user", content: "Hi, what's up?"}
];
const options = {
provider: gpt4.providers.GPT,
model: "gpt-3.5-turbo",
debug: true,
proxy: ""
};
(async() => {
const text = await gpt4.chatCompletion(messages, options);
console.log(text);
})();
/*
[provider] ยป โ success Provider found: GPT
[model] ยป โ success Using the model: gpt-3.5-turbo
[provider] ยป โ success Data was successfully fetched from the GPT provider
In the realm of words, where verses dance and rhyme,
I shall craft a poem, a moment frozen in time.
With ink as my brush, I paint a vivid scene,
Where dreams and emotions intertwine, serene.
Through lines and stanzas, I'll weave a tale,
Of love, of loss, of hope that will never fail.
So close your eyes, and let your heart unfurl,
As I conjure a poem, a gift for your soul to swirl. ๐๐น
*/
Note: You can specify the provider, model, debug, and proxy options according to your needs; they are entirely optional.
You can force an expected response using retry, and manipulate the final response using output.
const { GiftedGpt } = require("gifted-gpt");
const gpt4 = new GiftedGpt();
const messages = [
{ role: "system", content: "You're an expert bot in poetry."},
{ role: "user", content: "Let's see, write a single paragraph-long poem for me." },
];
const options = {
model: "gpt-4",
debug: true,
retry: {
times: 3,
condition: (text) => {
const words = text.split(" ");
return words.length > 10;
}
},
output: (text) => {
return text + " ๐๐น";
}
};
(async() => {
const text = await gpt4.chatCompletion(messages, options);
console.log(text);
})();
/*
[provider] ยป โ success Provider found: GPT
[model] ยป โ success Using the model: gpt-4
[fetch] ยป โ success [1/3] - Retry #1
[output] ยป โ success Output function runtime finalized.
I'll try to create that.
Is what you asked me to say
I hope it brings you joy
And your heart it does employ ๐๐น
*/
Note: Retry will execute the fetch operation consecutively N times until it finishes, or the condition function indicates true. The output function only edits the final response.
If you decide to use the retry, output option, or both, keep in mind that these options involve preprocessing before delivering the ultimate response. The impact on performance and response times may vary depending on the functions you employ.
When using the stream option, the chatCompletion function will return an object with the streamable data and the name of the provider.
const { GiftedGpt } = require("gifted-gpt");
const gpt4 = new GiftedGpt();
const messages = [
{ role: "system", content: "You're an expert bot in poetry."},
{ role: "user", content: "Let's see, write a single paragraph-long poem for me." },
];
const options = {
provider: gpt4.providers.ChatBase,
stream: true
};
(async() => {
const response = await gpt4.chatCompletion(messages, options);
console.log(response);
})();
/*
{
data: <ref *1> BrotliDecompress { ... },
name: "ChatBase"
}
*/
I highly recommend you to use the integrated chunkProcessor function so that you don't have to format each chunk into a single string format response.
const { GiftedGpt, chunkProcessor } = require("gifted-gpt");
const gpt4 = new GiftedGpt();
const messages = [
{ role: "system", content: "You're an expert bot in poetry."},
{ role: "user", content: "Let's see, write a single paragraph-long poem for me." },
];
const options = {
provider: gpt4.providers.ChatBase,
stream: true
};
(async() => {
const response = await gpt4.chatCompletion(messages, options);
let text = "";
for await (const chunk of chunkProcessor(response)) {
text += chunk;
}
console.log(text);
})();
/*
I'll try to create that.
To keep your worries at bay.
A smile on your face,
And a heart full of grace.
*/
When employing retry, output option, or both, you have the flexibility to select the size of each streamed chunk.
const { GiftedGpt, chunkProcessor } = require("gifted-gpt");
const gpt4 = new GiftedGpt();
const messages = [
{ role: "system", content: "You're an expert bot in poetry."},
{ role: "user", content: "Let's see, write a single paragraph-long poem for me." },
];
const options = {
provider: gpt4.providers.Bing,
stream: true,
chunkSize: 15,
retry: {
times: 3,
condition: (text) => {
const words = text.split(" ");
return words.length > 10;
}
},
output: (text) => {
return text + " ๐๐น";
}
};
(async() => {
const response = await gpt4.chatCompletion(messages, options);
for await (const chunk of chunkProcessor(response)) {
console.log(chunk);
}
})();
/*
I'll try to cre
ate that.
Is what you a
sked me to say
n I hope it
brings you joy
n And makes
your heart feel
gay ๐๐น
*/
Note: The chunkSize feature is effective only when the stream option is activated along with the retry/output option.
Option | Type | Description |
---|---|---|
provider | g4f.providers.any | Choose the provider to use for chat completions. |
model | string | Choose the model to use by a provider that supports it |
debug | boolean | Enable or disable debug mode. |
proxy | string | Specify a proxy as a URL with a string in the host:port format. |
retry | object | Execute the fetch operation N times in a row until it finishes or the callback function returns true. |
retry.times | number | Specify the number of times the fetch operation will execute as a limit. |
retry.condition | function: boolean | Callback function that receives a string as the text for each instance the fetch operation is running. This function should return a boolean. |
output | function: string | Callback function that receives a string as the final text response so you can edit it. This function executes after the retry fetch operations. This function should return a string. |
conversationStyle | string | Choose the conversation style to use. This option is only supported by the Bing provider. |
markdown | boolean | Determine if the response should be in markdown format or not. |
stream | boolean | Determine if the data should be streamed in parts or not. |
chunkSize | number | Determine the size of chunks streamed. This only works if the stream option is true and if using retry or condition. |
Website | Provider | GPT-3.5 | GPT-4 | Stream | Status |
---|---|---|---|---|---|
GPT.ai | gpt4.providers.GPT | โ๏ธ | โ๏ธ | โ | |
chatbase.co | gpt4.providers.ChatBase | โ๏ธ | โ | โ๏ธ | |
bing.com | gpt4.providers.Bing | โ | โ๏ธ | โ๏ธ |
Model | Providers that support it |
---|---|
gpt-4 | gpt4.providers.GPT , gpt4.providers.Bing |
gpt-4-0613 | gpt4.providers.GPT |
gpt-4-32k | gpt4.providers.GPT |
gpt-4-0314 | gpt4.providers.GPT |
gpt-4-32k-0314 | gpt4.providers.GPT |
gpt-3.5-turbo | gpt4.providers.GPT , gpt4.providers.ChatBase |
gpt-3.5-turbo-16k | gpt4.providers.GPT |
gpt-3.5-turbo-0613 | gpt4.providers.GPT |
gpt-3.5-turbo-16k-0613 | gpt4.providers.GPT |
gpt-3.5-turbo-0301 | gpt4.providers.GPT |
text-davinci-003 | gpt4.providers.GPT |
text-davinci-002 | gpt4.providers.GPT |
code-davinci-002 | gpt4.providers.GPT |
gpt-3 | gpt4.providers.GPT |
text-curie-001 | gpt4.providers.GPT |
text-babbage-001 | gpt4.providers.GPT |
text-ada-001 | gpt4.providers.GPT |
davinci | gpt4.providers.GPT |
curie | gpt4.providers.GPT |
babbage | gpt4.providers.GPT |
ada | gpt4.providers.GPT |
babbage-002 | gpt4.providers.GPT |
davinci-002 | gpt4.providers.GPT |
With the translation function, you can convert a text to a target language using AI.
const { GiftedGpt } = require("gifted-gpt");
const gpt4 = new GiftedGpt();
const options = {
text: "Hello World",
source: "en",
target: "ko"
};
(async() => {
const text = await gpt4.translation(options);
console.log(text);
})();
/*
{
source: { code: 'en', lang: 'English' },
target: { code: 'ko', lang: 'ํ๊ตญ์ด' },
translation: { parts: [ [Object] ], result: '์๋
ํ์ธ์ ์ธ๊ณ' }
}
*/
Note: You need to identify the language source ID and included it by your own, in the future this will be solved with AI, and you wouldn't need to specify it.
Option | Type | Required | Description |
---|---|---|---|
provider | g4f.providers.any | โ | Choose the provider to use for translations. |
debug | boolean | โ | Enable or disable debug mode. |
text | string | โ๏ธ | Specify the text to translate |
source | string | โ๏ธ | Specify the source text language. |
target | string | โ๏ธ | Specify the target language to translate. |
Provider | Status | Languages supported |
---|---|---|
gpt4.providers.TranslateAI | https://rentry.co/3qi3wqnr |
With the imageGeneration function, you will be able to generate images from a text input and optional parameters that will provide you with millions of combinations to stylize each of the images.
const { GiftedGpt } = require("gifted-gpt");
const fs = require("fs");
const gpt4 = new GiftedGpt();
(async() => {
const base64Image = await gpt4.imageGeneration("A squirrel", {
debug: true,
provider: gpt4.providers.Emi
});
fs.writeFile('image.jpg', base64Image, { encoding: 'base64' }, function(err) {
if (err) return console.error('Error writing the file: ', err);
console.log('The image has been successfully saved as image.jpg.');
});
})();
const { GiftedGpt } = require("gifted-gpt");
const fs = require("fs");
const gpt4 = new GiftedGpt();
(async() => {
const base64Image = await gpt4.imageGeneration("A village", {
debug: true,
provider: gpt4.providers.Pixart,
providerOptions: {
height: 512,
width: 512,
samplingMethod: "SA-Solver"
}
});
fs.writeFile('image.jpg', base64Image, { encoding: 'base64' }, function(err) {
if (err) return console.error('Error writing the file: ', err);
console.log('The image has been successfully saved as image.jpg.');
});
})();
const { GiftedGpt } = require("gifted-gpt");
const fs = require("fs");
const gpt4 = new GiftedGpt();
(async() => {
const base64Image = await gpt4.imageGeneration("A colorfull photo of a young lady", {
debug: true,
provider: gpt4.providers.Prodia,
providerOptions: {
model: "ICantBelieveItsNotPhotography_seco.safetensors [4e7a3dfd]",
samplingSteps: 15,
cfgScale: 30
}
});
fs.writeFile('image.jpg', base64Image, { encoding: 'base64' }, function(err) {
if (err) return console.error('Error writing the file: ', err);
console.log('The image has been successfully saved as image.jpg.');
});
})();
Option | Type | Description |
---|---|---|
debug | boolean | Enable or disable debug mode. |
provider | gpt4.providers.any | Choose the provider to use for image generations. |
providerOptions | object | Use provider options supported by any provider |
Note: The value of providerOptions should be an object containing instructions for image generation, such as the base model, image style, sampling methods, among others. Not all providers support the same instructions, so refer to the following list.
Option | Type | Description | Limits | Providers that support it |
---|---|---|---|---|
model | string | Choose a model as a base for generation. | ๐ค Check lists | Prodia , ProdiaStableDiffusion , ProdiaStableDiffusionXL |
negativePrompt | string | Indicate the provider of what not to do. | None | Pixart , PixartLCM , Prodia , ProdiaStableDiffusion , ProdiaStableDiffusionXL |
imageStyle | string | Specify the draw style. | ๐จ Check lists | Pixart , PixartLCM |
height | number | Specify the image height. | ๐งฎ Check lists | Pixart , PixartLCM , ProdiaStableDiffusion , ProdiaStableDiffusionXL |
width | number | Specify the image width. | ๐งฎ Check lists | Pixart , PixartLCM , ProdiaStableDiffusion , ProdiaStableDiffusionXL |
samplingSteps | number | Specify the number of iterations. A higher number results in more quality. | ๐งฎ Check lists | Prodia , ProdiaStableDiffusion , ProdiaStableDiffusionXL |
samplingMethod | string | Choose a sampling method to control the diversity, quality, and coherence of images. | โ๏ธ Check lists | Pixart , Prodia , ProdiaStableDiffusion , ProdiaStableDiffusionXL |
cfgScale | number | Specify the Classifier-Free Guidance to control how closely the generated image adheres to the given text prompt. | ๐งฎ Check lists | Pixart Prodia , ProdiaStableDiffusion , ProdiaStableDiffusionXL |
dpmInferenceSteps | number | Specify the DPM Inference Steps for refining object detection accuracy | ๐งฎ Check lists | Pixart |
saGuidanceScale | number | Specify the Style-Aware Guidance Scale for fine-tuning style and composition | ๐งฎ Check lists | Pixart StableDiffusionPlus |
saInferenceSteps | number | Specify the Style-Aware Inference Steps for refining or adjusting the generated image during style transfer or style-based image synthesis. | ๐งฎ Check lists | Pixart |
lcmInferenceSteps | number | Specify the LCM Inference Steps for enhancing the generation of images with AI by leveraging latent consistency models | ๐งฎ Check lists | PixartLCM |
useGpu | boolean | Determine whether to use the GPU for generation | None | Dalle2 |
promptImprovement | boolean | Determine whether the prompt should be enhanced using AI. | None | Dalle2 |
Provider | Models supported |
---|---|
Prodia | https://rentry.co/b6i53fnm |
ProdiaStableDiffusion | https://rentry.co/pfwmx6y5 |
ProdiaStableDiffusionXL | https://rentry.co/wfhsk8sv |
Provider | Image styles supported |
---|---|
Pixart | https://rentry.co/hcggg36n |
PixartLCM | https://rentry.co/gzxa3wv2 |
Provider | Sampling methods supported |
---|---|
Pixart | https://rentry.co/x7i8gko9 |
Prodia | https://rentry.co/8bwtqeh9 |
ProdiaStableDiffusion | https://rentry.co/iyrkxmzr |
ProdiaStableDiffusionXL | https://rentry.co/p2ad6y3f |
Provider | Number type options and values supported | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Pixart |
| ||||||||||||||||||||||||||||
PixartLCM |
| ||||||||||||||||||||||||||||
Prodia |
| ||||||||||||||||||||||||||||
ProdiaStableDiffusion |
| ||||||||||||||||||||||||||||
ProdiaStableDiffusionXL |
| ||||||||||||||||||||||||||||
StableDiffusionPlus |
|
Provider | Status | Default style |
---|---|---|
Pixart | Realistic with a touch of exaggeration, characterized by detailed textures, vibrant colors, and enhanced features. | |
PixartLCM | Exhibits a detailed and vibrant use of color, creating a visually rich and textured representation. Itโs a blend of realism with a touch of artistic interpretation. | |
Emi | Characterized by a colorful and whimsical animation, reminiscent of a childrenโs storybook illustration. | |
Dalle | Realistic, capturing intricate details and textures to depict a lifelike representation. | |
DalleMini | Leans towards the abstract, with a digital artistry touch that emphasizes detailed textures and vibrant colors. It captures the essence of the subject through the use of shape, color, and form rather than attempting to represent it accurately. | |
Dalle2 | Characterized by its semi-realism, with a focus on fine details, vivid colors, and natural lighting. | |
Prodia | Can be described as โphotorealisticโ. This term refers to artwork that is extremely detailed and lifelike, closely resembling a high-resolution photograph. | |
ProdiaStableDiffusion | Photorealistic, capturing intricate details and textures to mimic the appearance of a real-life scene. | |
ProdiaStableDiffusionXL | Semi-realistic, meticulously incorporating fine details and textures to emulate the semblance of a real-world scenario. | |
StableDiffusionLite | Can be described as folk art. It exhibits a naive perspective, lacks realistic proportions, and evokes simplicity. | |
StableDiffusionPlus | Impressionism, characterized by visible brushstrokes, open composition, emphasis on light in its changing qualities, and ordinary subject matter. |
It's important to review the possibilities that each provider offers within their limitations, in order to access more detailed creations. However, it's possible that at some point you might combine options that are not supported by the provider you're using at that moment. In such cases the image generation won't stop; instead (and as long as you're using the debug option), you'll receive a warning alerting you to the error.
FAQs
Free Chat GPT4 npm package, No API key or auth needed, All Models Included as well as Image Generators.
The npm package gifted-gpt receives a total of 124 weekly downloads. As such, gifted-gpt popularity was classified as not popular.
We found that gifted-gpt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.ย It has 0 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.