diff --git a/web/src/components/llm-setting-items/slider.tsx b/web/src/components/llm-setting-items/slider.tsx
index baea5ea31..482b80578 100644
--- a/web/src/components/llm-setting-items/slider.tsx
+++ b/web/src/components/llm-setting-items/slider.tsx
@@ -19,6 +19,7 @@ type SliderInputSwitchFormFieldProps = {
name: string;
label: string;
defaultValue?: number;
+ onChange?: (value: number) => void;
className?: string;
checkName: string;
};
@@ -30,6 +31,7 @@ export function SliderInputSwitchFormField({
label,
name,
defaultValue,
+ onChange,
className,
checkName,
}: SliderInputSwitchFormFieldProps) {
@@ -66,6 +68,10 @@ export function SliderInputSwitchFormField({
{
+ onChange?.(value);
+ field.onChange(value);
+ }}
max={max}
min={min}
step={step}
@@ -80,6 +86,10 @@ export function SliderInputSwitchFormField({
min={min}
step={step}
{...field}
+ onChange={(value: number) => {
+ onChange?.(value);
+ field.onChange(value);
+ }}
>
diff --git a/web/src/components/ui/multi-select.tsx b/web/src/components/ui/multi-select.tsx
index 3433c21b0..1393c4b60 100644
--- a/web/src/components/ui/multi-select.tsx
+++ b/web/src/components/ui/multi-select.tsx
@@ -209,8 +209,10 @@ export const MultiSelect = React.forwardRef<
const [isAnimating, setIsAnimating] = React.useState(false);
React.useEffect(() => {
- setSelectedValues(defaultValue);
- }, [defaultValue]);
+ if (selectedValues === undefined) {
+ setSelectedValues(defaultValue);
+ }
+ }, [defaultValue, selectedValues]);
const flatOptions = React.useMemo(() => {
return options.flatMap((option) =>
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index 355dd96a0..1bd095ea6 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -479,6 +479,7 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s
improvise: 'Improvise',
precise: 'Precise',
balance: 'Balance',
+ custom: 'Custom',
freedomTip: `A shortcut to 'Temperature', 'Top P', 'Presence penalty', and 'Frequency penalty' settings, indicating the freedom level of the model. This parameter has three options: Select 'Improvise' to produce more creative responses; select 'Precise' (default) to produce more conservative responses; 'Balance' is a middle ground between 'Improvise' and 'Precise'.`,
temperature: 'Temperature',
temperatureMessage: 'Temperature is required',
diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts
index 37a783687..34b1a3719 100644
--- a/web/src/locales/zh-traditional.ts
+++ b/web/src/locales/zh-traditional.ts
@@ -454,6 +454,7 @@ export default {
improvise: '即興創作',
precise: '精確',
balance: '平衡',
+ custom: '自定義',
freedomTip: `“精確”意味著法學碩士會保守並謹慎地回答你的問題。“即興發揮”意味著你希望法學碩士能夠自由地暢所欲言。“平衡”是謹慎與自由之間的平衡。`,
temperature: '溫度',
temperatureMessage: '溫度是必填項',
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index 7e46565e4..70667800f 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -477,6 +477,7 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于
improvise: '即兴创作',
precise: '精确',
balance: '平衡',
+ custom: '自定义',
freedomTip: `“精确”意味着大语言模型会保守并谨慎地回答你的问题。 “即兴发挥”意味着你希望大语言模型能够自由地畅所欲言。 “平衡”是谨慎与自由之间的平衡。`,
temperature: '温度',
temperatureMessage: '温度是必填项',
diff --git a/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/index.less b/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/index.less
index fd2b50f77..9850fb410 100644
--- a/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/index.less
+++ b/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/index.less
@@ -35,7 +35,7 @@
.documentPreview {
// width: 40%;
- height: calc(100vh - 130px);
+ height: calc(100vh - 180px);
overflow: auto;
}
diff --git a/web/src/pages/next-search/search-setting-aisummery-config.tsx b/web/src/pages/next-search/search-setting-aisummery-config.tsx
index f9d622cc8..6f30de26a 100644
--- a/web/src/pages/next-search/search-setting-aisummery-config.tsx
+++ b/web/src/pages/next-search/search-setting-aisummery-config.tsx
@@ -21,7 +21,7 @@ import {
} from '@/constants/knowledge';
import { useTranslate } from '@/hooks/common-hooks';
import { useComposeLlmOptionsByModelTypes } from '@/hooks/llm-hooks';
-import { camelCase } from 'lodash';
+import { camelCase, isEqual } from 'lodash';
import { useCallback } from 'react';
import { useFormContext } from 'react-hook-form';
import { z } from 'zod';
@@ -61,20 +61,15 @@ export function LlmSettingFieldItems({
const handleChange = useCallback(
(parameter: string) => {
- const currentValues = { ...form.getValues() };
- console.log('currentValues', currentValues);
const values =
settledModelVariableMap[
parameter as keyof typeof settledModelVariableMap
];
const enabledKeys = Object.keys(LlmSettingEnableSchema);
- // const nextValues = { ...currentValues, ...values };
-
for (const key in values) {
if (Object.prototype.hasOwnProperty.call(values, key)) {
- const element = values[key];
-
+ const element = values[key as keyof typeof values];
form.setValue(`${prefix}.${key}`, element);
}
}
@@ -90,7 +85,11 @@ export function LlmSettingFieldItems({
const parameterOptions = Object.values(ModelVariableType).map((x) => ({
label: t(camelCase(x)),
value: x,
- }));
+ })) as unknown as { label: string; value: ModelVariableType | 'Custom' }[];
+ parameterOptions.push({
+ label: t(camelCase('Custom')),
+ value: 'Custom',
+ });
const getFieldWithPrefix = useCallback(
(name: string) => {
@@ -99,6 +98,35 @@ export function LlmSettingFieldItems({
[prefix],
);
+ const checkParameterIsEquel = () => {
+ const [
+ parameter,
+ topPValue,
+ frequencyPenaltyValue,
+ temperatureValue,
+ presencePenaltyValue,
+ ] = form.getValues([
+ getFieldWithPrefix('parameter'),
+ getFieldWithPrefix('temperature'),
+ getFieldWithPrefix('top_p'),
+ getFieldWithPrefix('frequency_penalty'),
+ getFieldWithPrefix('presence_penalty'),
+ ]);
+ if (parameter && parameter !== 'Custom') {
+ const parameterValue =
+ settledModelVariableMap[parameter as keyof typeof ModelVariableType];
+ const parameterRealValue = {
+ top_p: topPValue,
+ temperature: temperatureValue,
+ frequency_penalty: frequencyPenaltyValue,
+ presence_penalty: presencePenaltyValue,
+ };
+ if (!isEqual(parameterValue, parameterRealValue)) {
+ form.setValue(getFieldWithPrefix('parameter'), 'Custom');
+ }
+ }
+ };
+
return (
{
+ checkParameterIsEquel();
+ }}
>
{
+ checkParameterIsEquel();
+ }}
>
{
+ checkParameterIsEquel();
+ }}
>
{
+ checkParameterIsEquel();
+ }}
>
{/* = ({
use_rerank: search_config?.rerank_id ? true : false,
top_k: search_config?.top_k || 1024,
summary: search_config?.summary || false,
- chat_id: '',
+ chat_id: search_config?.chat_id || '',
llm_setting: {
- llm_id: llm_setting?.llm_id || '',
+ llm_id: search_config?.chat_id || '',
parameter: llm_setting?.parameter,
temperature: llm_setting?.temperature,
top_p: llm_setting?.top_p,
@@ -159,7 +159,7 @@ const SearchSetting: React.FC = ({
meta_data_filter: search_config?.meta_data_filter,
},
});
- }, [data, search_config, llm_setting, formMethods]);
+ }, [data, search_config, llm_setting, formMethods, descriptionDefaultValue]);
useEffect(() => {
resetForm();
@@ -255,7 +255,7 @@ const SearchSetting: React.FC = ({
...other_config
} = search_config;
const llmSetting = {
- llm_id: llm_setting.llm_id,
+ // llm_id: llm_setting.llm_id,
parameter: llm_setting.parameter,
temperature: llm_setting.temperature,
top_p: llm_setting.top_p,
@@ -263,22 +263,11 @@ const SearchSetting: React.FC = ({
presence_penalty: llm_setting.presence_penalty,
} as IllmSettingProps;
- if (!llm_setting.frequencyPenaltyEnabled) {
- delete llmSetting.frequency_penalty;
- }
- if (!llm_setting.presencePenaltyEnabled) {
- delete llmSetting.presence_penalty;
- }
- if (!llm_setting.temperatureEnabled) {
- delete llmSetting.temperature;
- }
- if (!llm_setting.topPEnabled) {
- delete llmSetting.top_p;
- }
await updateSearch({
...other_formdata,
search_config: {
...other_config,
+ chat_id: llm_setting.llm_id,
vector_similarity_weight: 1 - vector_similarity_weight,
rerank_id: use_rerank ? rerank_id : '',
llm_setting: { ...llmSetting },
diff --git a/web/src/pages/next-searches/hooks.ts b/web/src/pages/next-searches/hooks.ts
index 0919e5c13..564e9c1ad 100644
--- a/web/src/pages/next-searches/hooks.ts
+++ b/web/src/pages/next-searches/hooks.ts
@@ -154,6 +154,7 @@ export interface ISearchAppDetailProps {
search_config: {
cross_languages: string[];
doc_ids: string[];
+ chat_id: string;
highlight: boolean;
kb_ids: string[];
keyword: boolean;