// Copyright 2025 IBM Corp.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_data_model_nlp.proto

/*------------------------------------------------------------------------------
 * AUTO GENERATED
 *----------------------------------------------------------------------------*/

syntax = "proto3";
package caikit_data_model.nlp;
import "caikit_data_model_common.proto";


/*-- ENUMS -------------------------------------------------------------------*/

enum FinishReason {
  NOT_FINISHED = 0;
  MAX_TOKENS = 1;
  EOS_TOKEN = 2;
  CANCELLED = 3;
  TIME_LIMIT = 4;
  STOP_SEQUENCE = 5;
  TOKEN_LIMIT = 6;
  ERROR = 7;
}

enum InputWarningReason {
  UNSUITABLE_INPUT = 0;
}


/*-- MESSAGES ----------------------------------------------------------------*/

message ClassificationResult {

  /*-- fields --*/
  string label = 1;
  double score = 2;
}

message ClassificationResults {

  /*-- fields --*/
  repeated caikit_data_model.nlp.ClassificationResult results = 1;
}

message ClassificationTrainRecord {

  /*-- fields --*/
  string text = 1;
  repeated string labels = 2;
}

message ClassifiedGeneratedTextResult {

  /*-- fields --*/
  string generated_text = 1;
  caikit_data_model.nlp.TextGenTokenClassificationResults token_classification_results = 2;
  caikit_data_model.nlp.FinishReason finish_reason = 3;
  int64 generated_token_count = 4;
  uint64 seed = 5;
  int64 input_token_count = 6;
  repeated caikit_data_model.nlp.InputWarning warnings = 9;
  repeated caikit_data_model.nlp.GeneratedToken tokens = 10;
  repeated caikit_data_model.nlp.GeneratedToken input_tokens = 11;
}

message ClassifiedGeneratedTextStreamResult {

  /*-- fields --*/
  string generated_text = 1;
  caikit_data_model.nlp.TextGenTokenClassificationResults token_classification_results = 2;
  caikit_data_model.nlp.FinishReason finish_reason = 3;
  int64 generated_token_count = 4;
  uint64 seed = 5;
  int64 input_token_count = 6;
  repeated caikit_data_model.nlp.InputWarning warnings = 9;
  repeated caikit_data_model.nlp.GeneratedToken tokens = 10;
  repeated caikit_data_model.nlp.GeneratedToken input_tokens = 11;
  int64 processed_index = 7;
  int64 start_index = 8;
}

message GeneratedTextResult {

  /*-- fields --*/
  string generated_text = 1;
  int64 generated_tokens = 2;
  caikit_data_model.nlp.FinishReason finish_reason = 3;
  caikit_data_model.common.ProducerId producer_id = 4;
  int64 input_token_count = 5;
  uint64 seed = 6;
  repeated caikit_data_model.nlp.GeneratedToken tokens = 7;
  repeated caikit_data_model.nlp.GeneratedToken input_tokens = 8;
}

message GeneratedTextStreamResult {

  /*-- fields --*/
  string generated_text = 1;
  repeated caikit_data_model.nlp.GeneratedToken tokens = 2;
  caikit_data_model.nlp.TokenStreamDetails details = 3;
  caikit_data_model.common.ProducerId producer_id = 4;
  repeated caikit_data_model.nlp.GeneratedToken input_tokens = 5;
}

message GeneratedToken {

  /*-- fields --*/
  string text = 1;
  double logprob = 3;
}

message InputWarning {

  /*-- fields --*/
  caikit_data_model.nlp.InputWarningReason id = 1;
  string message = 2;
}

message TextGenTokenClassificationResults {

  /*-- fields --*/
  repeated caikit_data_model.nlp.TokenClassificationResult input = 10;
  repeated caikit_data_model.nlp.TokenClassificationResult output = 20;
}

message Token {

  /*-- fields --*/
  int64 start = 1;
  int64 end = 2;
  string text = 3;
}

message TokenClassificationResult {

  /*-- fields --*/
  int64 start = 1;
  int64 end = 2;
  string word = 3;
  string entity = 4;
  string entity_group = 5;
  double score = 6;
  int64 token_count = 7;
}

message TokenClassificationResults {

  /*-- fields --*/
  repeated caikit_data_model.nlp.TokenClassificationResult results = 1;
}

message TokenClassificationStreamResult {

  /*-- fields --*/
  repeated caikit_data_model.nlp.TokenClassificationResult results = 1;
  int64 processed_index = 2;
  int64 start_index = 3;
}

message TokenStreamDetails {

  /*-- fields --*/
  caikit_data_model.nlp.FinishReason finish_reason = 1;
  uint32 generated_tokens = 2;
  uint64 seed = 3;
  int64 input_token_count = 4;
}

message TokenizationResults {

  /*-- fields --*/
  repeated caikit_data_model.nlp.Token results = 1;
  int64 token_count = 4;
}

message TokenizationStreamResult {

  /*-- fields --*/
  repeated caikit_data_model.nlp.Token results = 1;
  int64 token_count = 4;
  int64 processed_index = 2;
  int64 start_index = 3;
}
