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