Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
oneai-stage
Advanced tools
NLP-as-a-service
OneAI is a NLP as a service platform. Our API enables language comprehension in context, transforming texts from any source into structured data to use in code.
This SDK provides safe and convenient access to OneAI's API from a node.js environment.
See the One AI documentation
npm install oneai
You will need a valid API key for all requests. Register and create a key for your project in OneAI Studio. As a security measure we only show the key once, so make sure to keep it somewhere safe.
import oneai from 'oneai';
oneai.api_key = '<YOUR-API-KEY>';
const pipeline = new oneai.Pipeline(
oneai.skills.names(),
oneai.skills.summarize({ min_length: 20 }),
oneai.skills.highlights()
);
const output = await pipeline.run('analyze this text');
console.log(output);
The pipeline API enables analyzing and transforming text using various skills. A skill is a package of trained NLP models, available via API, which accept text from various language sources as input and respond with processed texts and extracted metadata. Chaining skills together creates a pipeline.
The best way to create a pipeline is to use our studio where you can craft a pipeline using an easy graphical interface and then paste the generated code back into your repository.
Let's say you're interested in extracting keywords from the text.
const pipeline = new oneai.Pipeline(
oneai.skills.keywords(),
);
const output = await pipeline.run('analyze this text');
console.log(output);
Let's say you're interested in extracting keywords and emotions from the text.
const pipeline = new oneai.Pipeline(
oneai.skills.keywords(),
oneai.skills.emotions(),
);
const output = await pipeline.run('analyze this text');
console.log(output);
Skills can do either text analysis, and then their output are labels and spans (labels location in the analyzed text), or they can be generator skills, in which case they transform the input text into an output text.
Here's an example for a pipeline that combines both type of skills. It will extract keywords and emotions from the text, and then summarize it.
const pipeline = new oneai.Pipeline(
oneai.skills.keywords(),
oneai.skills.emotions(),
oneai.skills.summarize(),
);
const output = await pipeline.run('analyze this text');
console.log(output);
When the pipeline is invoked, it is invoked with an original text you submit. If a generator skill is ran, then all following skills will use its generated text rather then the original text. In this example, for instance, we change the order of the pipeline from the previous example, and the results will be different. Instead of extracting keywords and emotions from the original text, keywords and emotions will be extracted from the generated summary.
const pipeline = new oneai.Pipeline(
oneai.skills.summarize(),
oneai.skills.keywords(),
oneai.skills.emotions(),
);
const output = await pipeline.run('analyze this text');
console.log(output);
Many skills are configurable as you can find out in the docs. Let's use the exact same example, this time however, we'll limit the summary length to 50 words.
const pipeline = new oneai.Pipeline(
oneai.skills.summarize({max_length: 50}),
oneai.skills.keywords(),
oneai.skills.emotions(),
);
const output = await pipeline.run('analyze this text');
console.log(output);
The structure of the output is dynamic, and corresponds to the Skills used, whether they are generators or analyzers, and their order in the pipeline. Each output object contains the input text (which can be the original input or text produced by generator Skills), and a list of labels detected by analyzer Skills, that contain the extracted data.
Let's say we run this code
const text = "The Hitchhiker's Guide to the Galaxy is a science fiction comedy radio series written by Douglas Adams ";
const pipeline = new oneai.Pipeline(
oneai.skills.names(),
oneai.skills.summarize({ min_length: 20 }),
oneai.skills.names(),
);
const output = await pipeline.run(text);
console.log(output);
In plain English, we extract names from the text, then summarize it, and then extract names from the summary. Here's what the reponse would look like (the important thing to notice, whenever a generator skill runs, summarize
in this case, all following skills responses will be embedded within the generator result as it changes the text the skill processes:
{
"text":"The Hitchhiker's Guide to the Galaxy is a science fiction comedy radio series written by Douglas Adams ",
"names":[ // This array will contain the names detected in the original text
{
"type":"name", // label type
"name":"WORK_OF_ART", // label class
"value":"The Hitchhiker's Guide to the Galaxy", // label value
"output_spans":[ // label spans (where the name was detected in the text)
{
"section":0,
"start":0,
"end":36
}
],
},
...
],
"summary":{
// this actual summary
"text":"The Hitchhiker's Guide to the Galaxy is a science fiction comedy",
// the names detected in the summary
"names":[
{
"type":"name",
"name":"WORK_OF_ART",
"value":"The Hitchhiker's Guide to the Galaxy",
"output_spans":[
{
"section":0,
"start":0,
"end":36
}
],
},
...
]
}
}
Our API supports the following file extensions:
.txt
- text content.json
- conversations in the One AI conversation format.srt
- analyze captions as conversations.wav
- audio files to be transcribed & analyzed.jpg
- detect text in pictures via OCR
Upload a file via the oneai.File
class, i.econst input = new oneai.File('./example.txt');
const pipeline = new oneai.Pipeline(...);
const output = await pipeline.run(input);
Feel free to submit issues in this repo, contact us at devrel@oneai.com, or chat with us on Discord
FAQs
NLP-as-a-service
We found that oneai-stage 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
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.