UNPKG

@aristech-org/nlp-client

Version:

A Node.js client library for the Aristech NLP Service

174 lines (173 loc) 8.01 kB
import * as grpc from '@grpc/grpc-js'; import { type DeepPartial, type FunctionMessage, FunctionRequest, RunFunctionsRequest, type RunFunctionsResponse, SyncDBsRequest, SyncDBsResponse } from './generated/nlp_server.js'; import { GetContentRequest, type GetContentResponse, GetIntentsRequest, GetKeywordsRequest, GetKeywordsResponse, GetScoreLimitsRequest, GetScoreLimitsResponse, Intent, RemoveContentRequest, type RemoveContentResponse, UpdateContentRequest, type UpdateContentResponse } from './generated/intents.js'; import { AddProjectRequest, type AddProjectResponse, EmbeddingModel, GetEmbeddingModelsRequest, GetProjectsRequest, type Project, RemoveProjectRequest, RemoveProjectResponse, UpdateProjectRequest, UpdateProjectResponse } from './generated/projects.js'; import { AddDocumentsRequest, type AddDocumentsResponse, GetDocumentsRequest, type GetDocumentsResponse, GetDocumentStatusRequest, type GetDocumentStatusResponse, ProcessDocumentsRequest, type ProcessDocumentsResponse, RemoveDocumentsRequest, type RemoveDocumentsResponse, UpdateDocumentsRequest, type UpdateDocumentsResponse } from './generated/documents.js'; export * as NlpServer from './generated/nlp_server.js'; export * as Projects from './generated/projects.js'; export * as Intents from './generated/intents.js'; export interface ConnectionOptions { /** * The Aristech NLP-Server uri e.g. nlp.example.com */ host?: string; /** * Whether to use SSL/TLS. Automatically enabled when rootCert is provided */ ssl?: boolean; /** * Allows providing a custom root certificate that might not exist * in the root certificate chain */ rootCert?: string; /** * Optionally instead of providing a root cert path via `rootCert` the root cert content can be provided directly */ rootCertContent?: string; /** * Further grpc client options */ grpcClientOptions?: grpc.ClientOptions; /** * Authentication options. * **Note:** Can only be used in combination with SSL/TLS. */ auth?: { token: string; secret: string; }; } export declare class NlpClient { private cOptions; constructor(options: ConnectionOptions); /** * List all available functions on the server * @param request An optional request object * @returns A promise that resolves with an array of function messages */ listFunctions(request?: DeepPartial<FunctionRequest>): Promise<Array<FunctionMessage>>; /** * Performs a processing request with the given request * @param request The request object * @returns A promise that resolves with the response object */ runFunctions(request: DeepPartial<RunFunctionsRequest>): Promise<RunFunctionsResponse>; /** * Performs a processing request with the given request * @deprecated Use `runFunctions` instead * @param request The request object * @returns A promise that resolves with the response object */ process(request: DeepPartial<RunFunctionsRequest>): Promise<RunFunctionsResponse>; /** * Get all projects available on the server * @param request An optional request object * @returns A promise that resolves with an array of projects */ listProjects(request?: DeepPartial<GetProjectsRequest>): Promise<Array<Project>>; /** * Add a new project to the server * @param project The project to add * @returns A promise that resolves with the added project */ addProject(request: DeepPartial<AddProjectRequest>): Promise<AddProjectResponse>; /** * Update a project on the server * @param project The project to update * @returns A promise that resolves with the updated project */ updateProject(request: DeepPartial<UpdateProjectRequest>): Promise<UpdateProjectResponse>; /** * Remove a project from the server * @param projectId The id of the project to remove * @returns A promise that resolves when the project was removed */ removeProject(request: DeepPartial<RemoveProjectRequest>): Promise<RemoveProjectResponse>; /** * Get all intents for a given project * @param request The request object * @returns A promise that resolves with the response objects */ listIntents(request: DeepPartial<GetIntentsRequest>): Promise<Array<Intent>>; /** * This function allows to find out good thresholds by providing prompts that should match * an intent and negative prompts that should not match an intent. * * @param request The request object * @returns A promise that resolves with the response object */ getScoreLimits(request: DeepPartial<GetScoreLimitsRequest>): Promise<GetScoreLimitsResponse>; /** * List all available embedding models on the server * @param request An optional request object * @returns A promise that resolves with an array of embedding models */ listEmbeddingModels(request?: DeepPartial<GetEmbeddingModelsRequest>): Promise<Array<EmbeddingModel>>; /** * Triggers a database synchronization on the server. * @param request An optional request object * @returns A promise that resolves with the synchronization response */ syncDbs(request?: DeepPartial<SyncDBsRequest>): Promise<SyncDBsResponse>; /** * Get all keywords for a given project * @param request The request object * @returns A promise that resolves with the response objects */ getKeywords(request: DeepPartial<GetKeywordsRequest>): Promise<Array<GetKeywordsResponse>>; /** * Get the content of a given id * @param request The request object * @returns A promise that resolves with the response objects */ getContent(request: DeepPartial<GetContentRequest>): Promise<Array<GetContentResponse>>; /** * Updates content inside the vector database * @param request The request object * @returns A promise that resolves with the response object */ updateContent(request: DeepPartial<UpdateContentRequest>): Promise<UpdateContentResponse>; /** * Removes content from the vector database * @param request The request object * @returns A promise that resolves when the content was removed */ removeContent(request: DeepPartial<RemoveContentRequest>): Promise<RemoveContentResponse>; /** * Adds documents to a given project. * @param request The request object * @return A promise that resolves with the response object */ addDocuments(request: DeepPartial<AddDocumentsRequest>): Promise<AddDocumentsResponse>; /** * Gets all documents for a given project. * @param request The request object * @return A promise that resolves with the response object */ getDocuments(request: DeepPartial<GetDocumentsRequest>): Promise<GetDocumentsResponse>; /** * Processes spefified documents in a project. * @param request The request object * @return A promise that resolves with the response object */ processDocuments(request: DeepPartial<ProcessDocumentsRequest>): Promise<ProcessDocumentsResponse>; /** * Updates documents in a project. * @param request The request object * @return A promise that resolves with the response object */ updateDocuments(request: DeepPartial<UpdateDocumentsRequest>): Promise<UpdateDocumentsResponse>; /** * Removes documents from a project. * @param request The request object * @return A promise that resolves with the response object */ removeDocuments(request: DeepPartial<RemoveDocumentsRequest>): Promise<RemoveDocumentsResponse>; /** * Gets the processing status of a document in a project. * @param request The request object * @return A promise that resolves with the response object */ getDocumentStatus(request: DeepPartial<GetDocumentStatusRequest>): Promise<GetDocumentStatusResponse>; private getClient; }