UNPKG

@aristech-org/nlp-client

Version:

A Node.js client library for the Aristech NLP Service

751 lines (703 loc) 27 kB
// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.6.1 // protoc v3.21.12 // source: nlp_server.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { type CallOptions, ChannelCredentials, Client, type ClientOptions, type ClientReadableStream, type ClientUnaryCall, type handleServerStreamingCall, type handleUnaryCall, makeGenericClientConstructor, Metadata, type ServiceError, type UntypedServiceImplementation, } from "@grpc/grpc-js"; import { GetContentRequest, GetContentResponse, GetIntentsRequest, GetIntentsResponse, GetScoreLimitsRequest, GetScoreLimitsResponse, 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"; /** Request for list of functions that server provides */ export interface FunctionRequest { } /** * A function is a specific operation or information that can be performed on * incoming text. I.E. Classification, recasing etc. */ export interface FunctionMessage { /** * An unique ID for the function used (i.e. useful when using different * versions of a functions) */ id: string; /** An self-explaining name of the function */ name: string; /** A description of the function. */ description: string; /** A list of arguments for the function */ arguments: string[]; } /** Process raw text input. */ export interface RunFunctionsRequest { /** Function to be requested */ functions: FunctionMessage[]; /** The input to be processed */ input: string; /** * Arguments, if necessary. I.E. switchting between raw output and debug * output. */ arguments: string[]; } export interface RunFunctionsResponse { /** Processed text */ output: string; } function createBaseFunctionRequest(): FunctionRequest { return {}; } export const FunctionRequest: MessageFns<FunctionRequest> = { encode(_: FunctionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): FunctionRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let 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(_: any): FunctionRequest { return {}; }, toJSON(_: FunctionRequest): unknown { const obj: any = {}; return obj; }, create<I extends Exact<DeepPartial<FunctionRequest>, I>>(base?: I): FunctionRequest { return FunctionRequest.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<FunctionRequest>, I>>(_: I): FunctionRequest { const message = createBaseFunctionRequest(); return message; }, }; function createBaseFunctionMessage(): FunctionMessage { return { id: "", name: "", description: "", arguments: [] }; } export const FunctionMessage: MessageFns<FunctionMessage> = { encode(message: FunctionMessage, writer: BinaryWriter = new BinaryWriter()): 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!); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): FunctionMessage { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let 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; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): FunctionMessage { 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: any) => globalThis.String(e)) : [], }; }, toJSON(message: FunctionMessage): unknown { const obj: any = {}; 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; } return obj; }, create<I extends Exact<DeepPartial<FunctionMessage>, I>>(base?: I): FunctionMessage { return FunctionMessage.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<FunctionMessage>, I>>(object: I): FunctionMessage { const message = createBaseFunctionMessage(); message.id = object.id ?? ""; message.name = object.name ?? ""; message.description = object.description ?? ""; message.arguments = object.arguments?.map((e) => e) || []; return message; }, }; function createBaseRunFunctionsRequest(): RunFunctionsRequest { return { functions: [], input: "", arguments: [] }; } export const RunFunctionsRequest: MessageFns<RunFunctionsRequest> = { encode(message: RunFunctionsRequest, writer: BinaryWriter = new BinaryWriter()): 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!); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): RunFunctionsRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let 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; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): RunFunctionsRequest { return { functions: globalThis.Array.isArray(object?.functions) ? object.functions.map((e: any) => FunctionMessage.fromJSON(e)) : [], input: isSet(object.input) ? globalThis.String(object.input) : "", arguments: globalThis.Array.isArray(object?.arguments) ? object.arguments.map((e: any) => globalThis.String(e)) : [], }; }, toJSON(message: RunFunctionsRequest): unknown { const obj: any = {}; 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; } return obj; }, create<I extends Exact<DeepPartial<RunFunctionsRequest>, I>>(base?: I): RunFunctionsRequest { return RunFunctionsRequest.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<RunFunctionsRequest>, I>>(object: I): RunFunctionsRequest { const message = createBaseRunFunctionsRequest(); message.functions = object.functions?.map((e) => FunctionMessage.fromPartial(e)) || []; message.input = object.input ?? ""; message.arguments = object.arguments?.map((e) => e) || []; return message; }, }; function createBaseRunFunctionsResponse(): RunFunctionsResponse { return { output: "" }; } export const RunFunctionsResponse: MessageFns<RunFunctionsResponse> = { encode(message: RunFunctionsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.output !== "") { writer.uint32(10).string(message.output); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): RunFunctionsResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let 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: any): RunFunctionsResponse { return { output: isSet(object.output) ? globalThis.String(object.output) : "" }; }, toJSON(message: RunFunctionsResponse): unknown { const obj: any = {}; if (message.output !== "") { obj.output = message.output; } return obj; }, create<I extends Exact<DeepPartial<RunFunctionsResponse>, I>>(base?: I): RunFunctionsResponse { return RunFunctionsResponse.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<RunFunctionsResponse>, I>>(object: I): RunFunctionsResponse { const message = createBaseRunFunctionsResponse(); message.output = object.output ?? ""; return message; }, }; /** Interface exported by the server. */ export type NLPServerService = typeof NLPServerService; export const NLPServerService = { /** * A simple RPC. * returns all available processing Models. */ getFunctions: { path: "/aristech.nlp.NLPServer/GetFunctions", requestStream: false, responseStream: true, requestSerialize: (value: FunctionRequest) => Buffer.from(FunctionRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => FunctionRequest.decode(value), responseSerialize: (value: FunctionMessage) => Buffer.from(FunctionMessage.encode(value).finish()), responseDeserialize: (value: Buffer) => FunctionMessage.decode(value), }, /** * A server-to-client streaming method * Returns the processed text */ runFunctions: { path: "/aristech.nlp.NLPServer/RunFunctions", requestStream: false, responseStream: false, requestSerialize: (value: RunFunctionsRequest) => Buffer.from(RunFunctionsRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => RunFunctionsRequest.decode(value), responseSerialize: (value: RunFunctionsResponse) => Buffer.from(RunFunctionsResponse.encode(value).finish()), responseDeserialize: (value: Buffer) => RunFunctionsResponse.decode(value), }, /** Method to add content to a vector database. */ updateContent: { path: "/aristech.nlp.NLPServer/UpdateContent", requestStream: false, responseStream: false, requestSerialize: (value: UpdateContentRequest) => Buffer.from(UpdateContentRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => UpdateContentRequest.decode(value), responseSerialize: (value: UpdateContentResponse) => Buffer.from(UpdateContentResponse.encode(value).finish()), responseDeserialize: (value: Buffer) => UpdateContentResponse.decode(value), }, /** Method to remove content from a vector database. */ removeContent: { path: "/aristech.nlp.NLPServer/RemoveContent", requestStream: false, responseStream: false, requestSerialize: (value: RemoveContentRequest) => Buffer.from(RemoveContentRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => RemoveContentRequest.decode(value), responseSerialize: (value: RemoveContentResponse) => Buffer.from(RemoveContentResponse.encode(value).finish()), responseDeserialize: (value: Buffer) => RemoveContentResponse.decode(value), }, /** Method to get content from a vector database. */ getContent: { path: "/aristech.nlp.NLPServer/GetContent", requestStream: false, responseStream: true, requestSerialize: (value: GetContentRequest) => Buffer.from(GetContentRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => GetContentRequest.decode(value), responseSerialize: (value: GetContentResponse) => Buffer.from(GetContentResponse.encode(value).finish()), responseDeserialize: (value: Buffer) => GetContentResponse.decode(value), }, /** Method to initialize a project */ addProject: { path: "/aristech.nlp.NLPServer/AddProject", requestStream: false, responseStream: false, requestSerialize: (value: AddProjectRequest) => Buffer.from(AddProjectRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => AddProjectRequest.decode(value), responseSerialize: (value: AddProjectResponse) => Buffer.from(AddProjectResponse.encode(value).finish()), responseDeserialize: (value: Buffer) => AddProjectResponse.decode(value), }, /** Method to remove Project */ removeProject: { path: "/aristech.nlp.NLPServer/RemoveProject", requestStream: false, responseStream: false, requestSerialize: (value: RemoveProjectRequest) => Buffer.from(RemoveProjectRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => RemoveProjectRequest.decode(value), responseSerialize: (value: RemoveProjectResponse) => Buffer.from(RemoveProjectResponse.encode(value).finish()), responseDeserialize: (value: Buffer) => RemoveProjectResponse.decode(value), }, /** update the settings of a project */ updateProject: { path: "/aristech.nlp.NLPServer/UpdateProject", requestStream: false, responseStream: false, requestSerialize: (value: UpdateProjectRequest) => Buffer.from(UpdateProjectRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => UpdateProjectRequest.decode(value), responseSerialize: (value: UpdateProjectResponse) => Buffer.from(UpdateProjectResponse.encode(value).finish()), responseDeserialize: (value: Buffer) => UpdateProjectResponse.decode(value), }, /** Method to get projects from a vector database */ getProjects: { path: "/aristech.nlp.NLPServer/GetProjects", requestStream: false, responseStream: true, requestSerialize: (value: GetProjectsRequest) => Buffer.from(GetProjectsRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => GetProjectsRequest.decode(value), responseSerialize: (value: Project) => Buffer.from(Project.encode(value).finish()), responseDeserialize: (value: Buffer) => Project.decode(value), }, /** Method to get intents from a project */ getIntents: { path: "/aristech.nlp.NLPServer/GetIntents", requestStream: false, responseStream: true, requestSerialize: (value: GetIntentsRequest) => Buffer.from(GetIntentsRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => GetIntentsRequest.decode(value), responseSerialize: (value: GetIntentsResponse) => Buffer.from(GetIntentsResponse.encode(value).finish()), responseDeserialize: (value: Buffer) => GetIntentsResponse.decode(value), }, /** Method to get score limits for a project */ getScoreLimits: { path: "/aristech.nlp.NLPServer/GetScoreLimits", requestStream: false, responseStream: false, requestSerialize: (value: GetScoreLimitsRequest) => Buffer.from(GetScoreLimitsRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => GetScoreLimitsRequest.decode(value), responseSerialize: (value: GetScoreLimitsResponse) => Buffer.from(GetScoreLimitsResponse.encode(value).finish()), responseDeserialize: (value: Buffer) => GetScoreLimitsResponse.decode(value), }, /** get the available embedding models to be used for similarity search */ getEmbeddingModels: { path: "/aristech.nlp.NLPServer/GetEmbeddingModels", requestStream: false, responseStream: true, requestSerialize: (value: GetEmbeddingModelsRequest) => Buffer.from(GetEmbeddingModelsRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => GetEmbeddingModelsRequest.decode(value), responseSerialize: (value: EmbeddingModel) => Buffer.from(EmbeddingModel.encode(value).finish()), responseDeserialize: (value: Buffer) => EmbeddingModel.decode(value), }, } as const; export interface NLPServerServer extends UntypedServiceImplementation { /** * A simple RPC. * returns all available processing Models. */ getFunctions: handleServerStreamingCall<FunctionRequest, FunctionMessage>; /** * A server-to-client streaming method * Returns the processed text */ runFunctions: handleUnaryCall<RunFunctionsRequest, RunFunctionsResponse>; /** Method to add content to a vector database. */ updateContent: handleUnaryCall<UpdateContentRequest, UpdateContentResponse>; /** Method to remove content from a vector database. */ removeContent: handleUnaryCall<RemoveContentRequest, RemoveContentResponse>; /** Method to get content from a vector database. */ getContent: handleServerStreamingCall<GetContentRequest, GetContentResponse>; /** Method to initialize a project */ addProject: handleUnaryCall<AddProjectRequest, AddProjectResponse>; /** Method to remove Project */ removeProject: handleUnaryCall<RemoveProjectRequest, RemoveProjectResponse>; /** update the settings of a project */ updateProject: handleUnaryCall<UpdateProjectRequest, UpdateProjectResponse>; /** Method to get projects from a vector database */ getProjects: handleServerStreamingCall<GetProjectsRequest, Project>; /** Method to get intents from a project */ getIntents: handleServerStreamingCall<GetIntentsRequest, GetIntentsResponse>; /** Method to get score limits for a project */ getScoreLimits: handleUnaryCall<GetScoreLimitsRequest, GetScoreLimitsResponse>; /** get the available embedding models to be used for similarity search */ getEmbeddingModels: handleServerStreamingCall<GetEmbeddingModelsRequest, EmbeddingModel>; } export interface NLPServerClient extends Client { /** * A simple RPC. * returns all available processing Models. */ getFunctions(request: FunctionRequest, options?: Partial<CallOptions>): ClientReadableStream<FunctionMessage>; getFunctions( request: FunctionRequest, metadata?: Metadata, options?: Partial<CallOptions>, ): ClientReadableStream<FunctionMessage>; /** * A server-to-client streaming method * Returns the processed text */ runFunctions( request: RunFunctionsRequest, callback: (error: ServiceError | null, response: RunFunctionsResponse) => void, ): ClientUnaryCall; runFunctions( request: RunFunctionsRequest, metadata: Metadata, callback: (error: ServiceError | null, response: RunFunctionsResponse) => void, ): ClientUnaryCall; runFunctions( request: RunFunctionsRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: RunFunctionsResponse) => void, ): ClientUnaryCall; /** Method to add content to a vector database. */ updateContent( request: UpdateContentRequest, callback: (error: ServiceError | null, response: UpdateContentResponse) => void, ): ClientUnaryCall; updateContent( request: UpdateContentRequest, metadata: Metadata, callback: (error: ServiceError | null, response: UpdateContentResponse) => void, ): ClientUnaryCall; updateContent( request: UpdateContentRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: UpdateContentResponse) => void, ): ClientUnaryCall; /** Method to remove content from a vector database. */ removeContent( request: RemoveContentRequest, callback: (error: ServiceError | null, response: RemoveContentResponse) => void, ): ClientUnaryCall; removeContent( request: RemoveContentRequest, metadata: Metadata, callback: (error: ServiceError | null, response: RemoveContentResponse) => void, ): ClientUnaryCall; removeContent( request: RemoveContentRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: RemoveContentResponse) => void, ): ClientUnaryCall; /** Method to get content from a vector database. */ getContent(request: GetContentRequest, options?: Partial<CallOptions>): ClientReadableStream<GetContentResponse>; getContent( request: GetContentRequest, metadata?: Metadata, options?: Partial<CallOptions>, ): ClientReadableStream<GetContentResponse>; /** Method to initialize a project */ addProject( request: AddProjectRequest, callback: (error: ServiceError | null, response: AddProjectResponse) => void, ): ClientUnaryCall; addProject( request: AddProjectRequest, metadata: Metadata, callback: (error: ServiceError | null, response: AddProjectResponse) => void, ): ClientUnaryCall; addProject( request: AddProjectRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: AddProjectResponse) => void, ): ClientUnaryCall; /** Method to remove Project */ removeProject( request: RemoveProjectRequest, callback: (error: ServiceError | null, response: RemoveProjectResponse) => void, ): ClientUnaryCall; removeProject( request: RemoveProjectRequest, metadata: Metadata, callback: (error: ServiceError | null, response: RemoveProjectResponse) => void, ): ClientUnaryCall; removeProject( request: RemoveProjectRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: RemoveProjectResponse) => void, ): ClientUnaryCall; /** update the settings of a project */ updateProject( request: UpdateProjectRequest, callback: (error: ServiceError | null, response: UpdateProjectResponse) => void, ): ClientUnaryCall; updateProject( request: UpdateProjectRequest, metadata: Metadata, callback: (error: ServiceError | null, response: UpdateProjectResponse) => void, ): ClientUnaryCall; updateProject( request: UpdateProjectRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: UpdateProjectResponse) => void, ): ClientUnaryCall; /** Method to get projects from a vector database */ getProjects(request: GetProjectsRequest, options?: Partial<CallOptions>): ClientReadableStream<Project>; getProjects( request: GetProjectsRequest, metadata?: Metadata, options?: Partial<CallOptions>, ): ClientReadableStream<Project>; /** Method to get intents from a project */ getIntents(request: GetIntentsRequest, options?: Partial<CallOptions>): ClientReadableStream<GetIntentsResponse>; getIntents( request: GetIntentsRequest, metadata?: Metadata, options?: Partial<CallOptions>, ): ClientReadableStream<GetIntentsResponse>; /** Method to get score limits for a project */ getScoreLimits( request: GetScoreLimitsRequest, callback: (error: ServiceError | null, response: GetScoreLimitsResponse) => void, ): ClientUnaryCall; getScoreLimits( request: GetScoreLimitsRequest, metadata: Metadata, callback: (error: ServiceError | null, response: GetScoreLimitsResponse) => void, ): ClientUnaryCall; getScoreLimits( request: GetScoreLimitsRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: GetScoreLimitsResponse) => void, ): ClientUnaryCall; /** get the available embedding models to be used for similarity search */ getEmbeddingModels( request: GetEmbeddingModelsRequest, options?: Partial<CallOptions>, ): ClientReadableStream<EmbeddingModel>; getEmbeddingModels( request: GetEmbeddingModelsRequest, metadata?: Metadata, options?: Partial<CallOptions>, ): ClientReadableStream<EmbeddingModel>; } export const NLPServerClient = makeGenericClientConstructor(NLPServerService, "aristech.nlp.NLPServer") as unknown as { new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): NLPServerClient; service: typeof NLPServerService; serviceName: string; }; type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> } : Partial<T>; type KeysOfUnion<T> = T extends T ? keyof T : never; export type Exact<P, I extends P> = P extends Builtin ? P : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never }; function isSet(value: any): boolean { return value !== null && value !== undefined; } export interface MessageFns<T> { encode(message: T, writer?: BinaryWriter): BinaryWriter; decode(input: BinaryReader | Uint8Array, length?: number): T; fromJSON(object: any): T; toJSON(message: T): unknown; create<I extends Exact<DeepPartial<T>, I>>(base?: I): T; fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T; }