Refactor: Standardize naming convention to camelCase (#14079)

### What problem does this PR solve?

Refactor: Standardize naming convention to camelCase

### Type of change

- [x] Refactoring
This commit is contained in:
chanx
2026-04-13 21:07:07 +08:00
committed by GitHub
parent 9a38af7cbf
commit 6ffa566ec3
13 changed files with 200 additions and 196 deletions

View File

@@ -494,7 +494,7 @@ export function useUploadAndParseFile() {
const { data } = await chatService.uploadAndParse(
{
url: api.upload_and_parse,
url: api.uploadAndParse,
signal: controller.current.signal,
data: formData,
onUploadProgress: ({ progress }) => {

View File

@@ -47,7 +47,7 @@ export const useDeleteChunk = () => {
} = useMutation({
mutationKey: ['deleteChunk'],
mutationFn: async (params: { chunkIds: string[]; doc_id: string }) => {
const { data } = await kbService.rm_chunk(params);
const { data } = await kbService.rmChunk(params);
if (data.code === 0) {
setPaginationParams(1);
queryClient.invalidateQueries({ queryKey: ['fetchChunkList'] });
@@ -70,9 +70,9 @@ export const useCreateChunk = () => {
} = useMutation({
mutationKey: ['createChunk'],
mutationFn: async (payload: any) => {
let service = kbService.create_chunk;
let service = kbService.createChunk;
if (payload.chunk_id) {
service = kbService.set_chunk;
service = kbService.setChunk;
}
const { data } = await service(payload);
if (data.code === 0) {
@@ -95,7 +95,7 @@ export const useFetchChunk = (chunkId?: string): ResponseType<any> => {
initialData: {},
gcTime: 0,
queryFn: async () => {
const data = await kbService.get_chunk({
const data = await kbService.getChunk({
chunk_id: chunkId,
});
@@ -138,7 +138,7 @@ export const useFetchNextChunkList = (
gcTime: 0,
enabled,
queryFn: async () => {
const { data } = await kbService.chunk_list({
const { data } = await kbService.chunkList({
doc_id: documentId,
page: pagination.current,
size: pagination.pageSize,
@@ -206,7 +206,7 @@ export const useSwitchChunk = () => {
available_int?: number;
doc_id: string;
}) => {
const { data } = await kbService.switch_chunk(params);
const { data } = await kbService.switchChunk(params);
if (data.code === 0) {
message.success(t('message.modified'));
}

View File

@@ -71,7 +71,7 @@ export const useUploadNextDocument = () => {
});
try {
const ret = await kbService.document_upload(formData);
const ret = await kbService.documentUpload(formData);
const code = get(ret, 'data.code');
if (code === 0 || code === 500) {
@@ -93,7 +93,7 @@ export const useUploadNextDocument = () => {
return { uploadDocument: mutateAsync, loading, data };
};
export const useFetchDocumentList = () => {
export const useFetchDocumentList = (loop = true) => {
const { knowledgeId } = useGetKnowledgeSearchParams();
const { searchString, handleInputChange } = useHandleSearchChange();
const { pagination, setPagination } = useGetPaginationWithRouter();
@@ -103,9 +103,10 @@ export const useFetchDocumentList = () => {
const { filterValue, handleFilterSubmit, checkValue } =
useHandleFilterSubmit();
const [docs, setDocs] = useState<IDocumentInfo[]>([]);
const isLoop = useMemo(() => {
return docs.some((doc) => doc.run === '1');
}, [docs]);
return loop && docs.some((doc) => doc.run === '1');
}, [docs, loop]);
const { data, isFetching: loading } = useQuery<{
docs: IDocumentInfo[];
@@ -245,7 +246,7 @@ export const useSetDocumentStatus = () => {
documentId: string | string[];
}) => {
const ids = Array.isArray(documentId) ? documentId : [documentId];
const { data } = await kbService.document_change_status({
const { data } = await kbService.documentChangeStatus({
doc_ids: ids,
status: Number(status),
});
@@ -284,7 +285,7 @@ export const useRunDocument = () => {
queryClient.invalidateQueries({
queryKey: [DocumentApiAction.FetchDocumentList],
});
const ret = await kbService.document_run({
const ret = await kbService.documentRun({
doc_ids: documentIds,
run,
...(option || {}),
@@ -313,7 +314,7 @@ export const useRemoveDocument = () => {
} = useMutation({
mutationKey: [DocumentApiAction.RemoveDocument],
mutationFn: async (documentIds: string | string[]) => {
const { data } = await kbService.document_rm({ doc_id: documentIds });
const { data } = await kbService.documentRm({ doc_id: documentIds });
if (data.code === 0) {
message.success(i18n.t('message.deleted'));
queryClient.invalidateQueries({
@@ -381,7 +382,7 @@ export const useSetDocumentParser = () => {
documentId: string;
parserConfig: IChangeParserConfigRequestBody;
}) => {
const { data } = await kbService.document_change_parser({
const { data } = await kbService.documentChangeParser({
parser_id: parserId,
pipeline_id: pipelineId,
doc_id: documentId,
@@ -446,7 +447,7 @@ export const useCreateDocument = () => {
} = useMutation({
mutationKey: [DocumentApiAction.CreateDocument],
mutationFn: async (name: string) => {
const { data } = await kbService.document_create({
const { data } = await kbService.documentCreate({
name,
kb_id: id,
});
@@ -518,7 +519,7 @@ export const useNextWebCrawl = () => {
formData.append('url', url);
formData.append('kb_id', knowledgeId);
const ret = await kbService.web_crawl(formData);
const ret = await kbService.webCrawl(formData);
const code = get(ret, 'data.code');
if (code === 0) {
message.success(i18n.t('message.uploaded'));
@@ -542,7 +543,7 @@ export const useFetchDocumentThumbnailsByIds = () => {
enabled: ids.length > 0,
initialData: {},
queryFn: async () => {
const { data } = await kbService.document_thumbnails({ doc_ids: ids });
const { data } = await kbService.documentThumbnails({ doc_ids: ids });
if (data.code === 0) {
return data.data;
}

View File

@@ -78,7 +78,7 @@ export const useTestRetrieval = () => {
const mutation = useMutation<INextTestingResult, Error, typeof queryParams>({
mutationFn: async (params) => {
const { data } = await kbService.retrieval_test(params);
const { data } = await kbService.retrievalTest(params);
const result = data?.data ?? {};
return { ...result, isRuned: true };
},
@@ -406,7 +406,7 @@ export const useFetchKnowledgeBaseConfiguration = (props?: {
gcTime: 0,
queryFn: async () => {
if (isEdit) {
const { data } = await kbService.get_kb_detail({
const { data } = await kbService.getKbDetail({
kb_id: knowledgeBaseId,
});
return data?.data ?? {};
@@ -621,7 +621,7 @@ export const useTestChunkRetrieval = (): ResponsePostType<ITestingResult> & {
mutationKey: ['testChunk'], // This method is invalid
gcTime: 0,
mutationFn: async (values: any) => {
const { data } = await kbService.retrieval_test({
const { data } = await kbService.retrievalTest({
...values,
kb_id: values.kb_id ?? knowledgeBaseId,
page,
@@ -665,7 +665,7 @@ export const useTestChunkAllRetrieval = (): ResponsePostType<ITestingResult> & {
mutationKey: ['testChunkAll'], // This method is invalid
gcTime: 0,
mutationFn: async (values: any) => {
const { data } = await kbService.retrieval_test({
const { data } = await kbService.retrievalTest({
...values,
kb_id: values.kb_id ?? knowledgeBaseId,
doc_ids: [],

View File

@@ -40,7 +40,7 @@ export const useFetchLlmList = (modelType?: LlmModelType) => {
queryKey: [LLMApiAction.LlmList],
initialData: {},
queryFn: async () => {
const { data } = await userService.llm_list({ model_type: modelType });
const { data } = await userService.llmList({ model_type: modelType });
return data?.data ?? {};
},
@@ -191,7 +191,7 @@ export const useFetchLlmFactoryList = (): ResponseGetType<IFactory[]> => {
initialData: [],
gcTime: 0,
queryFn: async () => {
const { data } = await userService.factories_list();
const { data } = await userService.factoriesList();
return data?.data ?? [];
},
@@ -210,7 +210,7 @@ export const useFetchMyLlmList = (): ResponseGetType<
initialData: {},
gcTime: 0,
queryFn: async () => {
const { data } = await userService.my_llm();
const { data } = await userService.myLlm();
return data?.data ?? {};
},
@@ -227,7 +227,7 @@ export const useFetchMyLlmListDetailed = (): ResponseGetType<
initialData: {},
gcTime: 0,
queryFn: async () => {
const { data } = await userService.my_llm({ include_details: true });
const { data } = await userService.myLlm({ include_details: true });
return data?.data ?? {};
},
@@ -285,7 +285,7 @@ export const useSaveApiKey = () => {
} = useMutation({
mutationKey: [LLMApiAction.SaveApiKey],
mutationFn: async (params: IApiKeySavingParams) => {
const { data } = await userService.set_api_key(params);
const { data } = await userService.setApiKey(params);
if (data.code === 0) {
// message.success(t('message.modified'));
queryClient.invalidateQueries({ queryKey: [LLMApiAction.MyLlmList] });
@@ -319,7 +319,7 @@ export const useSaveTenantInfo = () => {
} = useMutation({
mutationKey: [LLMApiAction.SaveTenantInfo],
mutationFn: async (params: ISystemModelSettingSavingParams) => {
const { data } = await userService.set_tenant_info(params);
const { data } = await userService.setTenantInfo(params);
if (data.code === 0) {
message.success(t('message.modified'));
}
@@ -340,7 +340,7 @@ export const useAddLlm = () => {
} = useMutation({
mutationKey: [LLMApiAction.AddLlm],
mutationFn: async (params: IAddLlmRequestBody & { verify?: boolean }) => {
const { data } = await userService.add_llm(params);
const { data } = await userService.addLlm(params);
if (data.code === 0 && !params.verify) {
queryClient.invalidateQueries({ queryKey: [LLMApiAction.MyLlmList] });
queryClient.invalidateQueries({
@@ -367,7 +367,7 @@ export const useDeleteLlm = () => {
} = useMutation({
mutationKey: [LLMApiAction.DeleteLlm],
mutationFn: async (params: IDeleteLlmRequestBody) => {
const { data } = await userService.delete_llm(params);
const { data } = await userService.deleteLlm(params);
if (data.code === 0) {
queryClient.invalidateQueries({ queryKey: [LLMApiAction.MyLlmList] });
queryClient.invalidateQueries({
@@ -398,7 +398,7 @@ export const useEnableLlm = () => {
status?: 1 | 0;
} = { ...params, status: params.enable ? 1 : 0 };
delete reqParam.enable;
const { data } = await userService.enable_llm(reqParam);
const { data } = await userService.enableLlm(reqParam);
if (data.code === 0) {
queryClient.invalidateQueries({ queryKey: [LLMApiAction.MyLlmList] });
queryClient.invalidateQueries({

View File

@@ -50,7 +50,7 @@ export const useFetchUserInfo = (): ResponseGetType<IUserInfo> => {
initialData: {},
gcTime: 0,
queryFn: async () => {
const { data } = await userService.user_info();
const { data } = await userService.userInfo();
if (data.code === 0) {
const targetLng =
@@ -79,7 +79,7 @@ export const useFetchTenantInfo = (
initialData: {},
gcTime: 0,
queryFn: async () => {
const { data: res } = await userService.get_tenant_info();
const { data: res } = await userService.getTenantInfo();
if (res.code === 0) {
// llm_id is chat_id
// asr_id is speech2txt