enzostvs HF staff commited on
Commit
3a09171
·
1 Parent(s): a0a856c

format is a query params

Browse files
Files changed (1) hide show
  1. routes/prompt/index.js +6 -3
routes/prompt/index.js CHANGED
@@ -35,7 +35,11 @@ const IMAGE_SIZES = {
35
 
36
  module.exports = async function (fastify, opts) {
37
  fastify.get('/:inputs', async function (request, reply) {
38
- const { inputs } = request.params;
 
 
 
 
39
 
40
  const slug = inputs.replace(/[^a-zA-Z0-9-_ ]/g, "").replace(/ /g, "-");
41
 
@@ -46,8 +50,7 @@ module.exports = async function (fastify, opts) {
46
  .send(file);
47
  }
48
 
49
- let size = inputs.split(" ").find(i => Object.keys(IMAGE_SIZES).includes(i)) || "square";
50
- const { height, width } = IMAGE_SIZES[size];
51
 
52
  const hfRequest = await inference.textToImage({
53
  inputs,
 
35
 
36
  module.exports = async function (fastify, opts) {
37
  fastify.get('/:inputs', async function (request, reply) {
38
+ let { inputs } = request.params;
39
+ const { format } = request.query;
40
+ if (format) {
41
+ inputs = inputs + " " + format;
42
+ }
43
 
44
  const slug = inputs.replace(/[^a-zA-Z0-9-_ ]/g, "").replace(/ /g, "-");
45
 
 
50
  .send(file);
51
  }
52
 
53
+ const { height, width } = IMAGE_SIZES[format ?? "square"];
 
54
 
55
  const hfRequest = await inference.textToImage({
56
  inputs,