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; 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; 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; } 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; } message PartialPredictResponseProto { PayloadProto data = 101; optional bool start = 103; optional bool finish = 104; } message FitStatusProto { int32 percentage = 101; } 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; } message BatchPayloadProto { int64 requestId = 1; PayloadProto data = 101; } 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 PayloadProto { // имя класса, закодированного в text или bytes optional string dataType = 1; oneof body { string json = 101; bytes protobuf = 102; } } enum SimpleStatusProto { OK = 0; BAD_REQUEST = 400; NOT_FOUND = 404; INTERNAL_SERVER_ERROR = 500; } message ApiErrorProto { string code = 1; string message = 2; SimpleStatusProto status = 3; map args = 4; } 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; }