Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@or-sdk/qna
Advanced tools
The `@or-sdk/qna` package provides a client for working with the QnA (Question and Answer) system in OneReach.ai. With this client, you can perform operations such as loading documents, creating collections, searching in collections, and asking questions
The @or-sdk/qna
package provides a client for working with the QnA (Question and Answer) system in OneReach.ai. With this client, you can perform operations such as loading documents, creating collections, searching in collections, and asking questions to generate answers based on the loaded documents.
To install the package, run the following command:
$ npm install @or-sdk/qna
To use the QnA
client, you need to create an instance of the class with the appropriate configuration options. You can either provide the direct API URL or the service discovery URL. Here is an example:
import { QnA } from '@or-sdk/qna';
// with direct api url
const qna = new QnA({
token: 'my-account-token-string',
serviceUrl: 'http://example.qna/endpoint'
});
// with service discovery(slower)
const qna = new QnA({
token: 'my-account-token-string',
discoveryUrl: 'http://example.qna/endpoint'
});
Once you have an instance of the QnA
client, you can use its methods to interact with the OneReach.ai QnA system. The available methods are:
loadDocument
Load a document into a collection.
[0]: string
- Collection name.[1]: string
- Document name.[2]: CreateDocument
- Document creation parameters.await qna.loadDocument('myCollection', 'myDocument', {
url: 'https://example.com/document.pdf'
});
removeDocument
Remove a document from a collection.
[0]: string
- Collection name.[1]: string
- Document name.await qna.removeDocument('myCollection', 'myDocument');
createCollection
Create a new collection.
[0]: CreateCollection
- Collection creation parameters.await qna.createCollection({ collection: 'myCollection' });
deleteCollection
Delete a collection.
[0]: string
- Collection name.await qna.deleteCollection('myCollection');
search
Search in the collection.
[0]: string
- Collection name.[1]: Search
- Search parameters.[2]?: number
- Optional limit of search results (defaults to 5).const searchResults = await qna.search('myCollection', { term: 'coffee' });
console.log(searchResults.documents);
ask
Answer a question.
[0]: string
- Collection name.[1]: Ask
- Ask question parameters.[2]?: number
- Optional limit of search results (defaults to 5).const askResults = await qna.ask('myCollection', {
question: 'What are the health benefits of coffee?',
messages: [
{ role: 'user', content: 'Tell me about coffee' },
{ role: 'assistant', content: 'Coffee is a popular beverage...' }
]
});
console.log(askResults.result.content);
FAQs
The `@or-sdk/qna` package provides a client for working with the QnA (Question and Answer) system in OneReach.ai a.k.a Lookup. With this client, you can perform operations such as loading documents, creating collections, searching in collections, asking q
The npm package @or-sdk/qna receives a total of 379 weekly downloads. As such, @or-sdk/qna popularity was classified as not popular.
We found that @or-sdk/qna demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.