Patch both api and web sides
This commit is contained in:
@@ -16,6 +16,6 @@ View your app in AI Studio: https://ai.studio/apps/drive/1Cg9WH_2bOQEHVVj-lSN5l2
|
||||
1. Install dependencies:
|
||||
`npm install`
|
||||
2. Set the `GEMINI_API_KEY` in [.env.local](.env.local) to your Gemini API key
|
||||
3. Optional: set `VITE_API_BASE_URL` (for backend API, default `http://localhost:8000/api`)
|
||||
3. Optional: set `VITE_API_BASE_URL` (for backend API, default `http://127.0.0.1:8100/api`)
|
||||
4. Run the app:
|
||||
`npm run dev`
|
||||
|
||||
@@ -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(/\/+$/, '');
|
||||
|
||||
|
||||
@@ -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> => {
|
||||
|
||||
Reference in New Issue
Block a user