Socket
Socket
Sign inDemoInstall

qb-ai-answer-assistant

Package Overview
Dependencies
8
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

dist/browser.js

59

dist/index.d.ts

@@ -1,4 +0,55 @@

import QBAIAnswerAssistant from './QBAIAnswerAssistant';
import AIAnswerAssistantSettings from './AIAnswerAssistantSettings';
import AIAnswerAssistantException from './AIAnswerAssistantException';
export { QBAIAnswerAssistant, type AIAnswerAssistantSettings, type AIAnswerAssistantException };
import { Settings, AIModel, ChatMessage, AIException } from 'qb-ai-core';
interface IAISettings extends Settings {
}
declare class AIAnswerAssistantSettings implements IAISettings {
constructor(apiKey: string, apiVersion: string, maxRequestTokens: number, maxResponseTokens: number | undefined, model: AIModel, organization: string | undefined, serverPath: string, temperature: number, token: string);
get apiKey(): string;
set apiKey(value: string);
get apiVersion(): string;
set apiVersion(value: string);
get maxRequestTokens(): number;
set maxRequestTokens(value: number);
get maxResponseTokens(): number | undefined;
set maxResponseTokens(value: number | undefined);
get model(): AIModel;
set model(value: AIModel);
get organization(): string | undefined;
set organization(value: string | undefined);
get serverPath(): string;
set serverPath(value: string);
get temperature(): number;
set temperature(value: number);
get token(): string;
set token(value: string);
private _apiKey;
private _apiVersion;
private _maxRequestTokens;
private _maxResponseTokens;
private _model;
private _organization;
private _serverPath;
private _temperature;
private _token;
}
declare class QBAIAnswerAssistant {
static createAnswer(text: string, messages: ChatMessage[], settings: AIAnswerAssistantSettings): Promise<string>;
private static createAnswerAssistPrompt;
static createDefaultAIAnswerAssistantSettings(): AIAnswerAssistantSettings;
private static updateChatRoles;
private static getData;
private static getDataWithProxyServer;
private static stringifyError;
private static parseErrorMessage;
private static jsonParse;
private static parseErrorObject;
}
declare class AIAnswerAssistantException extends AIException {
message: string;
constructor(message: string, code: number);
}
export { AIAnswerAssistantException, AIAnswerAssistantSettings, QBAIAnswerAssistant };

10

dist/index.js

@@ -1,8 +0,2 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.QBAIAnswerAssistant = void 0;
var QBAIAnswerAssistant_1 = __importDefault(require("./QBAIAnswerAssistant"));
exports.QBAIAnswerAssistant = QBAIAnswerAssistant_1.default;
"use strict";var a=require("qb-ai-core");class E{constructor(e,t,r,n,u,p,g,c,h){this._apiKey=e,this._apiVersion=t,this._maxRequestTokens=r,this._maxResponseTokens=n,this._model=u,this._organization=p,this._serverPath=g,this._temperature=c,this._token=h}get apiKey(){return this._apiKey}set apiKey(e){this._apiKey=e}get apiVersion(){return this._apiVersion}set apiVersion(e){this._apiVersion=e}get maxRequestTokens(){return this._maxRequestTokens}set maxRequestTokens(e){this._maxRequestTokens=e}get maxResponseTokens(){return this._maxResponseTokens}set maxResponseTokens(e){this._maxResponseTokens=e}get model(){return this._model}set model(e){this._model=e}get organization(){return this._organization}set organization(e){this._organization=e}get serverPath(){return this._serverPath}set serverPath(e){this._serverPath=e}get temperature(){return this._temperature}set temperature(e){this._temperature=e}get token(){return this._token}set token(e){this._token=e}}const T="Undefined settings",f=121;class d extends a.AIException{constructor(e,t){super(e,t),this.message=e}}const i=class o{static async createAnswer(e,t,r){const n=o.createAnswerAssistPrompt(e);if(r.apiKey)return o.getData(n,t,r.serverPath,r.apiKey,a.AIModel.gpt__3_5__turbo,r.temperature,r.organization);if(r.serverPath)return o.getDataWithProxyServer(n,t,r.serverPath,r.token,a.AIModel.gpt__3_5__turbo,r.temperature,r.organization);throw new d(T,f)}static createAnswerAssistPrompt(e){return`You are a customer support chat operator. Your goal is to provide helpful and informative responses to customer inquiries. Give a response to the next user\u2019s query, considering the entire conversation context, and use grammar and vocabulary at the A2-B2 level. Answer in the format of simple sentences. Do not include question in answer. Translate your response into the same language as the my issue. Please, provide answer for this issue:'${e}'.`}static createDefaultAIAnswerAssistantSettings(){return new E("",a.ApiVersion.v1,3584,3584,a.AIModel.gpt__3_5__turbo,"","https://api.openai.com/v1/chat/completions",.5,"")}static updateChatRoles(e){return e.map(t=>{let r="user";return t.role==="system"?r="system":r=t.role===a.Role.other?"assistant":"user",{role:r,content:t.content}})}static async getData(e,t,r,n,u="gpt-3.5-turbo",p=.5,g=""){const c=`${r}`,h=n,_=u,m=[...t,{role:"user",content:e}],l=this.updateChatRoles(m);try{return await a.QBAICore.sendPromptToOpenai(h,l,_,p,g,c)}catch(y){const A=o.stringifyError(y);throw new d(A,-1)}}static async getDataWithProxyServer(e,t,r,n,u="gpt-3.5-turbo",p=.5,g=""){const c=`${r}`,h=n,_=u,m=[...t,{role:"user",content:e}],l=this.updateChatRoles(m);try{return await a.QBAICore.sendPromptToProxy(h,l,_,p,c)}catch(y){const A=o.stringifyError(y);throw new d(A,-1)}}static stringifyError(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;return t.detail?o.parseErrorMessage(t.detail):t?.message?o.parseErrorMessage(t.message):o.parseErrorObject(t)}return JSON.stringify(e)}};i.parseErrorMessage=s=>{const e=i.jsonParse(s);return typeof e=="string"?e:Array.isArray(e)?e.join(""):typeof e=="object"?i.parseErrorObject(e):e},i.jsonParse=s=>{try{return JSON.parse(s)}catch{return s}},i.parseErrorObject=s=>Object.keys(s).map(e=>{const t=s[e];return Array.isArray(t)?`${e} ${t.join("")}`:`${e} ${t}`}).join(" ").replace(/errors\s?/,"");let v=i;exports.QBAIAnswerAssistant=v;
//# sourceMappingURL=index.js.map
{
"name": "qb-ai-answer-assistant",
"version": "0.1.1",
"version": "0.1.2",
"description": "Quickblox AI Answer assistant library",
"main": "dist/index.js",
"module": "dist/index.mjs",
"browser": "dist/browser.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"qb-ai-core": "^0.1.1"
"qb-ai-core": "^0.1.3"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@testing-library/jest-dom": "^5.16.5",

@@ -30,10 +36,9 @@ "@testing-library/user-event": "^13.5.0",

"prettier": "^2.8.0",
"ts-loader": "^9.4.2",
"typedoc": "^0.23.22",
"typescript": "^4.9.3",
"webpack": "^5.82.1",
"webpack-cli": "^5.1.1"
"rollup": "^4.6.0",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.0",
"typescript": "^4.9.3"
},
"scripts": {
"build": "tsc",
"build": "rollup -c",
"lint": "eslint ./src"

@@ -40,0 +45,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc