mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-31 00:22:01 +08:00

* feat: Fixed the issue where the greeting would disappear when clicking on a new dialog * feat: replace favicon with logo.svg * feat: if the backend returns 401, it will jump to the login page. * feat: unavailable llm models appear disabled * feat: display chunk token number when category of knowledge as general
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { LlmModelType } from '@/constants/knowledge';
|
|
import { IThirdOAIModelCollection } from '@/interfaces/database/llm';
|
|
import { useCallback, useEffect, useMemo } from 'react';
|
|
import { useDispatch, useSelector } from 'umi';
|
|
|
|
export const useFetchLlmList = (modelType: LlmModelType) => {
|
|
const dispatch = useDispatch();
|
|
|
|
const fetchLlmList = useCallback(() => {
|
|
dispatch({
|
|
type: 'settingModel/llm_list',
|
|
payload: { model_type: modelType },
|
|
});
|
|
}, [dispatch, modelType]);
|
|
|
|
useEffect(() => {
|
|
fetchLlmList();
|
|
}, [fetchLlmList]);
|
|
};
|
|
|
|
export const useSelectLlmOptions = () => {
|
|
const llmInfo: IThirdOAIModelCollection = useSelector(
|
|
(state: any) => state.settingModel.llmInfo,
|
|
);
|
|
|
|
const embeddingModelOptions = useMemo(() => {
|
|
return Object.entries(llmInfo).map(([key, value]) => {
|
|
return {
|
|
label: key,
|
|
options: value.map((x) => ({
|
|
label: x.llm_name,
|
|
value: x.llm_name,
|
|
disabled: !x.available,
|
|
})),
|
|
};
|
|
});
|
|
}, [llmInfo]);
|
|
|
|
return embeddingModelOptions;
|
|
};
|