fix: temperature limit float
This commit is contained in:
@@ -448,7 +448,7 @@ const defaultApi = {
|
||||
useBatchFetch: false, // 是否启用聚合发送请求
|
||||
useContext: false, // 是否启用智能上下文
|
||||
contextSize: DEFAULT_CONTEXT_SIZE, // 智能上下文保留会话数
|
||||
temperature: 0,
|
||||
temperature: 0.0,
|
||||
maxTokens: 20480,
|
||||
think: false,
|
||||
thinkIgnore: "qwen3,deepseek-r1",
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import { limitNumber } from "../libs/utils";
|
||||
import { limitNumber, limitFloat } from "../libs/utils";
|
||||
|
||||
function ValidationInput({ value, onChange, name, min, max, ...props }) {
|
||||
function ValidationInput({
|
||||
value,
|
||||
onChange,
|
||||
name,
|
||||
min,
|
||||
max,
|
||||
isFloat = false,
|
||||
...props
|
||||
}) {
|
||||
const [localValue, setLocalValue] = useState(value);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -21,7 +29,9 @@ function ValidationInput({ value, onChange, name, min, max, ...props }) {
|
||||
return;
|
||||
}
|
||||
|
||||
const validatedValue = limitNumber(numValue, min, max);
|
||||
const validatedValue = isFloat
|
||||
? limitFloat(numValue, min, max)
|
||||
: limitNumber(numValue, min, max);
|
||||
|
||||
if (validatedValue !== numValue) {
|
||||
setLocalValue(validatedValue);
|
||||
|
||||
@@ -15,7 +15,7 @@ export const limitNumber = (num, min = 0, max = 100) => {
|
||||
return number;
|
||||
};
|
||||
|
||||
export const limitFloat = (num, min = 0, max = 100) => {
|
||||
export const limitFloat = (num, min = 0.0, max = 100.0) => {
|
||||
const number = parseFloat(num);
|
||||
if (Number.isNaN(number) || number < min) {
|
||||
return min;
|
||||
|
||||
@@ -299,8 +299,9 @@ function ApiFields({ apiSlug, isUserApi, deleteApi }) {
|
||||
name="temperature"
|
||||
value={temperature}
|
||||
onChange={handleChange}
|
||||
min={0}
|
||||
max={2}
|
||||
min={0.0}
|
||||
max={2.0}
|
||||
isFloat={true}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} md={6} lg={3}>
|
||||
|
||||
Reference in New Issue
Block a user