File tree Expand file tree Collapse file tree 3 files changed +110
-0
lines changed Expand file tree Collapse file tree 3 files changed +110
-0
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+ lora: z .boolean (),
11+ });
12+
13+ const { name } = props .parse (Astro .props );
14+
15+ const worker = `
16+ export default {
17+ async fetch(request, env, ctx): Promise<Response> {
18+ const resp = await env.AI.run("${name }", {
19+ "text":"Hello World!"
20+ }, {
21+ returnRawResponse: true
22+ });
23+
24+ return resp;
25+ },
26+ } satisfies ExportedHandler<Env>;
27+ ` ;
28+
29+ const curl = `
30+ curl --request POST \
31+ --url 'https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/${name }' \
32+ --header 'Authorization: Bearer {TOKEN}' \
33+ --header 'Content-Type: application/json' \
34+ --data '{
35+ "text":"Hello world!"
36+ }'
37+ ` ;
38+ ---
39+
40+ <>
41+ <Details header =" Worker" >
42+ <Code code ={ worker } lang =" ts" />
43+ </Details >
44+
45+ <Details header =" curl" >
46+ <Code code ={ curl } lang =" sh" />
47+ </Details >
48+ </>
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+ lora: z .boolean (),
11+ });
12+
13+ const { name } = props .parse (Astro .props );
14+
15+ const worker = `
16+ export default {
17+ async fetch(request, env, ctx): Promise<Response> {
18+ const URL = "https://URL_TO_MP3_FILE/audio.mp3";
19+ const mp3 = await fetch(URL);
20+
21+
22+ const resp = await env.AI.run("${name }", {
23+ "audio": {
24+ body: mp3.body,
25+ contentType: "audio/mpeg"
26+ },
27+ "detect_language": true
28+ }, {
29+ returnRawResponse: true
30+ });
31+ return resp;
32+ },
33+ } satisfies ExportedHandler<Env>; ` ;
34+
35+ const curl = `
36+ curl --request POST \
37+ --url 'https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/deepgram/nova-3?detect_language=true' \
38+ --header 'Authorization: Bearer {TOKEN}' \
39+ --header 'Content-Type: audio/mpeg' \
40+ --data-binary "@/path/to/your-mp3-file.mp3"
41+ ` ;
42+ ---
43+
44+ <>
45+ <Details header =" Worker" >
46+ <Code code ={ worker } lang =" ts" />
47+ </Details >
48+
49+ <Details header =" curl" >
50+ <Code code ={ curl } lang =" sh" />
51+ </Details >
52+ </>
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ import BgeRerankerBase from "~/components/models/code/Bge-Reranker-Base.astro";
2929
3030import { authorData } from " ~/components/models/data" ;
3131import OpenAIResponsesTextGenerationCode from " ~/components/models/code/OpenAIResponsesTextGenerationCode.astro" ;
32+ import DeepgramAura from " ~/components/models/code/DeepgramAura.astro" ;
33+ import DeepgramNova from " ~/components/models/code/DeepgramNova.astro" ;
3234
3335export const getStaticPaths = (async () => {
3436 const models = await getCollection (" workers-ai-models" );
@@ -116,6 +118,14 @@ if (
116118 CodeExamples = OpenAIResponsesTextGenerationCode ;
117119}
118120
121+ if (model .name === " @cf/deepgram/aura-1" ) {
122+ CodeExamples = DeepgramAura ;
123+ }
124+
125+ if (model .name === " @cf/deepgram/nova-3" ) {
126+ CodeExamples = DeepgramNova ;
127+ }
128+
119129const description = model .description ;
120130
121131const isBeta = model .properties .find (
You can’t perform that action at this time.
0 commit comments