mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Load pollinations models from an endpoint
This commit is contained in:
@ -1692,28 +1692,17 @@ async function loadStabilityModels() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadPollinationsModels() {
|
async function loadPollinationsModels() {
|
||||||
return [
|
const result = await fetch('/api/sd/pollinations/models', {
|
||||||
{
|
method: 'POST',
|
||||||
value: 'flux',
|
headers: getRequestHeaders(),
|
||||||
text: 'FLUX.1 [schnell]',
|
});
|
||||||
},
|
|
||||||
{
|
if (result.ok) {
|
||||||
value: 'flux-realism',
|
const data = await result.json();
|
||||||
text: 'FLUX Realism',
|
return data;
|
||||||
},
|
}
|
||||||
{
|
|
||||||
value: 'flux-anime',
|
return [];
|
||||||
text: 'FLUX Anime',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'flux-3d',
|
|
||||||
text: 'FLUX 3D',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'turbo',
|
|
||||||
text: 'SDXL Turbo',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadTogetherAIModels() {
|
async function loadTogetherAIModels() {
|
||||||
|
@ -811,6 +811,31 @@ drawthings.post('/generate', jsonParser, async (request, response) => {
|
|||||||
|
|
||||||
const pollinations = express.Router();
|
const pollinations = express.Router();
|
||||||
|
|
||||||
|
pollinations.post('/models', jsonParser, async (_request, response) => {
|
||||||
|
try {
|
||||||
|
const modelsUrl = new URL('https://image.pollinations.ai/models');
|
||||||
|
const result = await fetch(modelsUrl);
|
||||||
|
|
||||||
|
if (!result.ok) {
|
||||||
|
console.log('Pollinations returned an error.', result.status, result.statusText);
|
||||||
|
throw new Error('Pollinations request failed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await result.json();
|
||||||
|
|
||||||
|
if (!Array.isArray(data)) {
|
||||||
|
console.log('Pollinations returned invalid data.');
|
||||||
|
throw new Error('Pollinations request failed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const models = data.map(x => ({ value: x, text: x }));
|
||||||
|
return response.send(models);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
pollinations.post('/generate', jsonParser, async (request, response) => {
|
pollinations.post('/generate', jsonParser, async (request, response) => {
|
||||||
try {
|
try {
|
||||||
const promptUrl = new URL(`https://image.pollinations.ai/prompt/${encodeURIComponent(request.body.prompt)}`);
|
const promptUrl = new URL(`https://image.pollinations.ai/prompt/${encodeURIComponent(request.body.prompt)}`);
|
||||||
|
Reference in New Issue
Block a user