package com.odde.doughnut.services.ai.tools;

import com.odde.doughnut.services.ai.*;
import com.theokanning.openai.completion.chat.ChatFunction;
import java.util.List;

public class AiToolFactory {

  public static final String COMPLETE_NOTE_DETAILS = "complete_note_details";

  public static AiToolList mcqWithAnswerAiTool() {
    return new AiToolList(
        """
      Please assume the role of a Memory Assistant, which involves helping me review, recall, and reinforce information from my notes. As a Memory Assistant, focus on creating exercises that stimulate memory and comprehension. Please adhere to the following guidelines:

      1. Generate a MCQ based on the note in the current context path
      2. Only the top-level of the context path is visible to the user.
      3. Provide 2 to 4 choices with only 1 correct answer.
      4. Vary the lengths of the choice texts so that the correct answer isn't consistently the longest.
      5. If there's insufficient information in the note to create a question, leave the 'stem' field empty.

      Note: The specific note of focus and its more detailed contexts are not known. Focus on memory reinforcement and recall across various subjects.
      """,
        List.of(
            ChatFunction.builder()
                .name("ask_single_answer_multiple_choice_question")
                .description("Ask a single-answer multiple-choice question to the user")
                .executor(MCQWithAnswer.class, null)
                .build()));
  }

  public static AiToolList questionEvaluationAiTool(MCQWithAnswer question) {
    MultipleChoicesQuestion clone = question.getMultipleChoicesQuestion();

    String messageBody =
        """
Please assume the role of a learner, who has learned the note of focus as well as many other notes.
Only the top-level of the context path is visible to you.
Without the specific note of focus and its more detailed contexts revealed to you,
please critically check if the following question makes sense and is possible to you:

%s

"""
            .formatted(clone.toJsonString());

    return new AiToolList(
        messageBody,
        List.of(
            ChatFunction.builder()
                .name("evaluate_question")
                .description("answer and evaluate the feasibility of the question")
                .executor(QuestionEvaluation.class, null)
                .build()));
  }
}

com.theokanning.openai.completion.chat.ChatFunction.builder
[((1248, 1505), 'com.theokanning.openai.completion.chat.ChatFunction.builder'), ((1248, 1480), 'com.theokanning.openai.completion.chat.ChatFunction.builder'), ((1248, 1427), 'com.theokanning.openai.completion.chat.ChatFunction.builder'), ((1248, 1338), 'com.theokanning.openai.completion.chat.ChatFunction.builder'), ((2165, 2397), 'com.theokanning.openai.completion.chat.ChatFunction.builder'), ((2165, 2372), 'com.theokanning.openai.completion.chat.ChatFunction.builder'), ((2165, 2314), 'com.theokanning.openai.completion.chat.ChatFunction.builder'), ((2165, 2230), 'com.theokanning.openai.completion.chat.ChatFunction.builder')]