Class: LetsDiscussService

LetsDiscussService()

The Let's Discuss module allows the user to have a conversation with the AI about the content provided by the user. The main difference between this module and the Question Answering module is that Let's Discuss keeps a history of the interactions. LetsDiscuss main service, continues thread of conversation.

Constructor

new LetsDiscussService()

Source:

Methods

call(user, session_id, query, engineopt) → {Promise.<Object>}

Parameters:
Name Type Attributes Default Description
user string The ID of the user accessing the Soffos API. Soffos assumes that the owner of the api is an application (app) and that app has users. Soffos API will accept any string.
session_id string The ID of the session provided by the /create/ endpoint.
query string User's message.
engine string <optional>
null The LLM engine to be used.
Source:
Returns:
response - string
Module's response to the user's query.
context - string
The context discussed about provided by the user during session creation.
messages - dictionary list
A list of dictionaries representing all the messages exchanged between the user and the system for the specific session. The messages are sorted in chronological order.
Each dictionary contains the following fields: text: The message. source: The source of the message, which is either the user or Soffos.
Type
Promise.<Object>
Example
import { SoffosServices } from "soffosai";

const my_apiKey = "Token <put your api key here>";
const service = new SoffosServices.LetsDiscussService({apiKey:my_apiKey});
let response = await service.call(
    "me again",
    "b658686f8b834b3f86d5218a4549e1c4",
    "What is the purpose of observing this?"
);
console.log(JSON.stringify(response, null, 2));

// returns
// {
//     "response": "The James Webb Space Telescope will allow scientists to look at what our universe was like about 200 million years after the Big Bang. It will also be able to observe objects in our solar system from Mars outward, look inside dust 
//   clouds to see where new stars and planets are forming and examine the atmospheres of planets orbiting other stars.",       
//     "context": "The James Webb Space Telescope is the largest, most powerful space telescope ever built.     It will allow scientists to look at what our universe was like about 200 million years     after the Big Bang. The telescope will be able to capture images of some of the first     galaxies ever formed. It will also be able to observe objects in our solar system from     Mars outward, look inside dust clouds to see where new stars and planets are forming     and examine the atmospheres of planets orbiting other stars.",
//     "messages": [
//       {
//         "text": "Where can I see the photos taken by this telescope?",
//         "source": "user"
//       },
//       {
//         "text": "The photos taken by the James Webb Space Telescope will be available to the public on the official website of the telescope.",
//         "source": "soffos"
//       },
//       {
//         "text": "What is the purpose of observing this?",
//         "source": "user"
//       },
//       {
//         "text": "The James Webb Space Telescope will allow scientists to look at what our universe was like about 200 million years after the Big Bang. It will also be able to observe objects in our solar system from Mars outward, look inside dust 
//   clouds to see where new stars and planets are forming and examine the atmospheres of planets orbiting other stars.",       
//         "source": "soffos"
//       }
//     ],
//     "cost": {
//       "api_call_cost": 0.005,
//       "character_volume_cost": 0.07085,
//       "total_cost": 0.07585
//     },
//     "charged_character_count": 1417,
//     "unit_price": "0.000050"
// }

setInputConfigs(name, session_id, query, engineopt) → {Promise.<Object>}

Parameters:
Name Type Attributes Default Description
name string Reference name of this Service. It will be used by the Pipeline to reference this Service.
session_id string | InputConfig The ID of the session provided by the /create/ endpoint.
query string | InputConfig User's message.
engine string <optional>
null The LLM engine to be used.
Source:
Returns:
Type
Promise.<Object>