11import { useEffect , useState } from 'react' ;
22import { PlusCircleOutlined } from '@ant-design/icons' ;
3- import { Alert , Button , Form , Input , Modal , notification , Radio , Select } from 'antd' ;
3+ import { Alert , AutoComplete , Button , Form , Input , Modal , notification , Radio , Select } from 'antd' ;
44import type { CheckboxGroupProps } from 'antd/es/checkbox' ;
55import get from 'lodash/get' ;
66import isEqual from 'lodash/isEqual' ;
@@ -10,15 +10,19 @@ import Loading from '../Evaluator/Loading';
1010
1111export enum ModelProviderType {
1212 OPENAI = 'openai' ,
13+ OPENAI_COMPATIBLE = 'openai_compatible' ,
1314 GEMINI = 'gemini' ,
14- CAII = 'caii'
15+ CAII = 'caii' ,
16+ AWS_BEDROCK = 'aws_bedrock'
1517}
1618
1719
18- const modelProviderTypeOptions : CheckboxGroupProps < string > [ 'options' ] = [
20+ export const modelProviderTypeOptions : CheckboxGroupProps < string > [ 'options' ] = [
1921 { label : 'OpenAI' , value : 'openai' } ,
20- // { label: 'CAII ', value: 'caii ' },
22+ { label : 'OpenAI Compatible ' , value : 'openai_compatible ' } ,
2123 { label : 'Gemini' , value : 'gemini' } ,
24+ { label : 'AWS Bedrock' , value : 'aws_bedrock' } ,
25+ { label : 'CAII' , value : 'caii' } ,
2226] ;
2327
2428const OPENAI_MODELS = [
@@ -27,7 +31,7 @@ const OPENAI_MODELS = [
2731 "gpt-4.1-nano"
2832] ;
2933
30- const OPENAI_MODELS_OPTIONS = OPENAI_MODELS . map ( ( model : string ) => ( {
34+ export const OPENAI_MODELS_OPTIONS = OPENAI_MODELS . map ( ( model : string ) => ( {
3135 label : model ,
3236 value : model
3337} ) ) ;
@@ -38,7 +42,42 @@ const GEMINI_MODELS = [
3842 "gemini-2.5-flash-lite" // June 2025 - cost-efficient
3943] ;
4044
41- const GEMINI_MODELS_OPTIONS = GEMINI_MODELS . map ( ( model : string ) => ( {
45+ export const AWS_BEDROCK_MODELS = [
46+ "us.anthropic.claude-3-5-sonnet-20241022-v2:0" ,
47+ "us.anthropic.claude-sonnet-4-5-20250929-v1:0" ,
48+ "us.anthropic.claude-opus-4-1-20250805-v1:0" ,
49+ "us.anthropic.claude-opus-4-20250514-v1:0" ,
50+ "global.anthropic.claude-sonnet-4-20250514-v1:0" ,
51+ "us.anthropic.claude-3-7-sonnet-20250219-v1:0" ,
52+ "us.anthropic.claude-3-5-haiku-20241022-v1:0" ,
53+ "anthropic.claude-3-5-sonnet-20240620-v1:0" ,
54+ "anthropic.claude-3-haiku-20240307-v1:0" ,
55+ "anthropic.claude-3-sonnet-20240229-v1:0" ,
56+ "us.anthropic.claude-3-opus-20240229-v1:0" ,
57+ "meta.llama3-8b-instruct-v1:0" ,
58+ "meta.llama3-70b-instruct-v1:0" ,
59+ "mistral.mistral-large-2402-v1:0" ,
60+ "mistral.mistral-small-2402-v1:0" ,
61+ "us.meta.llama3-2-11b-instruct-v1:0" ,
62+ "us.meta.llama3-2-3b-instruct-v1:0" ,
63+ "us.meta.llama3-2-90b-instruct-v1:0" ,
64+ "us.meta.llama3-2-1b-instruct-v1:0" ,
65+ "us.meta.llama3-1-8b-instruct-v1:0" ,
66+ "us.meta.llama3-1-70b-instruct-v1:0" ,
67+ "us.meta.llama3-3-70b-instruct-v1:0" ,
68+ "us.mistral.pixtral-large-2502-v1:0" ,
69+ "us.meta.llama4-scout-17b-instruct-v1:0" ,
70+ "us.meta.llama4-maverick-17b-instruct-v1:0" ,
71+ "mistral.mistral-7b-instruct-v0:2" ,
72+ "mistral.mixtral-8x7b-instruct-v0:1"
73+ ] ;
74+
75+ export const AWS_BEDROCK_MODELS_OPTIONS = AWS_BEDROCK_MODELS . map ( ( model : string ) => ( {
76+ label : model ,
77+ value : model
78+ } ) ) ;
79+
80+ export const GEMINI_MODELS_OPTIONS = GEMINI_MODELS . map ( ( model : string ) => ( {
4281 label : model ,
4382 value : model
4483} ) ) ;
@@ -50,6 +89,7 @@ interface Props {
5089const AddModelProviderButton : React . FC < Props > = ( { refetch } ) => {
5190 const [ form ] = Form . useForm ( ) ;
5291 const [ showModal , setShowModal ] = useState ( false ) ;
92+ const [ modelProviderType , setModelProviderType ] = useState < ModelProviderType > ( ModelProviderType . OPENAI ) ;
5393 const [ models , setModels ] = useState ( OPENAI_MODELS_OPTIONS ) ;
5494 const mutation = useMutation ( {
5595 mutationFn : addModelProvider
@@ -106,10 +146,13 @@ const AddModelProviderButton: React.FC<Props> = ({ refetch }) => {
106146
107147 const onChange = ( e : any ) => {
108148 const value = get ( e , 'target.value' ) ;
149+ setModelProviderType ( value as ModelProviderType ) ;
109150 if ( value === 'openai' && ! isEqual ( OPENAI_MODELS_OPTIONS , models ) ) {
110151 setModels ( OPENAI_MODELS_OPTIONS ) ;
111152 } else if ( value === 'gemini' && ! isEqual ( GEMINI_MODELS_OPTIONS , models ) ) {
112153 setModels ( GEMINI_MODELS_OPTIONS ) ;
154+ } else if ( value === 'aws_bedrock' && ! isEqual ( GEMINI_MODELS_OPTIONS , models ) ) {
155+ setModels ( AWS_BEDROCK_MODELS_OPTIONS ) ;
113156 }
114157 }
115158
@@ -146,7 +189,7 @@ const AddModelProviderButton: React.FC<Props> = ({ refetch }) => {
146189 defaultValue = "openai"
147190 optionType = "button"
148191 buttonStyle = "solid"
149- style = { { width : '40% ' } }
192+ style = { { width : '100%' , whiteSpace : 'nowrap ' } }
150193 onChange = { onChange }
151194 />
152195 </ Form . Item >
@@ -161,17 +204,17 @@ const AddModelProviderButton: React.FC<Props> = ({ refetch }) => {
161204 ] } >
162205 < Input />
163206 </ Form . Item >
164- < Form . Item
165- name = "endpoint_id"
166- label = "Endpoint ID"
167- rules = { [
207+ { /* <Form.Item
208+ name="endpoint_id"
209+ label="Endpoint ID"
210+ rules={[
168211 {
169212 required: true,
170213 message: 'This field is required.'
171214 }
172215 ]}>
173216 <Input />
174- </ Form . Item >
217+ </Form.Item> */ }
175218 < Form . Item
176219 name = "model_id"
177220 label = "Model"
@@ -181,9 +224,20 @@ const AddModelProviderButton: React.FC<Props> = ({ refetch }) => {
181224 message : 'This field is required.'
182225 }
183226 ] } >
184- < Select options = { models } />
227+ < AutoComplete
228+ autoFocus
229+ showSearch
230+ allowClear
231+ options = { [
232+ { label : < strong > { 'Enter Model Name ' } </ strong > , value : '' }
233+ ] . concat (
234+ models
235+ ) }
236+ placeholder = { 'Select Model' }
237+ />
185238 </ Form . Item >
186- < Form . Item
239+
240+ { modelProviderType !== ModelProviderType . OPENAI && modelProviderType !== ModelProviderType . GEMINI && < Form . Item
187241 name = "endpoint_url"
188242 label = "Endpoint URL"
189243 rules = { [
@@ -193,8 +247,8 @@ const AddModelProviderButton: React.FC<Props> = ({ refetch }) => {
193247 }
194248 ] } >
195249 < Input />
196- </ Form . Item >
197- < Form . Item
250+ </ Form . Item > }
251+ { modelProviderType !== ModelProviderType . AWS_BEDROCK && modelProviderType !== ModelProviderType . CAII && < Form . Item
198252 name = "api_key"
199253 label = "API Key"
200254 rules = { [
@@ -204,7 +258,55 @@ const AddModelProviderButton: React.FC<Props> = ({ refetch }) => {
204258 }
205259 ] } >
206260 < Input . Password />
261+ </ Form . Item > }
262+ { modelProviderType === ModelProviderType . CAII && < Form . Item
263+ name = "cdp_token"
264+ label = "CDP Token"
265+ rules = { [
266+ {
267+ required : true ,
268+ message : 'This field is required.'
269+ }
270+ ] } >
271+ < Input . Password />
272+ </ Form . Item > }
273+ { modelProviderType === ModelProviderType . AWS_BEDROCK &&
274+ < >
275+ < Form . Item
276+ name = "aws_access_key_id:"
277+ label = "Access Key"
278+ rules = { [
279+ {
280+ required : true ,
281+ message : 'This field is required.'
282+ }
283+ ] } >
284+ < Input . Password />
285+ </ Form . Item >
286+ < Form . Item
287+ name = "aws_secret_access_key:"
288+ label = "Secret Key"
289+ rules = { [
290+ {
291+ required : true ,
292+ message : 'This field is required.'
293+ }
294+ ] } >
295+ < Input . Password />
296+ </ Form . Item >
297+ < Form . Item
298+ name = "region:"
299+ label = "Region"
300+ rules = { [
301+ {
302+ required : true ,
303+ message : 'This field is required.'
304+ }
305+ ] } >
306+ < Input />
207307 </ Form . Item >
308+ </ >
309+ }
208310 </ Form >
209311 </ Modal > }
210312 </ >
0 commit comments