syntax = "proto3"; package com.mlp.gate; import "google/protobuf/duration.proto"; option java_multiple_files = true; service Gate { rpc healthCheck (HeartBeatProto) returns (HeartBeatProto); rpc processAsync(stream ServiceToGateProto) returns (stream GateToServiceProto) {} rpc process(ClientRequestProto) returns (ClientResponseProto) {} rpc processResponseStream(ClientRequestProto) returns (stream ClientResponseProto) {} rpc processStream(stream ClientRequestProto) returns (stream ClientResponseProto) {} rpc processSynthesis(ClientTtsRequestProto) returns (stream ClientTtsResponseProto) {} rpc processRecognition(stream ClientAsrRequestProto) returns (stream ClientAsrResponseProto) {} } message ServiceDescriptorProto { string name = 1; bool fittable = 10; map methods = 20; // Контент протобаф-спеки для специфических типов данных, используемых данных экшеном. // пока что это поле предназначено для экспериментов map schemaFiles = 30; } message MethodDescriptorProto { map input = 1; ParamDescriptorProto output = 2; optional bool fitted = 3; } message ParamDescriptorProto { string type = 1; } message ServiceInfoProto { int64 accountId = 1; int64 modelId = 2; string modelName = 3; string authToken = 4; optional string bucketName = 5; } message ServiceToGateProto { int64 requestId = 1; oneof body { HeartBeatProto heartBeat = 2; StartServingProto startServing = 3; StopServingProto stopServing = 4; PredictResponseProto predict = 101; FitResponseProto fit = 102; ExtendedResponseProto ext = 103; StatusResponseProto status = 105; BatchResponseProto batch = 106; PartialPredictResponseProto partialPredict = 107; FitStatusProto fitStatus = 108; DeferredBillingChargeRequestProto deferredBillingCharge = 109; DeferredBillingChargesProto deferredBillingCharges = 110; ApiErrorProto error = 201; } map headers = 1000; } message GateToServiceProto { int64 requestId = 1; oneof body { HeartBeatProto heartBeat = 2; ClusterUpdateProto cluster = 3; ServiceInfoProto serviceInfo = 4; StopServingProto stopServing = 5; PredictRequestProto predict = 101; FitRequestProto fit = 102; ExtendedRequestProto ext = 103; StatusRequestProto status = 105; BatchRequestProto batch = 106; PartialPredictRequestProto partialPredict = 107; CancelRequestProto cancel = 108; ApiErrorProto error = 201; } map headers = 1000; } message HeartBeatProto { string status = 1; int32 interval = 2; } message StartServingProto { // Чтобы зарегистрироваться, сервис должен указать секретный ключ. Этот ключ генерирует Кайла // и передаёт в Cloud через env-переменные string connectionToken = 1; ServiceDescriptorProto serviceDescriptor = 3; optional string hostname = 4; optional int64 version = 5; optional string image = 6; // Unique identifier of the current SDK process lifetime. // Stable within a single process run; regenerated on instance restart. // Used by gateway to distinguish transient network disconnect from instance restart. // Field 7 is reserved (used as `imageVersionJson` in legacy mlp-python-sdk proto copy). optional string instanceBootUuid = 8; } message StopServingProto { optional string reason = 1; } message PredictRequestProto { PayloadProto data = 101; optional PayloadProto config = 102; } message PartialPredictRequestProto { PayloadProto data = 101; optional PayloadProto config = 102; optional bool start = 103; optional bool finish = 104; } message BatchRequestProto { repeated BatchPayloadProto data = 101; optional PayloadProto config = 102; } message PredictResponseProto { PayloadProto data = 101; map headers = 102; optional int32 statusCode = 103; } message PartialPredictResponseProto { PayloadProto data = 101; optional bool start = 103; optional bool finish = 104; map headers = 105; optional int32 statusCode = 106; } message FitStatusProto { int32 percentage = 101; } message DeferredBillingChargeRequestProto { string billingRequestId = 1; int64 amountInUnits = 2; } message DeferredBillingChargesProto { repeated DeferredBillingChargeProto charges = 1; DeferredBillingParamsProto params = 2; } message DeferredBillingParamsProto { optional int64 callerAccountId = 1; optional string apiKeyName = 2; optional string billingKeyName = 3; optional int64 billingAccountId = 4; optional string billingUserId = 5; } message DeferredBillingChargeProto { string idempotencyKey = 1; int64 amount = 2; optional string currency = 3; optional string llmModelName = 4; optional string billingDetails = 5; } message BatchResponseProto { repeated BatchPayloadResponseProto data = 101; } message DatasetInfoProto { int64 accountId = 1; int64 datasetId = 2; string name = 3; string type = 4; } message FitRequestProto { PayloadProto trainData = 101; optional PayloadProto targetsData = 102; optional PayloadProto config = 103; string modelDir = 104; optional string previousModelDir = 105; ServiceInfoProto targetServiceInfo = 106; DatasetInfoProto datasetInfo = 107; } message FitResponseProto { } message ExtendedRequestProto { string methodName = 1; map params = 2; } message ExtendedResponseProto { PayloadProto data = 1; map headers = 102; optional int32 statusCode = 103; } message BatchPayloadProto { int64 requestId = 1; PayloadProto data = 101; map headers = 102; optional int32 statusCode = 103; } message BatchPayloadResponseProto { int64 requestId = 1; oneof body { PredictResponseProto predict = 101; ApiErrorProto error = 201; } map headers = 1000; } message StatusRequestProto { } message StatusResponseProto { repeated string connectedGates = 1; bool connectedToAllGates = 2; } message CancelRequestProto { int64 requestIdToCancel = 101; } message PayloadProto { // имя класса, закодированного в text или bytes optional string dataType = 1; oneof body { string json = 101; bytes protobuf = 102; } } enum SimpleStatusProto { // Success OK = 0; // Client errors (4xx) BAD_REQUEST = 400; UNAUTHORIZED = 401; PAYMENT_REQUIRED = 402; FORBIDDEN = 403; NOT_FOUND = 404; METHOD_NOT_ALLOWED = 405; NOT_ACCEPTABLE = 406; PROXY_AUTHENTICATION_REQUIRED = 407; REQUEST_TIMEOUT = 408; CONFLICT = 409; GONE = 410; LENGTH_REQUIRED = 411; PRECONDITION_FAILED = 412; PAYLOAD_TOO_LARGE = 413; URI_TOO_LONG = 414; UNSUPPORTED_MEDIA_TYPE = 415; RANGE_NOT_SATISFIABLE = 416; EXPECTATION_FAILED = 417; IM_A_TEAPOT = 418; MISDIRECTED_REQUEST = 421; UNPROCESSABLE_ENTITY = 422; LOCKED = 423; FAILED_DEPENDENCY = 424; TOO_EARLY = 425; UPGRADE_REQUIRED = 426; PRECONDITION_REQUIRED = 428; TOO_MANY_REQUESTS = 429; REQUEST_HEADER_FIELDS_TOO_LARGE = 431; UNAVAILABLE_FOR_LEGAL_REASONS = 451; // Nginx specific (4xx) NO_RESPONSE = 444; // Nginx: Connection closed without response REQUEST_HEADER_TOO_LARGE = 494; // Nginx: Request header too large SSL_CERTIFICATE_ERROR = 495; // Nginx: SSL certificate error SSL_CERTIFICATE_REQUIRED = 496; // Nginx: SSL certificate required HTTP_REQUEST_SENT_TO_HTTPS_PORT = 497; // Nginx: HTTP request sent to HTTPS port CLIENT_CLOSED_REQUEST = 499; // Nginx: Client closed request // Server errors (5xx) INTERNAL_SERVER_ERROR = 500; NOT_IMPLEMENTED = 501; BAD_GATEWAY = 502; SERVICE_UNAVAILABLE = 503; GATEWAY_TIMEOUT = 504; HTTP_VERSION_NOT_SUPPORTED = 505; VARIANT_ALSO_NEGOTIATES = 506; INSUFFICIENT_STORAGE = 507; LOOP_DETECTED = 508; NOT_EXTENDED = 510; NETWORK_AUTHENTICATION_REQUIRED = 511; // Cloudflare specific (5xx) WEB_SERVER_RETURNED_UNKNOWN_ERROR = 520; // Cloudflare: Web server returned unknown error WEB_SERVER_IS_DOWN = 521; // Cloudflare: Web server is down CONNECTION_TIMED_OUT = 522; // Cloudflare: Connection timed out ORIGIN_IS_UNREACHABLE = 523; // Cloudflare: Origin is unreachable A_TIMEOUT_OCCURRED = 524; // Cloudflare: A timeout occurred SSL_HANDSHAKE_FAILED = 525; // Cloudflare: SSL handshake failed INVALID_SSL_CERTIFICATE = 526; // Cloudflare: Invalid SSL certificate RAILGUN_ERROR = 527; // Cloudflare: Railgun error SITE_IS_OVERLOADED = 529; // Cloudflare: Site is overloaded SITE_IS_FROZEN = 530; // Cloudflare: Site is frozen // AWS specific ORIGIN_CONNECTION_TIME_OUT = 561; // AWS ELB: Origin connection time-out } message ApiErrorProto { string code = 1; string message = 2; optional SimpleStatusProto status = 3; map args = 4; optional int32 statusCode = 5; // произвольный HTTP-статус код (приоритетнее status) } message ClientRequestProto { string account = 1; // тут можно передавать либо id либо shortName аккаунта и модели соответственно string model = 2; // обработка будет происходить так: если только цифры - значит id, иначе name // Чтобы обратиться к экшену, клиент должен указать секретный токен. // Это может быть либо id-сессии в AA, либо отдельный токен доступа, который можно сгенерировать и получить // через MLP API. Внутри системы, токен будет ассоциирован с конкретным аккаунтом в АА. string authToken = 3; // Таймаут в секундах. Если не указан, то используется значение по умолчанию int32 timeoutSec = 4; oneof body { PredictRequestProto predict = 101; ExtendedRequestProto ext = 103; PartialPredictRequestProto partialPredict = 104; } map headers = 1000; } message ClientResponseProto { oneof body { PredictResponseProto predict = 101; ExtendedResponseProto ext = 103; PartialPredictResponseProto partialPredict = 104; ApiErrorProto error = 201; } map headers = 1000; } message ClientTokenRequestProto { } message ClientTokenResponseProto { string token = 1; } message ClusterUpdateProto { repeated string servers = 1; string currentServer = 2; } message SimpleTextProto { string text = 1; } // GRPC TTS API message ClientTtsRequestProto { string account = 1; string model = 2; string authToken = 3; TtsRequestProto tts = 101; } message TtsRequestProto { string text = 1; optional string voice = 2; optional AudioFormatOptions output_audio_spec = 3; } message AudioFormatOptions { enum AudioEncoding { LINEAR16_PCM = 0; } optional AudioEncoding audio_encoding = 1; optional int64 sample_rate_hertz = 2; optional int64 chunk_size_kb = 3; } message ClientTtsResponseProto { oneof body { TtsResponseProto tts = 101; ApiErrorProto error = 201; } } message TtsResponseProto { message AudioChunk { bytes data = 1; } AudioChunk audio_chunk = 1; optional bool first = 10; optional bool last = 12; } message ClientAsrRequestProto { string account = 1; string model = 2; string authToken = 3; AsrRequestProto asr = 101; } message AsrRequestProto { oneof streaming_request { RecognitionConfig config = 1; bytes audio_content = 2; } } message RecognitionConfig { enum AudioEncoding { AUDIO_ENCODING_UNSPECIFIED = 0; LINEAR16_PCM = 1; OGG_OPUS = 2; MP3 = 3; MULAW = 4; ALAW = 5; FLAC = 6; } AudioEncoding audio_encoding = 1; int64 sample_rate_hertz = 2; // code in BCP-47 string language_code = 3; bool enable_profanity_filter = 4; string model = 5; // If set true, tentative hypotheses may be returned as they become available (final=false flag) // If false or omitted, only final=true result(s) are returned. // Makes sense only for StreamingRecognize requests. bool enable_partial_results = 7; bool enable_single_utterance = 8; // Used only for long running recognize. int64 audio_channel_count = 9; // This mark allows disable normalization text bool enable_raw_results = 10; // Rewrite text in literature style (default: false) bool enable_literature_text = 11; bool enable_automatic_punctuation = 12; string provider_specific = 13; } message ClientAsrResponseProto { oneof body { AsrResponseProto asr = 101; ApiErrorProto error = 201; } } message AsrResponseProto { repeated SpeechRecognitionChunk chunks = 1; optional bool final = 2; string provider_specific = 3; } message SpeechRecognitionChunk { repeated SpeechRecognitionAlternative alternatives = 1; // This flag shows that the received chunk contains a part of the recognized text that won't be changed. bool final = 2; // This flag shows that the received chunk is the end of an utterance. bool end_of_utterance = 3; } message SpeechRecognitionAlternative { string text = 1; float confidence = 2; repeated WordInfo words = 3; } message WordInfo { google.protobuf.Duration start_time = 1; google.protobuf.Duration end_time = 2; string word = 3; float confidence = 4; }