|
1 | 1 | import { createLogger } from '@sim/logger' |
2 | 2 | import { ChartBarIcon } from '@/components/icons' |
3 | | -import { isHosted } from '@/lib/core/config/feature-flags' |
4 | 3 | import type { BlockConfig, ParamType } from '@/blocks/types' |
| 4 | +import { getProviderCredentialSubBlocks, PROVIDER_CREDENTIAL_INPUTS } from '@/blocks/utils' |
5 | 5 | import type { ProviderId } from '@/providers/types' |
6 | | -import { |
7 | | - getBaseModelProviders, |
8 | | - getHostedModels, |
9 | | - getProviderIcon, |
10 | | - providers, |
11 | | -} from '@/providers/utils' |
| 6 | +import { getBaseModelProviders, getProviderIcon } from '@/providers/utils' |
12 | 7 | import { useProvidersStore } from '@/stores/providers/store' |
13 | 8 | import type { ToolResponse } from '@/tools/types' |
14 | 9 |
|
15 | 10 | const logger = createLogger('EvaluatorBlock') |
16 | 11 |
|
17 | | -const getCurrentOllamaModels = () => { |
18 | | - return useProvidersStore.getState().providers.ollama.models |
19 | | -} |
20 | | - |
21 | | -const getCurrentVLLMModels = () => { |
22 | | - return useProvidersStore.getState().providers.vllm.models |
23 | | -} |
24 | | - |
25 | 12 | interface Metric { |
26 | 13 | name: string |
27 | 14 | description: string |
@@ -204,91 +191,7 @@ export const EvaluatorBlock: BlockConfig<EvaluatorResponse> = { |
204 | 191 | }) |
205 | 192 | }, |
206 | 193 | }, |
207 | | - { |
208 | | - id: 'vertexCredential', |
209 | | - title: 'Google Cloud Account', |
210 | | - type: 'oauth-input', |
211 | | - serviceId: 'vertex-ai', |
212 | | - requiredScopes: ['https://www.googleapis.com/auth/cloud-platform'], |
213 | | - placeholder: 'Select Google Cloud account', |
214 | | - required: true, |
215 | | - condition: { |
216 | | - field: 'model', |
217 | | - value: providers.vertex.models, |
218 | | - }, |
219 | | - }, |
220 | | - { |
221 | | - id: 'apiKey', |
222 | | - title: 'API Key', |
223 | | - type: 'short-input', |
224 | | - placeholder: 'Enter your API key', |
225 | | - password: true, |
226 | | - connectionDroppable: false, |
227 | | - required: true, |
228 | | - // Hide API key for hosted models, Ollama models, vLLM models, and Vertex models (uses OAuth) |
229 | | - condition: isHosted |
230 | | - ? { |
231 | | - field: 'model', |
232 | | - value: [...getHostedModels(), ...providers.vertex.models], |
233 | | - not: true, // Show for all models EXCEPT those listed |
234 | | - } |
235 | | - : () => ({ |
236 | | - field: 'model', |
237 | | - value: [ |
238 | | - ...getCurrentOllamaModels(), |
239 | | - ...getCurrentVLLMModels(), |
240 | | - ...providers.vertex.models, |
241 | | - ], |
242 | | - not: true, // Show for all models EXCEPT Ollama, vLLM, and Vertex models |
243 | | - }), |
244 | | - }, |
245 | | - { |
246 | | - id: 'azureEndpoint', |
247 | | - title: 'Azure OpenAI Endpoint', |
248 | | - type: 'short-input', |
249 | | - password: true, |
250 | | - placeholder: 'https://your-resource.openai.azure.com', |
251 | | - connectionDroppable: false, |
252 | | - condition: { |
253 | | - field: 'model', |
254 | | - value: providers['azure-openai'].models, |
255 | | - }, |
256 | | - }, |
257 | | - { |
258 | | - id: 'azureApiVersion', |
259 | | - title: 'Azure API Version', |
260 | | - type: 'short-input', |
261 | | - placeholder: '2024-07-01-preview', |
262 | | - connectionDroppable: false, |
263 | | - condition: { |
264 | | - field: 'model', |
265 | | - value: providers['azure-openai'].models, |
266 | | - }, |
267 | | - }, |
268 | | - { |
269 | | - id: 'vertexProject', |
270 | | - title: 'Vertex AI Project', |
271 | | - type: 'short-input', |
272 | | - placeholder: 'your-gcp-project-id', |
273 | | - connectionDroppable: false, |
274 | | - required: true, |
275 | | - condition: { |
276 | | - field: 'model', |
277 | | - value: providers.vertex.models, |
278 | | - }, |
279 | | - }, |
280 | | - { |
281 | | - id: 'vertexLocation', |
282 | | - title: 'Vertex AI Location', |
283 | | - type: 'short-input', |
284 | | - placeholder: 'us-central1', |
285 | | - connectionDroppable: false, |
286 | | - required: true, |
287 | | - condition: { |
288 | | - field: 'model', |
289 | | - value: providers.vertex.models, |
290 | | - }, |
291 | | - }, |
| 194 | + ...getProviderCredentialSubBlocks(), |
292 | 195 | { |
293 | 196 | id: 'temperature', |
294 | 197 | title: 'Temperature', |
@@ -403,21 +306,7 @@ export const EvaluatorBlock: BlockConfig<EvaluatorResponse> = { |
403 | 306 | }, |
404 | 307 | }, |
405 | 308 | model: { type: 'string' as ParamType, description: 'AI model to use' }, |
406 | | - apiKey: { type: 'string' as ParamType, description: 'Provider API key' }, |
407 | | - azureEndpoint: { type: 'string' as ParamType, description: 'Azure OpenAI endpoint URL' }, |
408 | | - azureApiVersion: { type: 'string' as ParamType, description: 'Azure API version' }, |
409 | | - vertexProject: { |
410 | | - type: 'string' as ParamType, |
411 | | - description: 'Google Cloud project ID for Vertex AI', |
412 | | - }, |
413 | | - vertexLocation: { |
414 | | - type: 'string' as ParamType, |
415 | | - description: 'Google Cloud location for Vertex AI', |
416 | | - }, |
417 | | - vertexCredential: { |
418 | | - type: 'string' as ParamType, |
419 | | - description: 'Google Cloud OAuth credential ID for Vertex AI', |
420 | | - }, |
| 309 | + ...PROVIDER_CREDENTIAL_INPUTS, |
421 | 310 | temperature: { |
422 | 311 | type: 'number' as ParamType, |
423 | 312 | description: 'Response randomness level (low for consistent evaluation)', |
|
0 commit comments