UNPKG

@aristech-org/nlp-client

Version:

A Node.js client library for the Aristech NLP Service

757 lines (756 loc) 30.1 kB
// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.11.8 // protoc v6.33.1 // source: nlp_server.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { makeGenericClientConstructor, } from "@grpc/grpc-js"; import { AddDocumentsRequest, AddDocumentsResponse, contentTypeFromJSON, contentTypeToJSON, GetDocumentsRequest, GetDocumentsResponse, GetDocumentStatusRequest, GetDocumentStatusResponse, ProcessDocumentsRequest, ProcessDocumentsResponse, RemoveDocumentsRequest, RemoveDocumentsResponse, UpdateDocumentsRequest, UpdateDocumentsResponse, } from "./documents.js"; import { GetContentRequest, GetContentResponse, GetIntentsRequest, GetKeywordsRequest, GetKeywordsResponse, GetScoreLimitsRequest, GetScoreLimitsResponse, Intent, RemoveContentRequest, RemoveContentResponse, UpdateContentRequest, UpdateContentResponse, } from "./intents.js"; import { AddProjectRequest, AddProjectResponse, EmbeddingModel, GetEmbeddingModelsRequest, GetProjectsRequest, Project, RemoveProjectRequest, RemoveProjectResponse, UpdateProjectRequest, UpdateProjectResponse, } from "./projects.js"; export const protobufPackage = "aristech.nlp"; function createBaseFunctionRequest() { return {}; } export const FunctionRequest = { encode(_, writer = new BinaryWriter()) { return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFunctionRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(_) { return {}; }, toJSON(_) { const obj = {}; return obj; }, create(base) { return FunctionRequest.fromPartial(base ?? {}); }, fromPartial(_) { const message = createBaseFunctionRequest(); return message; }, }; function createBaseFunctionMessage() { return { id: "", name: "", description: "", arguments: [], supportsAttachments: false, supportedContentTypes: [] }; } export const FunctionMessage = { encode(message, writer = new BinaryWriter()) { if (message.id !== "") { writer.uint32(10).string(message.id); } if (message.name !== "") { writer.uint32(18).string(message.name); } if (message.description !== "") { writer.uint32(26).string(message.description); } for (const v of message.arguments) { writer.uint32(34).string(v); } if (message.supportsAttachments !== false) { writer.uint32(40).bool(message.supportsAttachments); } writer.uint32(50).fork(); for (const v of message.supportedContentTypes) { writer.int32(v); } writer.join(); return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFunctionMessage(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.id = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.name = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.description = reader.string(); continue; } case 4: { if (tag !== 34) { break; } message.arguments.push(reader.string()); continue; } case 5: { if (tag !== 40) { break; } message.supportsAttachments = reader.bool(); continue; } case 6: { if (tag === 48) { message.supportedContentTypes.push(reader.int32()); continue; } if (tag === 50) { const end2 = reader.uint32() + reader.pos; while (reader.pos < end2) { message.supportedContentTypes.push(reader.int32()); } continue; } break; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { id: isSet(object.id) ? globalThis.String(object.id) : "", name: isSet(object.name) ? globalThis.String(object.name) : "", description: isSet(object.description) ? globalThis.String(object.description) : "", arguments: globalThis.Array.isArray(object?.arguments) ? object.arguments.map((e) => globalThis.String(e)) : [], supportsAttachments: isSet(object.supportsAttachments) ? globalThis.Boolean(object.supportsAttachments) : isSet(object.supports_attachments) ? globalThis.Boolean(object.supports_attachments) : false, supportedContentTypes: globalThis.Array.isArray(object?.supportedContentTypes) ? object.supportedContentTypes.map((e) => contentTypeFromJSON(e)) : globalThis.Array.isArray(object?.supported_content_types) ? object.supported_content_types.map((e) => contentTypeFromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.id !== "") { obj.id = message.id; } if (message.name !== "") { obj.name = message.name; } if (message.description !== "") { obj.description = message.description; } if (message.arguments?.length) { obj.arguments = message.arguments; } if (message.supportsAttachments !== false) { obj.supportsAttachments = message.supportsAttachments; } if (message.supportedContentTypes?.length) { obj.supportedContentTypes = message.supportedContentTypes.map((e) => contentTypeToJSON(e)); } return obj; }, create(base) { return FunctionMessage.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseFunctionMessage(); message.id = object.id ?? ""; message.name = object.name ?? ""; message.description = object.description ?? ""; message.arguments = object.arguments?.map((e) => e) || []; message.supportsAttachments = object.supportsAttachments ?? false; message.supportedContentTypes = object.supportedContentTypes?.map((e) => e) || []; return message; }, }; function createBaseRunFunctionsRequest() { return { functions: [], input: "", arguments: [], attachments: [] }; } export const RunFunctionsRequest = { encode(message, writer = new BinaryWriter()) { for (const v of message.functions) { FunctionMessage.encode(v, writer.uint32(10).fork()).join(); } if (message.input !== "") { writer.uint32(18).string(message.input); } for (const v of message.arguments) { writer.uint32(26).string(v); } for (const v of message.attachments) { Attachment.encode(v, writer.uint32(34).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseRunFunctionsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.functions.push(FunctionMessage.decode(reader, reader.uint32())); continue; } case 2: { if (tag !== 18) { break; } message.input = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.arguments.push(reader.string()); continue; } case 4: { if (tag !== 34) { break; } message.attachments.push(Attachment.decode(reader, reader.uint32())); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { functions: globalThis.Array.isArray(object?.functions) ? object.functions.map((e) => FunctionMessage.fromJSON(e)) : [], input: isSet(object.input) ? globalThis.String(object.input) : "", arguments: globalThis.Array.isArray(object?.arguments) ? object.arguments.map((e) => globalThis.String(e)) : [], attachments: globalThis.Array.isArray(object?.attachments) ? object.attachments.map((e) => Attachment.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.functions?.length) { obj.functions = message.functions.map((e) => FunctionMessage.toJSON(e)); } if (message.input !== "") { obj.input = message.input; } if (message.arguments?.length) { obj.arguments = message.arguments; } if (message.attachments?.length) { obj.attachments = message.attachments.map((e) => Attachment.toJSON(e)); } return obj; }, create(base) { return RunFunctionsRequest.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseRunFunctionsRequest(); message.functions = object.functions?.map((e) => FunctionMessage.fromPartial(e)) || []; message.input = object.input ?? ""; message.arguments = object.arguments?.map((e) => e) || []; message.attachments = object.attachments?.map((e) => Attachment.fromPartial(e)) || []; return message; }, }; function createBaseAttachment() { return { name: "", contentType: 0, data: new Uint8Array(0) }; } export const Attachment = { encode(message, writer = new BinaryWriter()) { if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.contentType !== 0) { writer.uint32(16).int32(message.contentType); } if (message.data.length !== 0) { writer.uint32(26).bytes(message.data); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseAttachment(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.name = reader.string(); continue; } case 2: { if (tag !== 16) { break; } message.contentType = reader.int32(); continue; } case 3: { if (tag !== 26) { break; } message.data = reader.bytes(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { name: isSet(object.name) ? globalThis.String(object.name) : "", contentType: isSet(object.contentType) ? contentTypeFromJSON(object.contentType) : isSet(object.content_type) ? contentTypeFromJSON(object.content_type) : 0, data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), }; }, toJSON(message) { const obj = {}; if (message.name !== "") { obj.name = message.name; } if (message.contentType !== 0) { obj.contentType = contentTypeToJSON(message.contentType); } if (message.data.length !== 0) { obj.data = base64FromBytes(message.data); } return obj; }, create(base) { return Attachment.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseAttachment(); message.name = object.name ?? ""; message.contentType = object.contentType ?? 0; message.data = object.data ?? new Uint8Array(0); return message; }, }; function createBaseRunFunctionsResponse() { return { output: "" }; } export const RunFunctionsResponse = { encode(message, writer = new BinaryWriter()) { if (message.output !== "") { writer.uint32(10).string(message.output); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseRunFunctionsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.output = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { output: isSet(object.output) ? globalThis.String(object.output) : "" }; }, toJSON(message) { const obj = {}; if (message.output !== "") { obj.output = message.output; } return obj; }, create(base) { return RunFunctionsResponse.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseRunFunctionsResponse(); message.output = object.output ?? ""; return message; }, }; function createBaseSyncDBsRequest() { return {}; } export const SyncDBsRequest = { encode(_, writer = new BinaryWriter()) { return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSyncDBsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(_) { return {}; }, toJSON(_) { const obj = {}; return obj; }, create(base) { return SyncDBsRequest.fromPartial(base ?? {}); }, fromPartial(_) { const message = createBaseSyncDBsRequest(); return message; }, }; function createBaseSyncDBsResponse() { return { status: "" }; } export const SyncDBsResponse = { encode(message, writer = new BinaryWriter()) { if (message.status !== "") { writer.uint32(10).string(message.status); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSyncDBsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.status = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { status: isSet(object.status) ? globalThis.String(object.status) : "" }; }, toJSON(message) { const obj = {}; if (message.status !== "") { obj.status = message.status; } return obj; }, create(base) { return SyncDBsResponse.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseSyncDBsResponse(); message.status = object.status ?? ""; return message; }, }; export const NLPServerService = { /** * Returns all available processing functions (models) of the server. * Each function includes a unique ID, a descriptive name, * a description, and a list of possible arguments. */ getFunctions: { path: "/aristech.nlp.NLPServer/GetFunctions", requestStream: false, responseStream: true, requestSerialize: (value) => Buffer.from(FunctionRequest.encode(value).finish()), requestDeserialize: (value) => FunctionRequest.decode(value), responseSerialize: (value) => Buffer.from(FunctionMessage.encode(value).finish()), responseDeserialize: (value) => FunctionMessage.decode(value), }, /** * Processes the provided raw text using the specified functions. * Multiple functions can be applied sequentially. */ runFunctions: { path: "/aristech.nlp.NLPServer/RunFunctions", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(RunFunctionsRequest.encode(value).finish()), requestDeserialize: (value) => RunFunctionsRequest.decode(value), responseSerialize: (value) => Buffer.from(RunFunctionsResponse.encode(value).finish()), responseDeserialize: (value) => RunFunctionsResponse.decode(value), }, /** Adds new content or updates existing content. */ updateContent: { path: "/aristech.nlp.NLPServer/UpdateContent", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(UpdateContentRequest.encode(value).finish()), requestDeserialize: (value) => UpdateContentRequest.decode(value), responseSerialize: (value) => Buffer.from(UpdateContentResponse.encode(value).finish()), responseDeserialize: (value) => UpdateContentResponse.decode(value), }, /** Removes the specified content. */ removeContent: { path: "/aristech.nlp.NLPServer/RemoveContent", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(RemoveContentRequest.encode(value).finish()), requestDeserialize: (value) => RemoveContentRequest.decode(value), responseSerialize: (value) => Buffer.from(RemoveContentResponse.encode(value).finish()), responseDeserialize: (value) => RemoveContentResponse.decode(value), }, /** Retrieves content that is available both as vectorized data and as plain text. */ getContent: { path: "/aristech.nlp.NLPServer/GetContent", requestStream: false, responseStream: true, requestSerialize: (value) => Buffer.from(GetContentRequest.encode(value).finish()), requestDeserialize: (value) => GetContentRequest.decode(value), responseSerialize: (value) => Buffer.from(GetContentResponse.encode(value).finish()), responseDeserialize: (value) => GetContentResponse.decode(value), }, /** Initializes a new project. */ addProject: { path: "/aristech.nlp.NLPServer/AddProject", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(AddProjectRequest.encode(value).finish()), requestDeserialize: (value) => AddProjectRequest.decode(value), responseSerialize: (value) => Buffer.from(AddProjectResponse.encode(value).finish()), responseDeserialize: (value) => AddProjectResponse.decode(value), }, /** Removes an existing project and all associated content. */ removeProject: { path: "/aristech.nlp.NLPServer/RemoveProject", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(RemoveProjectRequest.encode(value).finish()), requestDeserialize: (value) => RemoveProjectRequest.decode(value), responseSerialize: (value) => Buffer.from(RemoveProjectResponse.encode(value).finish()), responseDeserialize: (value) => RemoveProjectResponse.decode(value), }, /** Updates the settings or configuration of an existing project. */ updateProject: { path: "/aristech.nlp.NLPServer/UpdateProject", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(UpdateProjectRequest.encode(value).finish()), requestDeserialize: (value) => UpdateProjectRequest.decode(value), responseSerialize: (value) => Buffer.from(UpdateProjectResponse.encode(value).finish()), responseDeserialize: (value) => UpdateProjectResponse.decode(value), }, /** Returns a list of all projects. */ getProjects: { path: "/aristech.nlp.NLPServer/GetProjects", requestStream: false, responseStream: true, requestSerialize: (value) => Buffer.from(GetProjectsRequest.encode(value).finish()), requestDeserialize: (value) => GetProjectsRequest.decode(value), responseSerialize: (value) => Buffer.from(Project.encode(value).finish()), responseDeserialize: (value) => Project.decode(value), }, /** Retrieves all intents of a project. */ getIntents: { path: "/aristech.nlp.NLPServer/GetIntents", requestStream: false, responseStream: true, requestSerialize: (value) => Buffer.from(GetIntentsRequest.encode(value).finish()), requestDeserialize: (value) => GetIntentsRequest.decode(value), responseSerialize: (value) => Buffer.from(Intent.encode(value).finish()), responseDeserialize: (value) => Intent.decode(value), }, /** Determines score limits for a project based on test inputs. */ getScoreLimits: { path: "/aristech.nlp.NLPServer/GetScoreLimits", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(GetScoreLimitsRequest.encode(value).finish()), requestDeserialize: (value) => GetScoreLimitsRequest.decode(value), responseSerialize: (value) => Buffer.from(GetScoreLimitsResponse.encode(value).finish()), responseDeserialize: (value) => GetScoreLimitsResponse.decode(value), }, /** Returns a list of available embedding models for similarity searches. */ getEmbeddingModels: { path: "/aristech.nlp.NLPServer/GetEmbeddingModels", requestStream: false, responseStream: true, requestSerialize: (value) => Buffer.from(GetEmbeddingModelsRequest.encode(value).finish()), requestDeserialize: (value) => GetEmbeddingModelsRequest.decode(value), responseSerialize: (value) => Buffer.from(EmbeddingModel.encode(value).finish()), responseDeserialize: (value) => EmbeddingModel.decode(value), }, syncDBs: { path: "/aristech.nlp.NLPServer/SyncDBs", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(SyncDBsRequest.encode(value).finish()), requestDeserialize: (value) => SyncDBsRequest.decode(value), responseSerialize: (value) => Buffer.from(SyncDBsResponse.encode(value).finish()), responseDeserialize: (value) => SyncDBsResponse.decode(value), }, getKeywords: { path: "/aristech.nlp.NLPServer/GetKeywords", requestStream: false, responseStream: true, requestSerialize: (value) => Buffer.from(GetKeywordsRequest.encode(value).finish()), requestDeserialize: (value) => GetKeywordsRequest.decode(value), responseSerialize: (value) => Buffer.from(GetKeywordsResponse.encode(value).finish()), responseDeserialize: (value) => GetKeywordsResponse.decode(value), }, addDocuments: { path: "/aristech.nlp.NLPServer/AddDocuments", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(AddDocumentsRequest.encode(value).finish()), requestDeserialize: (value) => AddDocumentsRequest.decode(value), responseSerialize: (value) => Buffer.from(AddDocumentsResponse.encode(value).finish()), responseDeserialize: (value) => AddDocumentsResponse.decode(value), }, getDocuments: { path: "/aristech.nlp.NLPServer/GetDocuments", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(GetDocumentsRequest.encode(value).finish()), requestDeserialize: (value) => GetDocumentsRequest.decode(value), responseSerialize: (value) => Buffer.from(GetDocumentsResponse.encode(value).finish()), responseDeserialize: (value) => GetDocumentsResponse.decode(value), }, processDocuments: { path: "/aristech.nlp.NLPServer/ProcessDocuments", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(ProcessDocumentsRequest.encode(value).finish()), requestDeserialize: (value) => ProcessDocumentsRequest.decode(value), responseSerialize: (value) => Buffer.from(ProcessDocumentsResponse.encode(value).finish()), responseDeserialize: (value) => ProcessDocumentsResponse.decode(value), }, updateDocuments: { path: "/aristech.nlp.NLPServer/UpdateDocuments", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(UpdateDocumentsRequest.encode(value).finish()), requestDeserialize: (value) => UpdateDocumentsRequest.decode(value), responseSerialize: (value) => Buffer.from(UpdateDocumentsResponse.encode(value).finish()), responseDeserialize: (value) => UpdateDocumentsResponse.decode(value), }, removeDocuments: { path: "/aristech.nlp.NLPServer/RemoveDocuments", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(RemoveDocumentsRequest.encode(value).finish()), requestDeserialize: (value) => RemoveDocumentsRequest.decode(value), responseSerialize: (value) => Buffer.from(RemoveDocumentsResponse.encode(value).finish()), responseDeserialize: (value) => RemoveDocumentsResponse.decode(value), }, getDocumentStatus: { path: "/aristech.nlp.NLPServer/GetDocumentStatus", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(GetDocumentStatusRequest.encode(value).finish()), requestDeserialize: (value) => GetDocumentStatusRequest.decode(value), responseSerialize: (value) => Buffer.from(GetDocumentStatusResponse.encode(value).finish()), responseDeserialize: (value) => GetDocumentStatusResponse.decode(value), }, }; export const NLPServerClient = makeGenericClientConstructor(NLPServerService, "aristech.nlp.NLPServer"); function bytesFromBase64(b64) { if (globalThis.Buffer) { return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); } return arr; } } function base64FromBytes(arr) { if (globalThis.Buffer) { return globalThis.Buffer.from(arr).toString("base64"); } else { const bin = []; arr.forEach((byte) => { bin.push(globalThis.String.fromCharCode(byte)); }); return globalThis.btoa(bin.join("")); } } function isSet(value) { return value !== null && value !== undefined; }