T1ckbase commited on
Commit
eb06d6c
·
1 Parent(s): 997a698
Files changed (3) hide show
  1. deno.json +2 -1
  2. deno.lock +13 -1
  3. main.ts +2 -0
deno.json CHANGED
@@ -6,7 +6,8 @@
6
  "imports": {
7
  "@hono/hono": "jsr:@hono/hono@^4.7.1",
8
  "@openai/openai": "jsr:@openai/openai@^4.87.3",
9
- "@std/encoding": "jsr:@std/encoding@^1.0.7"
 
10
  },
11
  "fmt": {
12
  "indentWidth": 2,
 
6
  "imports": {
7
  "@hono/hono": "jsr:@hono/hono@^4.7.1",
8
  "@openai/openai": "jsr:@openai/openai@^4.87.3",
9
+ "@std/encoding": "jsr:@std/encoding@^1.0.7",
10
+ "@std/fs": "jsr:@std/fs@^1.0.14"
11
  },
12
  "fmt": {
13
  "indentWidth": 2,
deno.lock CHANGED
@@ -4,6 +4,8 @@
4
  "jsr:@hono/hono@^4.7.1": "4.7.1",
5
  "jsr:@openai/openai@^4.87.3": "4.87.3",
6
  "jsr:@std/encoding@^1.0.7": "1.0.7",
 
 
7
  "npm:zod@3": "3.24.2"
8
  },
9
  "jsr": {
@@ -18,6 +20,15 @@
18
  },
19
  "@std/[email protected]": {
20
  "integrity": "f631247c1698fef289f2de9e2a33d571e46133b38d042905e3eac3715030a82d"
 
 
 
 
 
 
 
 
 
21
  }
22
  },
23
  "npm": {
@@ -29,7 +40,8 @@
29
  "dependencies": [
30
  "jsr:@hono/hono@^4.7.1",
31
  "jsr:@openai/openai@^4.87.3",
32
- "jsr:@std/encoding@^1.0.7"
 
33
  ]
34
  }
35
  }
 
4
  "jsr:@hono/hono@^4.7.1": "4.7.1",
5
  "jsr:@openai/openai@^4.87.3": "4.87.3",
6
  "jsr:@std/encoding@^1.0.7": "1.0.7",
7
+ "jsr:@std/fs@^1.0.14": "1.0.14",
8
+ "jsr:@std/path@^1.0.8": "1.0.8",
9
  "npm:zod@3": "3.24.2"
10
  },
11
  "jsr": {
 
20
  },
21
  "@std/[email protected]": {
22
  "integrity": "f631247c1698fef289f2de9e2a33d571e46133b38d042905e3eac3715030a82d"
23
+ },
24
+ "@std/[email protected]": {
25
+ "integrity": "1e84bf0b95fe08f41f1f4aea9717bbf29f45408a56ce073b0114474ce1c9fccf",
26
+ "dependencies": [
27
+ "jsr:@std/path"
28
+ ]
29
+ },
30
+ "@std/[email protected]": {
31
+ "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be"
32
  }
33
  },
34
  "npm": {
 
40
  "dependencies": [
41
  "jsr:@hono/hono@^4.7.1",
42
  "jsr:@openai/openai@^4.87.3",
43
+ "jsr:@std/encoding@^1.0.7",
44
+ "jsr:@std/fs@^1.0.14"
45
  ]
46
  }
47
  }
main.ts CHANGED
@@ -5,6 +5,7 @@ import { generateImage as fluxGenerateImage } from './gradio-api/flux.ts';
5
  import { parseResolution } from './utils/string.ts';
6
  import OpenAI from '@openai/openai';
7
  import { encodeBase64 } from '@std/encoding/base64';
 
8
 
9
  // https://api-inference.huggingface.co/v1
10
  const HF_API_URL = 'https://api-inference.huggingface.co';
@@ -105,6 +106,7 @@ app.post('/v1/images/generations', async (c) => {
105
  const image = await response.arrayBuffer();
106
  const fileName = `${crypto.randomUUID()}.${ext}`;
107
 
 
108
  await Deno.writeFile(`./tmp/${fileName}`, new Uint8Array(image), { create: true });
109
 
110
  let data: any = {
 
5
  import { parseResolution } from './utils/string.ts';
6
  import OpenAI from '@openai/openai';
7
  import { encodeBase64 } from '@std/encoding/base64';
8
+ import { ensureDir } from '@std/fs';
9
 
10
  // https://api-inference.huggingface.co/v1
11
  const HF_API_URL = 'https://api-inference.huggingface.co';
 
106
  const image = await response.arrayBuffer();
107
  const fileName = `${crypto.randomUUID()}.${ext}`;
108
 
109
+ await ensureDir('./tmp');
110
  await Deno.writeFile(`./tmp/${fileName}`, new Uint8Array(image), { create: true });
111
 
112
  let data: any = {