Package com.tnsai.llm.routing
Enum Class TaskType
- All Implemented Interfaces:
Serializable,Comparable<TaskType>,Constable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionData analysis, summarization, extraction.Conversational, Qinvalid input: '&A', general knowledge.Code generation, debugging, refactoring, code review.Creative writing, storytelling, poetry, marketing copy.Quick, simple tasks that need fast responses.Default/fallback for unclassified tasks.Mathematical reasoning, calculations, proofs.Tasks requiring deep reasoning and thinking.Language translation between languages.Image understanding and visual tasks. -
Method Summary
Modifier and TypeMethodDescriptionstatic TaskTypeFinds TaskType by id.getId()Returns the task type identifier.Returns keywords associated with this task type.booleanChecks if the given text contains keywords for this task type.intmatchScore(String text) Calculates a match score for the given text.static TaskTypeReturns the enum constant of this class with the specified name.static TaskType[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
CODING
Code generation, debugging, refactoring, code review. Best models: Claude Sonnet, GPT-4o, Codestral -
CREATIVE
Creative writing, storytelling, poetry, marketing copy. Best models: GPT-4o, Claude Opus -
MATH
Mathematical reasoning, calculations, proofs. Best models: o1, Gemini 2.0, Claude with CoT -
ANALYSIS
Data analysis, summarization, extraction. Best models: GPT-4o, Gemini, Claude -
TRANSLATION
Language translation between languages. Best models: GPT-4o, Gemini, specialized translation models -
CHAT
Conversational, Qinvalid input: '&A', general knowledge. Best models: Any capable model -
FAST
Quick, simple tasks that need fast responses. Best models: GPT-4o-mini, Groq, Gemini Flash -
REASONING
Tasks requiring deep reasoning and thinking. Best models: o1, o1-pro, Claude with extended thinking -
VISION
Image understanding and visual tasks. Best models: GPT-4o, Gemini, Claude (vision-capable) -
GENERAL
Default/fallback for unclassified tasks.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
getId
Returns the task type identifier. -
getKeywords
Returns keywords associated with this task type. -
matches
Checks if the given text contains keywords for this task type.- Parameters:
text- The text to check- Returns:
- true if any keyword matches
-
matchScore
Calculates a match score for the given text.- Parameters:
text- The text to score- Returns:
- Number of matching keywords (higher = better match)
-
fromId
Finds TaskType by id.
-