All files / features / llm-configs LlmConfigsListPage.tsx

52.77% Statements 19/36
40% Branches 8/20
50% Functions 5/10
61.29% Lines 19/31

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 61 62      54x     14x 14x               32x                                             32x 32x 32x                       14x               14x  
import { Outlet } from 'react-router-dom'
import { Page, DataTable, Crud } from '@/layers/L2R'
import type { PageConfig, ListConfig, CrudConfig } from '@/layers/interfaces'
import { LLM_CONFIG_FIELD_SET, LLM_CONFIG_FIELD_TYPES } from './llmConfigsCrudConfig'
 
export function LlmConfigsListPage() {
  const pageConfig: PageConfig = { title: 'LLM Provider Config' }
 
  const listConfig: ListConfig = {
    entityPath: 'llm-configs',
    prefix: 'llm',
    columns: [
      {
        field: 'name',
        label: 'Name',
        sortable: true,
        render: (row) => <a href={`#/llm-configs/${row.id}`}>{row.name as string}</a>,
      },
      {
        field: 'model',
        label: 'Default Model',
        sortable: true,
      },
      {
        field: 'base_url',
        label: 'Base URL',
        sortable: true,
      },
      {
        field: 'default_temperature',
        label: 'Temperature',
        render: (row) => {
          const val = row.default_temperature
          if (val === undefined || val === null) return '\u2014'
          return String(val)
        },
      },
    ],
    sort: { field: 'name', order: 'asc' },
    cIreateTarget: '/llm-configs/add',
    createLabel: '+ Add Provider',
    rowTarget: '/llm-configs/:id',
  }
 
  const crudConfig: CrudConfig = {
    entityPath: 'llm-configs',
    fieldSet: LLM_CONFIG_FIELD_SET,
    fieldTypes: LLM_CONFIG_FIELD_TYPES,
    successTarget: '/llm-configs/:id',
    cancelTarget: '/llm-configs',
    title: 'Add LLM Provider',
  }
 
  return (
    <Page config={pageConfig}>
      <DataTable config={listConfig} />
      <Crud config={crudConfig} />
      <Outlet />
    </Page>
  )
}