enzostvs HF staff commited on
Commit
df91643
1 Parent(s): 52e4693

dynamic load for env

Browse files
src/lib/components/snippets/Curl.svelte CHANGED
@@ -2,7 +2,7 @@
2
  import Icon from '@iconify/svelte';
3
  import Highlight from "svelte-highlight";
4
  import powershell from "svelte-highlight/languages/powershell";
5
- import { PUBLIC_INFERENCE_API_URL } from '$env/static/public'
6
 
7
 
8
  export let body: Record<string, any>;
@@ -13,7 +13,7 @@
13
  let isCopied: boolean = false;
14
 
15
  const generateCurlRequestFromEndpoint = (body: Record<string, any>) => {
16
- const fullpath = `${PUBLIC_INFERENCE_API_URL}/models/${endpoint}`;
17
  delete body.model
18
  return `curl -X POST "${fullpath}" \\
19
  -H ${JSON.stringify(headers)}
 
2
  import Icon from '@iconify/svelte';
3
  import Highlight from "svelte-highlight";
4
  import powershell from "svelte-highlight/languages/powershell";
5
+ import { env } from '$env/dynamic/public'
6
 
7
 
8
  export let body: Record<string, any>;
 
13
  let isCopied: boolean = false;
14
 
15
  const generateCurlRequestFromEndpoint = (body: Record<string, any>) => {
16
+ const fullpath = `${env.PUBLIC_INFERENCE_API_URL}/models/${endpoint}`;
17
  delete body.model
18
  return `curl -X POST "${fullpath}" \\
19
  -H ${JSON.stringify(headers)}
src/lib/components/snippets/Javascript.svelte CHANGED
@@ -2,7 +2,7 @@
2
  import Icon from '@iconify/svelte';
3
  import Highlight from "svelte-highlight";
4
  import javascript from "svelte-highlight/languages/javascript";
5
- import { PUBLIC_INFERENCE_API_URL } from '$env/static/public'
6
 
7
  export let body: Record<string, any>;
8
  export let endpoint: string;
@@ -12,7 +12,7 @@
12
  let isCopied: boolean = false;
13
 
14
  const generateCurlRequestFromEndpoint = (body: Record<string, any>) => {
15
- const fullpath = `${PUBLIC_INFERENCE_API_URL}/models/${endpoint}`;
16
  delete body.model
17
 
18
  return `const response = await fetch(
 
2
  import Icon from '@iconify/svelte';
3
  import Highlight from "svelte-highlight";
4
  import javascript from "svelte-highlight/languages/javascript";
5
+ import { env } from '$env/dynamic/public'
6
 
7
  export let body: Record<string, any>;
8
  export let endpoint: string;
 
12
  let isCopied: boolean = false;
13
 
14
  const generateCurlRequestFromEndpoint = (body: Record<string, any>) => {
15
+ const fullpath = `${env.PUBLIC_INFERENCE_API_URL}/models/${endpoint}`;
16
  delete body.model
17
 
18
  return `const response = await fetch(
src/lib/components/snippets/Python.svelte CHANGED
@@ -2,7 +2,7 @@
2
  import Icon from '@iconify/svelte';
3
  import Highlight from "svelte-highlight";
4
  import javascript from "svelte-highlight/languages/javascript";
5
- import { PUBLIC_INFERENCE_API_URL } from '$env/static/public'
6
 
7
  export let body: Record<string, any>;
8
  export let endpoint: string;
@@ -12,7 +12,7 @@
12
  let isCopied: boolean = false;
13
 
14
  const generateCurlRequestFromEndpoint = (body: Record<string, any>) => {
15
- const fullpath = `${PUBLIC_INFERENCE_API_URL}/models/${endpoint}`;
16
  delete body.model
17
 
18
  const removeEmptyValues = (data: Record<string, any>) => {
 
2
  import Icon from '@iconify/svelte';
3
  import Highlight from "svelte-highlight";
4
  import javascript from "svelte-highlight/languages/javascript";
5
+ import { env } from '$env/dynamic/public'
6
 
7
  export let body: Record<string, any>;
8
  export let endpoint: string;
 
12
  let isCopied: boolean = false;
13
 
14
  const generateCurlRequestFromEndpoint = (body: Record<string, any>) => {
15
+ const fullpath = `${env.PUBLIC_INFERENCE_API_URL}/models/${endpoint}`;
16
  delete body.model
17
 
18
  const removeEmptyValues = (data: Record<string, any>) => {
src/routes/+page.server.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import { redirect } from '@sveltejs/kit';
2
+
3
+ export function load() {
4
+ throw redirect(302, '/text-generation');
5
+ }
src/routes/+page.svelte CHANGED
@@ -1,59 +1,4 @@
1
- <script>
2
- import Counter from './Counter.svelte';
3
- import welcome from '$lib/images/svelte-welcome.webp';
4
- import welcome_fallback from '$lib/images/svelte-welcome.png';
5
- </script>
6
-
7
  <svelte:head>
8
- <title>Home</title>
9
- <meta name="description" content="Svelte demo app" />
10
  </svelte:head>
11
-
12
- <section>
13
- <h1>
14
- <span class="welcome">
15
- <picture>
16
- <source srcset={welcome} type="image/webp" />
17
- <img src={welcome_fallback} alt="Welcome" />
18
- </picture>
19
- </span>
20
-
21
- to your new<br />SvelteKit app
22
- </h1>
23
-
24
- <h2>
25
- try editing <strong>src/routes/+page.svelte</strong>
26
- </h2>
27
-
28
- <Counter />
29
- </section>
30
-
31
- <style>
32
- section {
33
- display: flex;
34
- flex-direction: column;
35
- justify-content: center;
36
- align-items: center;
37
- flex: 0.6;
38
- }
39
-
40
- h1 {
41
- width: 100%;
42
- }
43
-
44
- .welcome {
45
- display: block;
46
- position: relative;
47
- width: 100%;
48
- height: 0;
49
- padding: 0 0 calc(100% * 495 / 2048) 0;
50
- }
51
-
52
- .welcome img {
53
- position: absolute;
54
- width: 100%;
55
- height: 100%;
56
- top: 0;
57
- display: block;
58
- }
59
- </style>
 
 
 
 
 
 
 
1
  <svelte:head>
2
+ <title>Playground API Inference for PRO | Hugging Face</title>
3
+ <meta name="description" content="Playground API Inference for PRO | Hugging Face" />
4
  </svelte:head>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/routes/api/image-generation/+server.ts CHANGED
@@ -1,5 +1,5 @@
1
  import { error, type RequestEvent } from '@sveltejs/kit';
2
- import { SECRET_HF_TOKEN, SECRET_INFERENCE_API_URL } from '$env/static/private'
3
 
4
  /** @type {import('./$types').RequestHandler} */
5
  export async function POST({ request }: RequestEvent) {
@@ -13,10 +13,10 @@ export async function POST({ request }: RequestEvent) {
13
  throw error(400, 'missing inputs value')
14
  }
15
 
16
- const response = await fetch(SECRET_INFERENCE_API_URL + "/models/" + body.model, {
17
  method: "POST",
18
  headers: {
19
- Authorization: `Bearer ${SECRET_HF_TOKEN}`,
20
  'Content-Type': 'application/json',
21
  ['x-use-cache']: "0"
22
  },
 
1
  import { error, type RequestEvent } from '@sveltejs/kit';
2
+ import { env } from '$env/dynamic/private'
3
 
4
  /** @type {import('./$types').RequestHandler} */
5
  export async function POST({ request }: RequestEvent) {
 
13
  throw error(400, 'missing inputs value')
14
  }
15
 
16
+ const response = await fetch(env.SECRET_INFERENCE_API_URL + "/models/" + body.model, {
17
  method: "POST",
18
  headers: {
19
+ Authorization: `Bearer ${env.SECRET_HF_TOKEN}`,
20
  'Content-Type': 'application/json',
21
  ['x-use-cache']: "0"
22
  },
src/routes/api/text-generation/+server.ts CHANGED
@@ -1,5 +1,5 @@
1
  import { error, json, type RequestEvent } from '@sveltejs/kit';
2
- import { SECRET_HF_TOKEN, SECRET_INFERENCE_API_URL } from '$env/static/private'
3
 
4
  /** @type {import('./$types').RequestHandler} */
5
  export async function POST({ request }: RequestEvent) {
@@ -13,10 +13,10 @@ export async function POST({ request }: RequestEvent) {
13
  throw error(400, 'missing inputs value')
14
  }
15
 
16
- const response = await fetch(SECRET_INFERENCE_API_URL + "/models/" + body.model, {
17
  method: "POST",
18
  headers: {
19
- Authorization: `Bearer ${SECRET_HF_TOKEN}`,
20
  'Content-Type': 'application/json',
21
  ['x-use-cache']: "0"
22
  },
 
1
  import { error, json, type RequestEvent } from '@sveltejs/kit';
2
+ import { env } from '$env/dynamic/private'
3
 
4
  /** @type {import('./$types').RequestHandler} */
5
  export async function POST({ request }: RequestEvent) {
 
13
  throw error(400, 'missing inputs value')
14
  }
15
 
16
+ const response = await fetch(env.SECRET_INFERENCE_API_URL + "/models/" + body.model, {
17
  method: "POST",
18
  headers: {
19
+ Authorization: `Bearer ${env.SECRET_HF_TOKEN}`,
20
  'Content-Type': 'application/json',
21
  ['x-use-cache']: "0"
22
  },