package org.studiorailgun.ai.conversation.evaluators.opener;

import org.studiorailgun.ai.conversation.evaluators.goal.GoalData;
import org.studiorailgun.ai.conversation.tracking.Conversation;
import org.studiorailgun.ai.conversation.tracking.Sentence;

/**
 * Conversation opener synthesis evaluation
 */
public class OpenerSynthesis {
    
    /**
     * Synthesizes a conversation opener question
     * @param conversation The conversation
     * @return The quote
     */
    public static Sentence synthesize(Conversation conversation){
        Sentence response = null;
        GoalData goalData = conversation.getGoalData();
        switch(goalData.getGoal()){
            case OPENER: {
                if(OpenerSynthesis.shouldQueryProfileInfo(conversation)){
                    response = OpenerSynthesis.synthesizeProfileInfoQuery(conversation);
                } else {
                    throw new Error("Unhandled opener state");
                }
            } break;
            case ANSWER:
            case GREET: {
                throw new Error("Unsupported goal type for information transfer! " + goalData.getGoal());
            }
        }
        return response;
    }

    /**
     * Check if the first question we want to ask is profile information
     * @param conversation The conversation
     * @return true if should query for conversation information, false otherwise
     */
    private static boolean shouldQueryProfileInfo(Conversation conversation){
        return true;
    }

    /**
     * Synthesizes a query for profile information about a character
     * @param conversation The conversation
     * @return The query sentence
     */
    private static Sentence synthesizeProfileInfoQuery(Conversation conversation){
        return new Sentence("Who are you?");
    }

}
