File size: 7,967 Bytes
8c4ec99 452020d 8c4ec99 058cd84 452020d 8c4ec99 058cd84 452020d 8c4ec99 f1ced48 8c4ec99 f1ced48 8c4ec99 452020d 8c4ec99 b7adc24 8c4ec99 452020d f30b544 452020d b7adc24 452020d b7adc24 8c4ec99 452020d 8c4ec99 452020d b7adc24 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d b7adc24 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d b7adc24 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d b7adc24 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d b7adc24 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d 8c4ec99 452020d 79f4fcc 452020d 8c4ec99 452020d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
import {
LlmModelType,
ModelVariableType,
settledModelVariableMap,
} from '@/constants/knowledge';
import { Divider, Flex, Form, InputNumber, Select, Slider, Switch } from 'antd';
import classNames from 'classnames';
import { useEffect } from 'react';
import { ISegmentedContentProps } from '../interface';
import { useFetchLlmList, useSelectLlmOptions } from '@/hooks/llmHooks';
import { variableEnabledFieldMap } from '../constants';
import styles from './index.less';
const ModelSetting = ({ show, form }: ISegmentedContentProps) => {
const parameterOptions = Object.values(ModelVariableType).map((x) => ({
label: x,
value: x,
}));
const modelOptions = useSelectLlmOptions();
const handleParametersChange = (value: ModelVariableType) => {
const variable = settledModelVariableMap[value];
form.setFieldsValue({ llm_setting: variable });
};
useEffect(() => {
const values = Object.keys(variableEnabledFieldMap).reduce<
Record<string, boolean>
>((pre, field) => {
pre[field] = true;
return pre;
}, {});
form.setFieldsValue(values);
}, [form]);
useFetchLlmList(LlmModelType.Chat);
return (
<section
className={classNames({
[styles.segmentedHidden]: !show,
})}
>
<Form.Item
label="Model"
name="llm_id"
tooltip="Large language chat model"
rules={[{ required: true, message: 'Please select!' }]}
>
<Select options={modelOptions} showSearch />
</Form.Item>
<Divider></Divider>
<Form.Item
label="Freedom"
name="parameters"
tooltip="'Precise' means the LLM will be conservative and answer your question cautiously. 'Improvise' means the you want LLM talk much and freely. 'Balance' is between cautiously and freely."
initialValue={ModelVariableType.Precise}
// rules={[{ required: true, message: 'Please input!' }]}
>
<Select<ModelVariableType>
options={parameterOptions}
onChange={handleParametersChange}
/>
</Form.Item>
<Form.Item label="Temperature" tooltip={'This parameter controls the randomness of predictions by the model. A lower temperature makes the model more confident in its responses, while a higher temperature makes it more creative and diverse.'}>
<Flex gap={20} align="center">
<Form.Item
name={'temperatureEnabled'}
valuePropName="checked"
noStyle
>
<Switch size="small" />
</Form.Item>
<Flex flex={1}>
<Form.Item
name={['llm_setting', 'temperature']}
noStyle
rules={[{ required: true, message: 'Temperature is required' }]}
>
<Slider className={styles.variableSlider} max={1} step={0.01} />
</Form.Item>
</Flex>
<Form.Item
name={['llm_setting', 'temperature']}
noStyle
rules={[{ required: true, message: 'Temperature is required' }]}
>
<InputNumber
className={styles.sliderInputNumber}
max={1}
min={0}
step={0.01}
/>
</Form.Item>
</Flex>
</Form.Item>
<Form.Item label="Top P" tooltip={'Also known as βnucleus sampling,β this parameter sets a threshold to select a smaller set of words to sample from. It focuses on the most likely words, cutting off the less probable ones.'}>
<Flex gap={20} align="center">
<Form.Item name={'topPEnabled'} valuePropName="checked" noStyle>
<Switch size="small" />
</Form.Item>
<Flex flex={1}>
<Form.Item
name={['llm_setting', 'top_p']}
noStyle
rules={[{ required: true, message: 'Top_p is required' }]}
>
<Slider className={styles.variableSlider} max={1} step={0.01} />
</Form.Item>
</Flex>
<Form.Item
name={['llm_setting', 'top_p']}
noStyle
rules={[{ required: true, message: 'Top_p is required' }]}
>
<InputNumber
className={styles.sliderInputNumber}
max={1}
min={0}
step={0.01}
/>
</Form.Item>
</Flex>
</Form.Item>
<Form.Item label="Presence Penalty" tooltip={'This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation.'}>
<Flex gap={20} align="center">
<Form.Item
name={'presencePenaltyEnabled'}
valuePropName="checked"
noStyle
>
<Switch size="small" />
</Form.Item>
<Flex flex={1}>
<Form.Item
name={['llm_setting', 'presence_penalty']}
noStyle
rules={[
{ required: true, message: 'Presence Penalty is required' },
]}
>
<Slider className={styles.variableSlider} max={1} step={0.01} />
</Form.Item>
</Flex>
<Form.Item
name={['llm_setting', 'presence_penalty']}
noStyle
rules={[
{ required: true, message: 'Presence Penalty is required' },
]}
>
<InputNumber
className={styles.sliderInputNumber}
max={1}
min={0}
step={0.01}
/>
</Form.Item>
</Flex>
</Form.Item>
<Form.Item label="Frequency Penalty" tooltip={'Similar to the presence penalty, this reduces the modelβs tendency to repeat the same words frequently.'}>
<Flex gap={20} align="center">
<Form.Item
name={'frequencyPenaltyEnabled'}
valuePropName="checked"
noStyle
>
<Switch size="small" />
</Form.Item>
<Flex flex={1}>
<Form.Item
name={['llm_setting', 'frequency_penalty']}
noStyle
rules={[
{ required: true, message: 'Frequency Penalty is required' },
]}
>
<Slider className={styles.variableSlider} max={1} step={0.01} />
</Form.Item>
</Flex>
<Form.Item
name={['llm_setting', 'frequency_penalty']}
noStyle
rules={[
{ required: true, message: 'Frequency Penalty is required' },
]}
>
<InputNumber
className={styles.sliderInputNumber}
max={1}
min={0}
step={0.01}
/>
</Form.Item>
</Flex>
</Form.Item>
<Form.Item label="Max Tokens" tooltip={'This sets the maximum length of the modelβs output, measured in the number of tokens (words or pieces of words).'}>
<Flex gap={20} align="center">
<Form.Item name={'maxTokensEnabled'} valuePropName="checked" noStyle>
<Switch size="small" />
</Form.Item>
<Flex flex={1}>
<Form.Item
name={['llm_setting', 'max_tokens']}
noStyle
rules={[{ required: true, message: 'Max Tokens is required' }]}
>
<Slider className={styles.variableSlider} max={2048} />
</Form.Item>
</Flex>
<Form.Item
name={['llm_setting', 'max_tokens']}
noStyle
rules={[{ required: true, message: 'Max Tokens is required' }]}
>
<InputNumber
className={styles.sliderInputNumber}
max={2048}
min={0}
/>
</Form.Item>
</Flex>
</Form.Item>
</section>
);
};
export default ModelSetting;
|