Patch both api and web sides

This commit is contained in:
Xin Wang
2026-02-08 21:59:56 +08:00
parent 68e47320cd
commit 8069a16227
5 changed files with 34 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
const DEFAULT_API_BASE_URL = 'http://localhost:8000/api';
const DEFAULT_API_BASE_URL = 'http://127.0.0.1:8100/api';
const trimTrailingSlash = (value: string): string => value.replace(/\/+$/, '');

View File

@@ -173,13 +173,15 @@ export const deleteAssistant = async (id: string): Promise<void> => {
};
export const fetchVoices = async (): Promise<Voice[]> => {
const response = await apiRequest<AnyRecord[]>('/voices');
return response.map((item) => mapVoice(item));
const response = await apiRequest<{ list?: AnyRecord[] } | AnyRecord[]>('/voices');
const list = Array.isArray(response) ? response : (response.list || []);
return list.map((item) => mapVoice(item));
};
export const fetchWorkflows = async (): Promise<Workflow[]> => {
const response = await apiRequest<AnyRecord[]>('/workflows');
return response.map((item) => mapWorkflow(item));
const response = await apiRequest<{ list?: AnyRecord[] } | AnyRecord[]>('/workflows');
const list = Array.isArray(response) ? response : (response.list || []);
return list.map((item) => mapWorkflow(item));
};
export const fetchWorkflowById = async (id: string): Promise<Workflow> => {
@@ -238,12 +240,12 @@ export const deleteKnowledgeBase = async (kbId: string): Promise<void> => {
};
export const uploadKnowledgeDocument = async (kbId: string, file: File): Promise<void> => {
const params = new URLSearchParams({
const payload = {
name: file.name,
size: `${(file.size / 1024).toFixed(1)} KB`,
file_type: file.type || 'txt',
});
await apiRequest(`/knowledge/bases/${kbId}/documents?${params.toString()}`, { method: 'POST' });
fileType: file.type || 'txt',
};
await apiRequest(`/knowledge/bases/${kbId}/documents`, { method: 'POST', body: payload });
};
export const deleteKnowledgeDocument = async (kbId: string, docId: string): Promise<void> => {