All files / api/src/ai-providers/anthropic model-capabilities.ts

100% Statements 33/33
100% Branches 0/0
100% Functions 0/0
100% Lines 33/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54            1x       1x 1x   1x 1x         1x 1x 1x 1x   1x   1x 1x 1x 1x       1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * Anthropic model capabilities configuration.
 *
 * Defines which parameters are supported by different Anthropic models.
 */
 
import {
  ModelParameter,
  type ProviderModelCapabilities,
} from '@shared/types/ai-providers/model-capabilities';
import { FunctionName } from '@shared/types/api/request';
import { AIProvider } from '@shared/types/constants';
 
export const anthropicModelCapabilities: ProviderModelCapabilities = {
  provider: AIProvider.ANTHROPIC,
 
  // Default parameter ranges for Anthropic models
  // Source: https://docs.claude.com/en/api/messages
  // Temperature: 0-1, Top_p: 0-1 (note: cannot use both simultaneously)
  defaultParameterRanges: {
    temperature: { min: 0, max: 1 },
    top_p: { min: 0, max: 1 },
  },
 
  models: [
    // All Claude models have the same restrictions
    {
      modelPattern: /^claude-.+$/,
      endpointConfigs: {
        [FunctionName.CHAT_COMPLETE]: {
          // Anthropic API returns error: "`temperature` and `top_p` cannot both be specified"
          // We disable top_p and keep temperature since temperature is more commonly used/expected
          // Anthropic also doesn't support frequency_penalty, presence_penalty, or reasoning_effort
          unsupportedParameters: [
            ModelParameter.TOP_P,
            ModelParameter.FREQUENCY_PENALTY,
            ModelParameter.PRESENCE_PENALTY,
            ModelParameter.REASONING_EFFORT,
          ],
        },
        [FunctionName.STREAM_CHAT_COMPLETE]: {
          // Same restrictions as chat_complete
          unsupportedParameters: [
            ModelParameter.TOP_P,
            ModelParameter.FREQUENCY_PENALTY,
            ModelParameter.PRESENCE_PENALTY,
            ModelParameter.REASONING_EFFORT,
          ],
        },
      },
    },
  ],
};