UNPKG

@aristech-org/nlp-client

Version:

A Node.js client library for the Aristech NLP Service

119 lines (118 loc) 5.11 kB
import * as grpc from '@grpc/grpc-js'; import { type DeepPartial, type FunctionMessage, FunctionRequest, RunFunctionsRequest, type RunFunctionsResponse } from './generated/nlp_server.js'; import { GetContentRequest, type GetContentResponse, GetIntentsRequest, GetScoreLimitsRequest, GetScoreLimitsResponse, Intent, RemoveContentRequest, type RemoveContentResponse, UpdateContentRequest, type UpdateContentResponse } from './generated/intents.js'; import { AddProjectRequest, type AddProjectResponse, GetProjectsRequest, type Project, RemoveProjectRequest, RemoveProjectResponse, UpdateProjectRequest, UpdateProjectResponse } from './generated/projects.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>; /** * Get the content of a given id * @param request The request object * @returns A promise that resolves with the response object */ getContent(request: DeepPartial<GetContentRequest>): Promise<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>; private getClient; }