Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@or-sdk/qna

Package Overview
Dependencies
Maintainers
2
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@or-sdk/qna

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

  • 0.0.2-beta.1206.0
  • npm
  • Socket score

Version published
Weekly downloads
381
decreased by-28.92%
Maintainers
2
Weekly downloads
 
Created
Source

QnA SDK

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.

Installation

To install the package, run the following command:

$ npm install @or-sdk/qna

Usage

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.

Params
  • [0]: string - Collection name.
  • [1]: string - Document name.
  • [2]: CreateDocument - Document creation parameters.
Example
await qna.loadDocument('myCollection', 'myDocument', {
  url: 'https://example.com/document.pdf'
});

removeDocument

Remove a document from a collection.

Params
  • [0]: string - Collection name.
  • [1]: string - Document name.
Example
await qna.removeDocument('myCollection', 'myDocument');

createCollection

Create a new collection.

Params
  • [0]: CreateCollection - Collection creation parameters.
Example
await qna.createCollection({ collection: 'myCollection' });

deleteCollection

Delete a collection.

Params
  • [0]: string - Collection name.
Example
await qna.deleteCollection('myCollection');

Search in the collection.

Params
  • [0]: string - Collection name.
  • [1]: Search - Search parameters.
  • [2]?: number - Optional limit of search results (defaults to 5).
Example
const searchResults = await qna.search('myCollection', { term: 'coffee' });
console.log(searchResults.documents);

ask

Answer a question.

Params
  • [0]: string - Collection name.
  • [1]: Ask - Ask question parameters.
  • [2]?: number - Optional limit of search results (defaults to 5).
Example
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

Package last updated on 24 Apr 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc