All files / web/src/composables/agents useAgentModels.ts

0% Statements 0/34
0% Branches 0/1
0% Functions 0/1
0% Lines 0/34

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 55 56 57 58 59 60                                                                                                                       
import { readonly } from 'vue'
import { MODEL_OPTIONS } from '@/constants/node/models'
 
/**
 * Agent models management composable
 * Provides unified model list and helper functions
 */
export function useAgentModels() {
  // Build AVAILABLE_MODELS from MODEL_OPTIONS with supportsTemperature flag
  const AVAILABLE_MODELS = readonly(
    MODEL_OPTIONS.map(option => ({
      label: option.label,
      value: option.value,
      // O-series models don't support temperature
      supportsTemperature: !option.value.startsWith('o')
    }))
  )
 
  const O_SERIES_MODELS = ['o4-mini', 'o3', 'o3-mini']
 
  /**
   * Check if model is O-series
   */
  const isOSeriesModel = (model: string): boolean => {
    return O_SERIES_MODELS.includes(model)
  }
 
  /**
   * Get default temperature for model
   * Returns null for O-series models, 0.7 for others
   */
  const getDefaultTemperature = (model: string): number | null => {
    return isOSeriesModel(model) ? null : 0.7
  }
 
  /**
   * Check if model supports temperature configuration
   */
  const supportsTemperature = (model: string): boolean => {
    const modelInfo = AVAILABLE_MODELS.find(m => m.value === model)
    return modelInfo?.supportsTemperature ?? true
  }
 
  /**
   * Get model display label
   */
  const getModelLabel = (model: string): string => {
    const modelInfo = AVAILABLE_MODELS.find(m => m.value === model)
    return modelInfo?.label || model
  }
 
  return {
    AVAILABLE_MODELS,
    O_SERIES_MODELS,
    isOSeriesModel,
    getDefaultTemperature,
    supportsTemperature,
    getModelLabel
  }
}