1+ import { Col , Layout , Row , Table } from "antd" ;
2+ import { Content } from "antd/es/layout/layout" ;
3+ import styled from "styled-components" ;
4+ import { useModelProviders } from "./hooks" ;
5+ import get from "lodash/get" ;
6+ import { sortItemsByKey } from "../../utils/sortutils" ;
7+ import Paragraph from "antd/es/typography/Paragraph" ;
8+ import { render } from "@testing-library/react" ;
9+ import StyledTitle from "../Evaluator/StyledTitle" ;
10+
11+
12+
13+ const StyledContent = styled ( Content ) `
14+ padding: 24px;
15+ background-color: #f5f7f8;
16+ ` ;
17+
18+ interface CAIIModel {
19+ model : string ;
20+ endpoint : string ;
21+ }
22+
23+ interface Model {
24+ name : string ;
25+ }
26+
27+ const StyledTable = styled ( Table ) `
28+ font-family: Roboto, -apple-system, 'Segoe UI', sans-serif;
29+ color: #5a656d;
30+ .ant-table-thead > tr > th {
31+ color: #5a656d;
32+ border-bottom: 1px solid #eaebec;
33+ font-weight: 500;
34+ text-align: left;
35+ // background: #ffffff;
36+ border-bottom: 1px solid #eaebec;
37+ transition: background 0.3s ease;
38+ }
39+ .ant-table-row > td.ant-table-cell {
40+ padding: 8px;
41+ padding-left: 16px;
42+ font-size: 13px;
43+ font-family: Roboto, -apple-system, 'Segoe UI', sans-serif;
44+ color: #5a656d;
45+ .ant-typography {
46+ font-size: 13px;
47+ font-family: Roboto, -apple-system, 'Segoe UI', sans-serif;
48+ }
49+ }
50+ ` ;
51+
52+ const StyledParagraph = styled ( Paragraph ) `
53+ font-size: 13px;
54+ font-family: Roboto, -apple-system, 'Segoe UI', sans-serif;
55+ color: #5a656d;
56+ ` ;
57+
58+ const SettingsPage : React . FC = ( ) => {
59+ const filteredModelsReq = useModelProviders ( ) ;
60+ console . log ( 'filteredModelsReq' , filteredModelsReq ) ;
61+
62+ const caiiModels = get ( filteredModelsReq , 'data.models.CAII.enabled' , [ ] ) ;
63+ const awsModels = get ( filteredModelsReq , 'data.models.aws_bedrock.enabled' , [ ] ) ;
64+ const models = awsModels . map ( ( model : string ) => ( {
65+ name : model
66+ } ) )
67+
68+ const modelProvidersColumns = [ {
69+ key : 'model' ,
70+ title : 'Model' ,
71+ dataIndex : 'model' ,
72+ width : 200 ,
73+ sorter : sortItemsByKey ( 'model' )
74+ } , {
75+ key : 'endpoint' ,
76+ title : 'Endpoint' ,
77+ dataIndex : 'endpoint' ,
78+ width : 300 ,
79+ sorter : sortItemsByKey ( 'endpoint' ) ,
80+ render : ( endpoint : string ) => < StyledParagraph style = { { width : 200 , marginBottom : 0 } } ellipsis = { { rows : 1 } } > { endpoint } </ StyledParagraph >
81+ } ] ;
82+
83+
84+ const modelColumns = [ {
85+ key : 'model' ,
86+ title : 'Model' ,
87+ dataIndex : 'model' ,
88+ width : 200 ,
89+ sorter : sortItemsByKey ( 'model' )
90+ } ] ;
91+
92+ return (
93+ < Layout >
94+ < StyledContent >
95+ < Row >
96+ < Col sm = { 24 } >
97+ < StyledTitle style = { { fontWeight : 400 } } > { 'Models' } </ StyledTitle >
98+ < StyledTable
99+ rowKey = { ( row : Model ) => `${ row ?. model } ` }
100+ tableLayout = "fixed"
101+ columns = { modelColumns }
102+ dataSource = { caiiModels || [ ] as Model [ ] } />
103+ </ Col >
104+ </ Row >
105+ < Row >
106+ < Col sm = { 24 } >
107+ < StyledTitle style = { { fontWeight : 400 } } > { 'CAII Models' } </ StyledTitle >
108+ < StyledTable
109+ rowKey = { ( row : CAIIModel ) => `${ row ?. model } ` }
110+ tableLayout = "fixed"
111+ columns = { modelProvidersColumns }
112+ dataSource = { caiiModels || [ ] as CAIIModel [ ] } />
113+ </ Col >
114+ </ Row >
115+ </ StyledContent >
116+ </ Layout >
117+ ) ;
118+
119+ }
120+
121+ export default SettingsPage ;
0 commit comments