forked from lunanting/cangku
75 lines
2.5 KiB
JavaScript
75 lines
2.5 KiB
JavaScript
import request from './request';
|
|
|
|
const AI_BUYER_SHOW_TIMEOUT_MS = 5 * 60 * 1000;
|
|
|
|
export const getAiBuyerShowRuntime = () => (
|
|
request.get('/api/ai-buyer-show/runtime', { timeout: 30000 })
|
|
);
|
|
|
|
export const previewAiBuyerShowPrompt = (data) => (
|
|
request.post('/api/ai-buyer-show/prompt-preview', data, { timeout: 30000 })
|
|
);
|
|
|
|
export const generateAiBuyerShowReviews = ({ values = {}, productImages = [] }) => {
|
|
const formData = new FormData();
|
|
Object.entries(values).forEach(([key, value]) => {
|
|
if (value !== undefined && value !== null && String(value).trim() !== '') {
|
|
formData.append(key, Array.isArray(value) ? value.join(',') : value);
|
|
}
|
|
});
|
|
productImages.forEach((file) => {
|
|
const rawFile = file.originFileObj || file;
|
|
if (rawFile instanceof Blob) formData.append('productImages', rawFile);
|
|
});
|
|
return request.post('/api/ai-buyer-show/reviews', formData, {
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
timeout: AI_BUYER_SHOW_TIMEOUT_MS,
|
|
maxBodyLength: Infinity,
|
|
maxContentLength: Infinity,
|
|
});
|
|
};
|
|
|
|
export const createAiBuyerShowJob = ({ values = {}, productImages = [], sceneReferenceImages = [] }) => {
|
|
const formData = new FormData();
|
|
Object.entries(values).forEach(([key, value]) => {
|
|
if (value !== undefined && value !== null && String(value).trim() !== '') {
|
|
formData.append(key, value);
|
|
}
|
|
});
|
|
productImages.forEach((file) => {
|
|
const rawFile = file.originFileObj || file;
|
|
if (rawFile instanceof Blob) formData.append('productImages', rawFile);
|
|
});
|
|
sceneReferenceImages.forEach((file) => {
|
|
const rawFile = file.originFileObj || file;
|
|
if (rawFile instanceof Blob) formData.append('sceneReferenceImages', rawFile);
|
|
});
|
|
|
|
return request.post('/api/ai-buyer-show/jobs', formData, {
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
timeout: AI_BUYER_SHOW_TIMEOUT_MS,
|
|
maxBodyLength: Infinity,
|
|
maxContentLength: Infinity,
|
|
});
|
|
};
|
|
|
|
export const getAiBuyerShowJobs = (params) => (
|
|
request.get('/api/ai-buyer-show/jobs', { params, timeout: 30000 })
|
|
);
|
|
|
|
export const getAiBuyerShowHistory = (params) => (
|
|
request.get('/api/ai-buyer-show/history', { params, timeout: 30000 })
|
|
);
|
|
|
|
export const getAiBuyerShowHistoryDetail = (id) => (
|
|
request.get(`/api/ai-buyer-show/history/${id}`, { timeout: 30000 })
|
|
);
|
|
|
|
export const getAiBuyerShowJob = (jobId) => (
|
|
request.get(`/api/ai-buyer-show/jobs/${jobId}`, { timeout: 30000 })
|
|
);
|
|
|
|
export const getAiBuyerShowQueueStats = (params) => (
|
|
request.get('/api/ai-buyer-show/queue-stats', { params, timeout: 30000 })
|
|
);
|