All files / kernel-language-model-service/src/ollama parse.ts

100% Statements 4/4
100% Branches 2/2
100% Functions 1/1
100% Lines 4/4

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                        3x     15x 15x 15x    
import { assert } from '@metamask/superstruct';
 
import type { ModelInfo } from '../types.ts';
import { OllamaInstanceConfigStruct } from './types.ts';
import type { OllamaInstanceConfig, OllamaModelOptions } from './types.ts';
 
/**
 * Parse the Ollama model configuration.
 *
 * @param config - The configuration to parse.
 * @returns The model info struct describing an Ollama model.
 */
export const parseModelConfig = (
  config: OllamaInstanceConfig,
): ModelInfo<OllamaModelOptions> => {
  assert(config, OllamaInstanceConfigStruct);
  const { model, options } = config;
  return options ? { model, options } : { model };
};