Spaces:
Running on Zero
Running on Zero
File size: 2,267 Bytes
b701455 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | import axios from 'axios';
import type {
GenerationSettings,
GenerationResponse,
ImageMetadata,
ModelInfo,
SettingsPreferences,
SettingsSnapshot,
} from '../types';
const api = axios.create({
baseURL: '/api', // Proxy handles redirection to localhost:7861
});
export const listModels = async (): Promise<ModelInfo[]> => {
const res = await api.get<ModelInfo[]>('/models');
return res.data;
};
export const listControlNets = async (): Promise<{ models: string[] }> => {
const res = await api.get<{ models: string[] }>('/controlnets');
return res.data;
};
export const generateImage = async (settings: GenerationSettings): Promise<GenerationResponse> => {
const res = await api.post<GenerationResponse>('/generate', settings);
console.log("Generation response:", res.data);
return res.data;
};
export const interruptGeneration = async (): Promise<void> => {
await api.post('/interrupt');
};
export const getLastSeed = async (): Promise<{ seed: number | null }> => {
const res = await api.get('/settings/last');
return res.data;
};
export const getSettingsHistory = async (): Promise<{ history: SettingsSnapshot[] }> => {
const res = await api.get('/settings/history');
return res.data;
};
export const getSettingsPreferences = async (): Promise<SettingsPreferences> => {
const res = await api.get('/settings/preferences');
return res.data;
};
export const postSettingsPreferences = async (preferences: SettingsPreferences): Promise<SettingsPreferences> => {
const res = await api.post('/settings/preferences', preferences);
return res.data;
};
export const postSettingsSnapshot = async (settings: GenerationSettings, include_prompt: boolean = false): Promise<{ snapshot: SettingsSnapshot }> => {
const res = await api.post('/settings/history', { settings, include_prompt });
return res.data;
};
export const getImageMetadata = async (imageB64: string): Promise<{ metadata: ImageMetadata }> => {
const res = await api.post('/images/metadata', { image: imageB64 });
return res.data;
};
export const getTelemetry = async (): Promise<Record<string, unknown>> => {
const res = await api.get('/telemetry');
return res.data;
}
export default api;
|