File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ import { z } from " astro:schema" ;
3+ import { Code } from " @astrojs/starlight/components" ;
4+ import Details from " ~/components/Details.astro" ;
5+
6+ type Props = z .infer <typeof props >;
7+
8+ const props = z .object ({
9+ name: z .string (),
10+ });
11+
12+ const { name } = props .parse (Astro .props );
13+
14+ const worker = `
15+ export interface Env {
16+ AI: Ai;
17+ }
18+
19+ export default {
20+ async fetch(request, env): Promise<Response> {
21+ const { audio } = await env.AI.run('${name }', {
22+ prompt: 'Hello world',
23+ lang: 'en',
24+ });
25+ // Returns the base64 encoded MP3 audio
26+ return Response.json({ audio });
27+ },
28+ } satisfies ExportedHandler<Env>; ` ;
29+ ---
30+
31+ <Details header =" Workers - TypeScript" >
32+ <Code code ={ worker } lang =" ts" />
33+ </Details >
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import StableDiffusionV15Img2ImgCode from "~/components/models/code/StableDiffus
2323import StableDiffusionV15InpaintingCode from " ~/components/models/code/StableDiffusion-v1-5-inpaintingCode.astro" ;
2424import Flux1Schnell from " ~/components/models/code/Flux-1-Schnell.astro" ;
2525import WhisperBase64Code from " ~/components/models/code/WhisperBase64Code.astro" ;
26+ import MelottsCode from " ~/components/models/code/MelottsCode.astro" ;
2627import LlamaGuard from " ~/components/models/code/LlamaGuard.astro" ;
2728import BgeRerankerBase from " ~/components/models/code/Bge-Reranker-Base.astro" ;
2829
@@ -95,6 +96,10 @@ if (model.name === "@cf/openai/whisper-large-v3-turbo") {
9596 CodeExamples = WhisperBase64Code ;
9697}
9798
99+ if (model .name === " @cf/myshell-ai/melotts" ) {
100+ CodeExamples = MelottsCode ;
101+ }
102+
98103if (model .name === " @cf/meta/llama-guard-3-8b" ) {
99104 CodeExamples = LlamaGuard ;
100105}
@@ -251,4 +256,4 @@ const starlightPageProps = {
251256 <Code code ={ JSON .stringify (model .schema .output , null , 4 )} lang =" json" />
252257 </TabItem >
253258 </Tabs >
254- </StarlightPage >
259+ </StarlightPage >
You can’t perform that action at this time.
0 commit comments