MCPcopy Create free account
hub / github.com/ModelEngine-Group/app-platform / ModelSelect

Function ModelSelect

agent-flow/src/components/llm/Model.jsx:27–66  ·  view source on GitHub ↗
({shapeId, model, serviceName, tag, disabled, modelOptions})

Source from the content-addressed store, hash-verified

25 * @constructor
26 */
27const ModelSelect = ({shapeId, model, serviceName, tag, disabled, modelOptions}) => {
28 const shape = useShapeContext();
29 const {t} = useTranslation();
30 const dispatch = useDispatch();
31
32 const handleSelectClick = (event) => {
33 event.stopPropagation(); // 阻止事件冒泡
34 };
35
36 return (<>
37 <Form.Item
38 className='jade-form-item'
39 name={`model-${shapeId}`}
40 label={t('model')}
41 rules={[{required: true, message: t('pleaseSelectTheModelToBeUsed')}, {
42 validator: (_, value) => {
43 const validateInfo = shape.graph.validateInfo?.find(node => node?.nodeId === shape.id);
44 if (value && !(validateInfo?.isValid ?? true)) {
45 const modelConfigCheck = validateInfo.configChecks?.find(configCheck => configCheck.configName === 'accessInfo');
46 if (modelConfigCheck && modelConfigCheck.serviceName === serviceName?.value && modelConfigCheck.tag === tag?.value) {
47 return Promise.reject(new Error(`${modelConfigCheck.serviceName} ${t('selectedValueNotExist')}`));
48 }
49 }
50 return Promise.resolve();
51 },
52 }]}
53 initialValue={(serviceName?.value && tag?.value ? `${serviceName.value}&&${tag.value}` : null) ?? model?.value ?? serviceName?.value ?? ''} // 当组件套在Form.Item中的时候,内部组件的初始值使用Form.Item的initialValue进行赋值
54 validateTrigger='onBlur'
55 >
56 <JadeStopPropagationSelect
57 disabled={disabled}
58 className='jade-select'
59 onClick={handleSelectClick} // 点击下拉框时阻止事件冒泡
60 onChange={(e) => dispatch({type: 'changeAccessInfoConfig', value: e})}
61 options={modelOptions}
62 dropdownMatchSelectWidth={false}
63 />
64 </Form.Item>
65 </>);
66};
67
68/**
69 * 温度输入组件

Callers

nothing calls this directly

Calls 3

useShapeContextFunction · 0.90
useDispatchFunction · 0.90
findMethod · 0.65

Tested by

no test coverage detected