fix: Set the default value of Self RAG to false #1220 (#1702)

### What problem does this PR solve?

fix: Set the default value of Self RAG  to false #1220
fix: Change all tool file names to kebab format

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2024-07-25 14:38:17 +08:00
committed by GitHub
parent c92d334b29
commit 906c0c5c89
38 changed files with 203 additions and 215 deletions

View File

@@ -0,0 +1,74 @@
import { IFactory } from '@/interfaces/database/llm';
import isObject from 'lodash/isObject';
import snakeCase from 'lodash/snakeCase';
export const isFormData = (data: unknown): data is FormData => {
return data instanceof FormData;
};
const excludedFields = ['img2txt_id'];
const isExcludedField = (key: string) => {
return excludedFields.includes(key);
};
export const convertTheKeysOfTheObjectToSnake = (data: unknown) => {
if (isObject(data) && !isFormData(data)) {
return Object.keys(data).reduce<Record<string, any>>((pre, cur) => {
const value = (data as Record<string, any>)[cur];
pre[isFormData(value) || isExcludedField(cur) ? cur : snakeCase(cur)] =
value;
return pre;
}, {});
}
return data;
};
export const getSearchValue = (key: string) => {
const params = new URL(document.location as any).searchParams;
return params.get(key);
};
// Formatize numbers, add thousands of separators
export const formatNumberWithThousandsSeparator = (numberStr: string) => {
const formattedNumber = numberStr.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return formattedNumber;
};
const orderFactoryList = [
'OpenAI',
'Moonshot',
'ZHIPU-AI',
'Ollama',
'Xinference',
];
export const sortLLmFactoryListBySpecifiedOrder = (list: IFactory[]) => {
const finalList: IFactory[] = [];
orderFactoryList.forEach((orderItem) => {
const index = list.findIndex((item) => item.name === orderItem);
if (index !== -1) {
finalList.push(list[index]);
}
});
list.forEach((item) => {
if (finalList.every((x) => x.name !== item.name)) {
finalList.push(item);
}
});
return finalList;
};
export const filterOptionsByInput = (
input: string,
option: { label: string; value: string } | undefined,
) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase());
export const toFixed = (value: unknown, fixed = 2) => {
if (typeof value === 'number') {
return value.toFixed(fixed);
}
return value;
};