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 >
@@ -162,49 +205,97 @@ const AddModelProviderButton: React.FC<Props> = ({ refetch }) => {
162205 < Input />
163206 </ Form . Item >
164207 < Form . Item
165- name = "endpoint_id "
166- label = "Endpoint ID"
208+ name = "model_id "
209+ label = "Model"
167210 rules = { [
168211 {
169212 required : true ,
170213 message : 'This field is required.'
171214 }
172215 ] } >
173- < Input />
216+ < AutoComplete
217+ autoFocus
218+ showSearch
219+ allowClear
220+ options = { [
221+ { label : < strong > { 'Enter Model Name ' } </ strong > , value : '' }
222+ ] . concat (
223+ models
224+ ) }
225+ placeholder = { 'Select Model' }
226+ />
174227 </ Form . Item >
175- < Form . Item
176- name = "model_id"
177- label = "Model"
228+
229+ { modelProviderType !== ModelProviderType . OPENAI && modelProviderType !== ModelProviderType . GEMINI && < Form . Item
230+ name = "endpoint_url"
231+ label = "Endpoint URL"
232+ rules = { [
233+ {
234+ required : true ,
235+ message : 'This field is required.'
236+ }
237+ ] } >
238+ < Input />
239+ </ Form . Item > }
240+ { modelProviderType !== ModelProviderType . AWS_BEDROCK && modelProviderType !== ModelProviderType . CAII && < Form . Item
241+ name = "api_key"
242+ label = "API Key"
178243 rules = { [
179244 {
180245 required : true ,
181246 message : 'This field is required.'
182247 }
183248 ] } >
184- < Select options = { models } />
249+ < Input . Password />
250+ </ Form . Item > }
251+ { modelProviderType === ModelProviderType . CAII && < Form . Item
252+ name = "cdp_token"
253+ label = "CDP Token"
254+ rules = { [
255+ {
256+ required : true ,
257+ message : 'This field is required.'
258+ }
259+ ] } >
260+ < Input . Password />
261+ </ Form . Item > }
262+ { modelProviderType === ModelProviderType . AWS_BEDROCK &&
263+ < >
264+ < Form . Item
265+ name = "aws_access_key_id:"
266+ label = "Access Key"
267+ rules = { [
268+ {
269+ required : true ,
270+ message : 'This field is required.'
271+ }
272+ ] } >
273+ < Input . Password />
185274 </ Form . Item >
186275 < Form . Item
187- name = "endpoint_url "
188- label = "Endpoint URL"
276+ name = "aws_secret_access_key: "
277+ label = "Secret Key"
189278 rules = { [
190279 {
191280 required : true ,
192281 message : 'This field is required.'
193282 }
194283 ] } >
195- < Input />
284+ < Input . Password />
196285 </ Form . Item >
197286 < Form . Item
198- name = "api_key "
199- label = "API Key "
287+ name = "region: "
288+ label = "Region "
200289 rules = { [
201290 {
202291 required : true ,
203292 message : 'This field is required.'
204293 }
205294 ] } >
206- < Input . Password />
295+ < Input />
207296 </ Form . Item >
297+ </ >
298+ }
208299 </ Form >
209300 </ Modal > }
210301 </ >
0 commit comments