Enum Class TaskType

java.lang.Object
java.lang.Enum<TaskType>
com.tnsai.llm.routing.TaskType
All Implemented Interfaces:
Serializable, Comparable<TaskType>, Constable

public enum TaskType extends Enum<TaskType>
Defines task types for intelligent model routing.

TaskType enables task-based model selection, where different LLM models are automatically selected based on what they're best at. For example:

  • Coding tasks → Models optimized for code (e.g., Claude Sonnet, GPT-4o)
  • Creative tasks → Models good at creative writing
  • Math tasks → Models with strong reasoning (e.g., o1, Gemini)
  • Fast tasks → Quick, cheap models (e.g., GPT-4o-mini, Groq)

Usage with TaskBasedRouter


 TaskBasedRouter router = TaskBasedRouter.builder()
     .forTask(TaskType.CODING, new AnthropicClient("claude-sonnet-4"))
     .forTask(TaskType.CREATIVE, new OpenAIClient("gpt-4o"))
     .forTask(TaskType.MATH, new OpenAIClient("o1-preview"))
     .forTask(TaskType.FAST, new GroqClient("llama-3.3-70b"))
     .defaultClient(new OpenAIClient("gpt-4o-mini"))
     .build();

 // Auto-classification
 router.chat("Write a Python function to sort a list");  // → CODING → Claude
 router.chat("Write a poem about autumn");               // → CREATIVE → GPT-4o
 router.chat("Solve: 2x + 5 = 15");                      // → MATH → o1
 
See Also:
  • Enum Constant Details

    • CODING

      public static final TaskType CODING
      Code generation, debugging, refactoring, code review. Best models: Claude Sonnet, GPT-4o, Codestral
    • CREATIVE

      public static final TaskType CREATIVE
      Creative writing, storytelling, poetry, marketing copy. Best models: GPT-4o, Claude Opus
    • MATH

      public static final TaskType MATH
      Mathematical reasoning, calculations, proofs. Best models: o1, Gemini 2.0, Claude with CoT
    • ANALYSIS

      public static final TaskType ANALYSIS
      Data analysis, summarization, extraction. Best models: GPT-4o, Gemini, Claude
    • TRANSLATION

      public static final TaskType TRANSLATION
      Language translation between languages. Best models: GPT-4o, Gemini, specialized translation models
    • CHAT

      public static final TaskType CHAT
      Conversational, Qinvalid input: '&A', general knowledge. Best models: Any capable model
    • FAST

      public static final TaskType FAST
      Quick, simple tasks that need fast responses. Best models: GPT-4o-mini, Groq, Gemini Flash
    • REASONING

      public static final TaskType REASONING
      Tasks requiring deep reasoning and thinking. Best models: o1, o1-pro, Claude with extended thinking
    • VISION

      public static final TaskType VISION
      Image understanding and visual tasks. Best models: GPT-4o, Gemini, Claude (vision-capable)
    • GENERAL

      public static final TaskType GENERAL
      Default/fallback for unclassified tasks.
  • Method Details

    • values

      public static TaskType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static TaskType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getId

      public String getId()
      Returns the task type identifier.
    • getKeywords

      public Set<String> getKeywords()
      Returns keywords associated with this task type.
    • matches

      public boolean matches(String text)
      Checks if the given text contains keywords for this task type.
      Parameters:
      text - The text to check
      Returns:
      true if any keyword matches
    • matchScore

      public int matchScore(String text)
      Calculates a match score for the given text.
      Parameters:
      text - The text to score
      Returns:
      Number of matching keywords (higher = better match)
    • fromId

      public static TaskType fromId(String id)
      Finds TaskType by id.