
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@dasheck0/openai-api
Advanced tools
🚨 This is a fork of the original project located at https://github.com/Njerschow/openai-api. I contributed to this project. However, it seems that the original maintainer is unresponsive. So I decided to re-release this package with an apropriate scope. Thanks https://github.com/Njerschow for your work so far! 🚨
This package is a tiny node wrapper for the openAI API, if you find any issue please feel free to message me or open a PR :).
If you have any ideas on how to improve the library feel free to let me know as well!
You can also visit the Issue tracker for more information or open a new issue.
This project is not affiliated with OpenAI and was written purely out of interest.
npm i openai-api
const OpenAI = require('openai-api');
// Load your key from an environment variable or secret management service
// (do not include your key directly in your code)
const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const openai = new OpenAI(OPENAI_API_KEY);
(async () => {
const gptResponse = await openai.complete({
engine: 'davinci',
prompt: 'this is a test',
maxTokens: 5,
temperature: 0.9,
topP: 1,
presencePenalty: 0,
frequencyPenalty: 0,
bestOf: 1,
n: 1,
stream: false,
stop: ['\n', "testing"]
});
console.log(gptResponse.data);
})();
{
id: 'some-long-id',
object: 'text_completion',
created: 1616791508,
model: 'davinci:2020-05-03',
choices: [
{
text: " predicted text...",
index: 0,
logprobs: null,
finish_reason: 'length'
}
]
}
(async () => {
const gptResponse = await openai.search({
engine: 'davinci',
documents: ["White House", "hospital", "school"],
query: "the president"
});
console.log(gptResponse.data);
})();
(async () => {
const gptResponse = await openai.answers({
"documents": ["Puppy A is happy.", "Puppy B is sad."],
"question": "which puppy is happy?",
"search_model": "ada",
"model": "curie",
"examples_context": "In 2017, U.S. life expectancy was 78.6 years.",
"examples": [["What is human life expectancy in the United States?", "78 years."]],
"max_tokens": 5,
"stop": ["\n", "<|endoftext|>"],
});
console.log(gptResponse.data);
})();
(async () => {
const gptResponse = await openai.classification({
"examples": [
["A happy moment", "Positive"],
["I am sad.", "Negative"],
["I am feeling awesome", "Positive"]
],
"labels": ["Positive", "Negative", "Neutral"],
"query": "It is a raining day :(",
"search_model": "ada",
"model": "curie"
});
console.log(gptResponse.data);
})();
(async () => {
const gptResponse = await openai.engines();
console.log(gptResponse.data);
})();
Documentation: https://beta.openai.com/docs/api-reference/embeddings
(async () => {
const gptResponse = await openai.embeddings({
"engine": "test-similarity-babbage-001",
"input": [
"A happy moment",
"I am sad.",
"I am feeling awesome"
],
});
console.log(gptResponse.data); // see index.d.ts interface Embedding
})();
The token limit is 2048 for completions using the OpenAI API. This method allows you to get the number of tokens in your prompt. This is done offline (no API call is made).
openai.encode('This is an encoding test. Number of tokens is not necessarily the same as word count.').then((result) => {
console.log("Number of tokens for string:" + result.length);
});
Powered by Obelisk.ooo
FAQs
A tiny client module for the openAI API
The npm package @dasheck0/openai-api receives a total of 0 weekly downloads. As such, @dasheck0/openai-api popularity was classified as not popular.
We found that @dasheck0/openai-api 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.