// Code generated by sidekick. DO NOT EDIT.
//
// Copyright 2026 Google LLC
//
// 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
//
//     https://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.

#if EvaluationService
  import Foundation
  import GoogleCloudWkt

  /// Response message for EvaluationService.EvaluateInstances.
  public struct EvaluateInstancesResponse: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Metric results for each instance.
    /// The order of the metric results is guaranteed to be the same as the order
    /// of the instances in the request.
    public var metricResults: [MetricResult] = []

    /// Evaluation results will be served in the same order as presented in
    /// EvaluationRequest.instances.
    public var evaluationResults: OneOf_EvaluationResults? = nil

    /// Initialize a new instance of `EvaluateInstancesResponse`.
    public init() {}

    /// Use `config` to return a new instance of this object, with some fields updated.
    ///
    /// Commonly used to initialize the value, for example:
    ///
    /// ```
    /// let value = EvaluateInstancesResponse().with { $0.exactMatchResults = ... }
    /// ```
    public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
      var copy = self
      try config(&copy)
      return copy
    }

    private enum CodingKeys: Swift.String, CodingKey {
      case exactMatchResults = "exactMatchResults"
      case bleuResults = "bleuResults"
      case rougeResults = "rougeResults"
      case fluencyResult = "fluencyResult"
      case coherenceResult = "coherenceResult"
      case safetyResult = "safetyResult"
      case groundednessResult = "groundednessResult"
      case fulfillmentResult = "fulfillmentResult"
      case summarizationQualityResult = "summarizationQualityResult"
      case pairwiseSummarizationQualityResult = "pairwiseSummarizationQualityResult"
      case summarizationHelpfulnessResult = "summarizationHelpfulnessResult"
      case summarizationVerbosityResult = "summarizationVerbosityResult"
      case questionAnsweringQualityResult = "questionAnsweringQualityResult"
      case pairwiseQuestionAnsweringQualityResult = "pairwiseQuestionAnsweringQualityResult"
      case questionAnsweringRelevanceResult = "questionAnsweringRelevanceResult"
      case questionAnsweringHelpfulnessResult = "questionAnsweringHelpfulnessResult"
      case questionAnsweringCorrectnessResult = "questionAnsweringCorrectnessResult"
      case pointwiseMetricResult = "pointwiseMetricResult"
      case pairwiseMetricResult = "pairwiseMetricResult"
      case toolCallValidResults = "toolCallValidResults"
      case toolNameMatchResults = "toolNameMatchResults"
      case toolParameterKeyMatchResults = "toolParameterKeyMatchResults"
      case toolParameterKvMatchResults = "toolParameterKvMatchResults"
      case cometResult = "cometResult"
      case metricxResult = "metricxResult"
      case metricResults = "metricResults"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.metricResults = try container.decode([MetricResult].self, forKey: .metricResults)

      var evaluationResults: OneOf_EvaluationResults? = nil
      let evaluationResultsCheckAndSet = {
        if evaluationResults != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'evaluationResults'"))
        }
        evaluationResults = $0
      }
      if let exactMatchResults = try container.decodeIfPresent(
        ExactMatchResults?.self, forKey: .exactMatchResults)
      {
        try evaluationResultsCheckAndSet(.exactMatchResults(exactMatchResults))
      }
      if let bleuResults = try container.decodeIfPresent(BleuResults?.self, forKey: .bleuResults) {
        try evaluationResultsCheckAndSet(.bleuResults(bleuResults))
      }
      if let rougeResults = try container.decodeIfPresent(RougeResults?.self, forKey: .rougeResults)
      {
        try evaluationResultsCheckAndSet(.rougeResults(rougeResults))
      }
      if let fluencyResult = try container.decodeIfPresent(
        FluencyResult?.self, forKey: .fluencyResult)
      {
        try evaluationResultsCheckAndSet(.fluencyResult(fluencyResult))
      }
      if let coherenceResult = try container.decodeIfPresent(
        CoherenceResult?.self, forKey: .coherenceResult)
      {
        try evaluationResultsCheckAndSet(.coherenceResult(coherenceResult))
      }
      if let safetyResult = try container.decodeIfPresent(SafetyResult?.self, forKey: .safetyResult)
      {
        try evaluationResultsCheckAndSet(.safetyResult(safetyResult))
      }
      if let groundednessResult = try container.decodeIfPresent(
        GroundednessResult?.self, forKey: .groundednessResult)
      {
        try evaluationResultsCheckAndSet(.groundednessResult(groundednessResult))
      }
      if let fulfillmentResult = try container.decodeIfPresent(
        FulfillmentResult?.self, forKey: .fulfillmentResult)
      {
        try evaluationResultsCheckAndSet(.fulfillmentResult(fulfillmentResult))
      }
      if let summarizationQualityResult = try container.decodeIfPresent(
        SummarizationQualityResult?.self, forKey: .summarizationQualityResult)
      {
        try evaluationResultsCheckAndSet(.summarizationQualityResult(summarizationQualityResult))
      }
      if let pairwiseSummarizationQualityResult = try container.decodeIfPresent(
        PairwiseSummarizationQualityResult?.self, forKey: .pairwiseSummarizationQualityResult)
      {
        try evaluationResultsCheckAndSet(
          .pairwiseSummarizationQualityResult(pairwiseSummarizationQualityResult))
      }
      if let summarizationHelpfulnessResult = try container.decodeIfPresent(
        SummarizationHelpfulnessResult?.self, forKey: .summarizationHelpfulnessResult)
      {
        try evaluationResultsCheckAndSet(
          .summarizationHelpfulnessResult(summarizationHelpfulnessResult))
      }
      if let summarizationVerbosityResult = try container.decodeIfPresent(
        SummarizationVerbosityResult?.self, forKey: .summarizationVerbosityResult)
      {
        try evaluationResultsCheckAndSet(
          .summarizationVerbosityResult(summarizationVerbosityResult))
      }
      if let questionAnsweringQualityResult = try container.decodeIfPresent(
        QuestionAnsweringQualityResult?.self, forKey: .questionAnsweringQualityResult)
      {
        try evaluationResultsCheckAndSet(
          .questionAnsweringQualityResult(questionAnsweringQualityResult))
      }
      if let pairwiseQuestionAnsweringQualityResult = try container.decodeIfPresent(
        PairwiseQuestionAnsweringQualityResult?.self,
        forKey: .pairwiseQuestionAnsweringQualityResult)
      {
        try evaluationResultsCheckAndSet(
          .pairwiseQuestionAnsweringQualityResult(pairwiseQuestionAnsweringQualityResult))
      }
      if let questionAnsweringRelevanceResult = try container.decodeIfPresent(
        QuestionAnsweringRelevanceResult?.self, forKey: .questionAnsweringRelevanceResult)
      {
        try evaluationResultsCheckAndSet(
          .questionAnsweringRelevanceResult(questionAnsweringRelevanceResult))
      }
      if let questionAnsweringHelpfulnessResult = try container.decodeIfPresent(
        QuestionAnsweringHelpfulnessResult?.self, forKey: .questionAnsweringHelpfulnessResult)
      {
        try evaluationResultsCheckAndSet(
          .questionAnsweringHelpfulnessResult(questionAnsweringHelpfulnessResult))
      }
      if let questionAnsweringCorrectnessResult = try container.decodeIfPresent(
        QuestionAnsweringCorrectnessResult?.self, forKey: .questionAnsweringCorrectnessResult)
      {
        try evaluationResultsCheckAndSet(
          .questionAnsweringCorrectnessResult(questionAnsweringCorrectnessResult))
      }
      if let pointwiseMetricResult = try container.decodeIfPresent(
        PointwiseMetricResult?.self, forKey: .pointwiseMetricResult)
      {
        try evaluationResultsCheckAndSet(.pointwiseMetricResult(pointwiseMetricResult))
      }
      if let pairwiseMetricResult = try container.decodeIfPresent(
        PairwiseMetricResult?.self, forKey: .pairwiseMetricResult)
      {
        try evaluationResultsCheckAndSet(.pairwiseMetricResult(pairwiseMetricResult))
      }
      if let toolCallValidResults = try container.decodeIfPresent(
        ToolCallValidResults?.self, forKey: .toolCallValidResults)
      {
        try evaluationResultsCheckAndSet(.toolCallValidResults(toolCallValidResults))
      }
      if let toolNameMatchResults = try container.decodeIfPresent(
        ToolNameMatchResults?.self, forKey: .toolNameMatchResults)
      {
        try evaluationResultsCheckAndSet(.toolNameMatchResults(toolNameMatchResults))
      }
      if let toolParameterKeyMatchResults = try container.decodeIfPresent(
        ToolParameterKeyMatchResults?.self, forKey: .toolParameterKeyMatchResults)
      {
        try evaluationResultsCheckAndSet(
          .toolParameterKeyMatchResults(toolParameterKeyMatchResults))
      }
      if let toolParameterKvMatchResults = try container.decodeIfPresent(
        ToolParameterKVMatchResults?.self, forKey: .toolParameterKvMatchResults)
      {
        try evaluationResultsCheckAndSet(.toolParameterKvMatchResults(toolParameterKvMatchResults))
      }
      if let cometResult = try container.decodeIfPresent(CometResult?.self, forKey: .cometResult) {
        try evaluationResultsCheckAndSet(.cometResult(cometResult))
      }
      if let metricxResult = try container.decodeIfPresent(
        MetricxResult?.self, forKey: .metricxResult)
      {
        try evaluationResultsCheckAndSet(.metricxResult(metricxResult))
      }
      self.evaluationResults = evaluationResults
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.container(keyedBy: CodingKeys.self)
      try container.encode(self.metricResults, forKey: .metricResults)

      if let choice = self.evaluationResults {
        switch choice {
        case .exactMatchResults(let value):
          try container.encode(value, forKey: .exactMatchResults)
        case .bleuResults(let value):
          try container.encode(value, forKey: .bleuResults)
        case .rougeResults(let value):
          try container.encode(value, forKey: .rougeResults)
        case .fluencyResult(let value):
          try container.encode(value, forKey: .fluencyResult)
        case .coherenceResult(let value):
          try container.encode(value, forKey: .coherenceResult)
        case .safetyResult(let value):
          try container.encode(value, forKey: .safetyResult)
        case .groundednessResult(let value):
          try container.encode(value, forKey: .groundednessResult)
        case .fulfillmentResult(let value):
          try container.encode(value, forKey: .fulfillmentResult)
        case .summarizationQualityResult(let value):
          try container.encode(value, forKey: .summarizationQualityResult)
        case .pairwiseSummarizationQualityResult(let value):
          try container.encode(value, forKey: .pairwiseSummarizationQualityResult)
        case .summarizationHelpfulnessResult(let value):
          try container.encode(value, forKey: .summarizationHelpfulnessResult)
        case .summarizationVerbosityResult(let value):
          try container.encode(value, forKey: .summarizationVerbosityResult)
        case .questionAnsweringQualityResult(let value):
          try container.encode(value, forKey: .questionAnsweringQualityResult)
        case .pairwiseQuestionAnsweringQualityResult(let value):
          try container.encode(value, forKey: .pairwiseQuestionAnsweringQualityResult)
        case .questionAnsweringRelevanceResult(let value):
          try container.encode(value, forKey: .questionAnsweringRelevanceResult)
        case .questionAnsweringHelpfulnessResult(let value):
          try container.encode(value, forKey: .questionAnsweringHelpfulnessResult)
        case .questionAnsweringCorrectnessResult(let value):
          try container.encode(value, forKey: .questionAnsweringCorrectnessResult)
        case .pointwiseMetricResult(let value):
          try container.encode(value, forKey: .pointwiseMetricResult)
        case .pairwiseMetricResult(let value):
          try container.encode(value, forKey: .pairwiseMetricResult)
        case .toolCallValidResults(let value):
          try container.encode(value, forKey: .toolCallValidResults)
        case .toolNameMatchResults(let value):
          try container.encode(value, forKey: .toolNameMatchResults)
        case .toolParameterKeyMatchResults(let value):
          try container.encode(value, forKey: .toolParameterKeyMatchResults)
        case .toolParameterKvMatchResults(let value):
          try container.encode(value, forKey: .toolParameterKvMatchResults)
        case .cometResult(let value):
          try container.encode(value, forKey: .cometResult)
        case .metricxResult(let value):
          try container.encode(value, forKey: .metricxResult)
        }
      }
    }

    /// Evaluation results will be served in the same order as presented in
    /// EvaluationRequest.instances.
    public enum OneOf_EvaluationResults: Codable, Equatable, Sendable {
      /// Auto metric evaluation results.
      /// Results for exact match metric.
      indirect case exactMatchResults(ExactMatchResults?)
      /// Results for bleu metric.
      indirect case bleuResults(BleuResults?)
      /// Results for rouge metric.
      indirect case rougeResults(RougeResults?)
      /// LLM-based metric evaluation result.
      /// General text generation metrics, applicable to other categories.
      /// Result for fluency metric.
      indirect case fluencyResult(FluencyResult?)
      /// Result for coherence metric.
      indirect case coherenceResult(CoherenceResult?)
      /// Result for safety metric.
      indirect case safetyResult(SafetyResult?)
      /// Result for groundedness metric.
      indirect case groundednessResult(GroundednessResult?)
      /// Result for fulfillment metric.
      indirect case fulfillmentResult(FulfillmentResult?)
      /// Summarization only metrics.
      /// Result for summarization quality metric.
      indirect case summarizationQualityResult(SummarizationQualityResult?)
      /// Result for pairwise summarization quality metric.
      indirect case pairwiseSummarizationQualityResult(PairwiseSummarizationQualityResult?)
      /// Result for summarization helpfulness metric.
      indirect case summarizationHelpfulnessResult(SummarizationHelpfulnessResult?)
      /// Result for summarization verbosity metric.
      indirect case summarizationVerbosityResult(SummarizationVerbosityResult?)
      /// Question answering only metrics.
      /// Result for question answering quality metric.
      indirect case questionAnsweringQualityResult(QuestionAnsweringQualityResult?)
      /// Result for pairwise question answering quality metric.
      indirect case pairwiseQuestionAnsweringQualityResult(PairwiseQuestionAnsweringQualityResult?)
      /// Result for question answering relevance metric.
      indirect case questionAnsweringRelevanceResult(QuestionAnsweringRelevanceResult?)
      /// Result for question answering helpfulness metric.
      indirect case questionAnsweringHelpfulnessResult(QuestionAnsweringHelpfulnessResult?)
      /// Result for question answering correctness metric.
      indirect case questionAnsweringCorrectnessResult(QuestionAnsweringCorrectnessResult?)
      /// Generic metrics.
      /// Result for pointwise metric.
      indirect case pointwiseMetricResult(PointwiseMetricResult?)
      /// Result for pairwise metric.
      indirect case pairwiseMetricResult(PairwiseMetricResult?)
      /// Tool call metrics.
      ///  Results for tool call valid metric.
      indirect case toolCallValidResults(ToolCallValidResults?)
      /// Results for tool name match metric.
      indirect case toolNameMatchResults(ToolNameMatchResults?)
      /// Results for tool parameter key match  metric.
      indirect case toolParameterKeyMatchResults(ToolParameterKeyMatchResults?)
      /// Results for tool parameter key value match metric.
      indirect case toolParameterKvMatchResults(ToolParameterKVMatchResults?)
      /// Translation metrics.
      /// Result for Comet metric.
      indirect case cometResult(CometResult?)
      /// Result for Metricx metric.
      indirect case metricxResult(MetricxResult?)
    }

    public static var _anyTypeUrl: Swift.String {
      return "type.googleapis.com/google.cloud.aiplatform.v1.EvaluateInstancesResponse"
    }
    public init(fromAny any: GoogleCloudWkt.`Any`) throws {
      self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
    }
    public func _pack() throws -> GoogleCloudWkt.Struct {
      return try GoogleCloudWkt._slowAnySerialize(message: self)
    }
  }
#endif
