예제 #1
0
        internal static BasePrediction DeserializeBasePrediction(JsonElement element)
        {
            if (element.TryGetProperty("projectKind", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "Orchestration": return(OrchestrationPrediction.DeserializeOrchestrationPrediction(element));

                case "Conversation": return(ConversationPrediction.DeserializeConversationPrediction(element));
                }
            }
            ProjectKind       projectKind = default;
            Optional <string> topIntent   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("projectKind"))
                {
                    projectKind = new ProjectKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("topIntent"))
                {
                    topIntent = property.Value.GetString();
                    continue;
                }
            }
            return(new BasePrediction(projectKind, topIntent.Value));
        }
예제 #2
0
        internal static ConversationResult DeserializeConversationResult(JsonElement element)
        {
            string                 query            = default;
            Optional <string>      detectedLanguage = default;
            ConversationPrediction prediction       = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("query"))
                {
                    query = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("detectedLanguage"))
                {
                    detectedLanguage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("prediction"))
                {
                    prediction = ConversationPrediction.DeserializeConversationPrediction(property.Value);
                    continue;
                }
            }
            return(new ConversationResult(query, detectedLanguage.Value, prediction));
        }
        internal ConversationResult(string query, ConversationPrediction prediction)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (prediction == null)
            {
                throw new ArgumentNullException(nameof(prediction));
            }

            Query      = query;
            Prediction = prediction;
        }
예제 #4
0
 internal ConversationResult(string query, string detectedLanguage, ConversationPrediction prediction)
 {
     Query            = query;
     DetectedLanguage = detectedLanguage;
     Prediction       = prediction;
 }
예제 #5
0
 public static ConversationResult ConversationResult(string query = null, string detectedLanguage = null, ConversationPrediction prediction = null)
 {
     return(new ConversationResult(query, detectedLanguage, prediction));
 }