Spaces:
Sleeping
Sleeping
| import axios from 'axios'; | |
| const getApiBase = () => { | |
| if (import.meta.env.VITE_API_URL) return import.meta.env.VITE_API_URL; | |
| if (typeof window !== 'undefined' && window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1') { | |
| return window.location.origin; | |
| } | |
| return 'http://localhost:8000'; | |
| }; | |
| const API_BASE = getApiBase(); | |
| export const api = axios.create({ | |
| baseURL: API_BASE, | |
| timeout: 300000, | |
| headers: { 'Content-Type': 'application/json' }, | |
| }); | |
| export const ingestRepo = (githubUrl) => api.post('/api/repo/ingest', { github_url: githubUrl }); | |
| export const getRepoStatus = (repoId) => api.get(`/api/repo/${repoId}/status`, { timeout: 30000 }); | |
| export const analyzeArchitecture = (repoId) => api.post('/api/architecture/analyze', { repo_id: repoId }); | |
| export const startArchitectureAnalysis = (repoId) => api.post('/api/architecture/analyze/start', { repo_id: repoId }, { timeout: 30000 }); | |
| export const getArchitectureJob = (jobId) => api.get(`/api/architecture/analyze/jobs/${jobId}`, { timeout: 30000 }); | |
| export const getCachedArchitecture = (repoId) => api.get(`/api/architecture/${repoId}/cached`, { timeout: 30000 }); | |
| export const getWorkflow = (repoId) => api.get(`/api/architecture/${repoId}/workflow`); | |
| export const askQuestion = (repoId, question, chatHistory = []) => | |
| api.post('/api/assistant/ask', { repo_id: repoId, question, chat_history: chatHistory }); | |
| export const analyzeImpact = (repoId, targetFile) => | |
| api.post('/api/impact/analyze', { repo_id: repoId, target_file: targetFile }); | |
| export const generateDocs = (repoId, docType = 'onboarding') => | |
| api.post('/api/docs/generate', { repo_id: repoId, doc_type: docType }); | |
| export const startDocsGeneration = (repoId, docType = 'onboarding') => | |
| api.post('/api/docs/generate/start', { repo_id: repoId, doc_type: docType }, { timeout: 30000 }); | |
| export const getDocsJob = (jobId) => api.get(`/api/docs/generate/jobs/${jobId}`, { timeout: 30000 }); | |
| export const getMetrics = (repoId) => api.get(`/api/metrics/${repoId}`); | |
| export const startMetrics = (repoId) => api.post(`/api/metrics/${repoId}/start`, {}, { timeout: 30000 }); | |
| export const getMetricsJob = (jobId) => api.get(`/api/metrics/jobs/${jobId}`, { timeout: 30000 }); | |
| export const getJobs = (repoId) => api.get('/api/jobs', { params: repoId ? { repo_id: repoId } : {}, timeout: 30000 }); | |