Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/components/models/code/DeepgramAura.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
import { z } from "astro:schema";
import { Code } from "@astrojs/starlight/components";
import Details from "~/components/Details.astro";

type Props = z.infer<typeof props>;

const props = z.object({
name: z.string(),
lora: z.boolean(),
});

const { name } = props.parse(Astro.props);

const worker = `
export default {
async fetch(request, env, ctx): Promise<Response> {
const resp = await env.AI.run("${name}", {
"text":"Hello World!"
}, {
returnRawResponse: true
});

return resp;
},
} satisfies ExportedHandler<Env>;
`;

const curl = `
curl --request POST \
--url 'https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/${name}' \
--header 'Authorization: Bearer {TOKEN}' \
--header 'Content-Type: application/json' \
--data '{
"text":"Hello world!"
}'
`;
---

<>
<Details header="Worker">
<Code code={worker} lang="ts" />
</Details>

<Details header="curl">
<Code code={curl} lang="sh" />
</Details>
</>
52 changes: 52 additions & 0 deletions src/components/models/code/DeepgramNova.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
import { z } from "astro:schema";
import { Code } from "@astrojs/starlight/components";
import Details from "~/components/Details.astro";

type Props = z.infer<typeof props>;

const props = z.object({
name: z.string(),
lora: z.boolean(),
});

const { name } = props.parse(Astro.props);

const worker = `
export default {
async fetch(request, env, ctx): Promise<Response> {
const URL = "https://pub-dbcf9f0bd3af47ca9d40971179ee62de.r2.dev/02f6edc0-1f7b-4272-bd17-f05335104725/audio.mp3";
const mp3 = await fetch(URL);


const resp = await env.AI.run("${name}", {
"audio": {
body: mp3.body,
contentType: "audio/mpeg"
},
"detect_language": true
}, {
returnRawResponse: true
});
return resp;
},
} satisfies ExportedHandler<Env>;`;

const curl = `
curl --request POST \
--url 'https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/deepgram/nova-3?detect_language=true' \
--header 'Authorization: Bearer {TOKEN}' \
--header 'Content-Type: audio/mpeg' \
--data-binary "@/path/to/your-mp3-file.mp3"
`;
---

<>
<Details header="Worker">
<Code code={worker} lang="ts" />
</Details>

<Details header="curl">
<Code code={curl} lang="sh" />
</Details>
</>
13 changes: 11 additions & 2 deletions src/pages/workers-ai/models/[name].astro
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import BgeRerankerBase from "~/components/models/code/Bge-Reranker-Base.astro";

import { authorData } from "~/components/models/data";
import OpenAIResponsesTextGenerationCode from "~/components/models/code/OpenAIResponsesTextGenerationCode.astro";
import DeepgramAura from "~/components/models/code/DeepgramAura.astro";
import DeepgramNova from "~/components/models/code/DeepgramNova.astro";

export const getStaticPaths = (async () => {
const models = await getCollection("workers-ai-models");
Expand Down Expand Up @@ -116,6 +118,14 @@ if (
CodeExamples = OpenAIResponsesTextGenerationCode;
}

if (model.name === "@cf/deepgram/aura-1") {
CodeExamples = DeepgramAura;
}

if (model.name === "@cf/deepgram/nova-3") {
CodeExamples = DeepgramNova;
}

const description = model.description;

const isBeta = model.properties.find(
Expand All @@ -125,11 +135,10 @@ const isBeta = model.properties.find(
let hasPlayground = model.task.name === "Text Generation";

// temporary workaround for playground limitations
if (model.name.includes("@cf/openai/gpt-oss") ) {
if (model.name.includes("@cf/openai/gpt-oss")) {
hasPlayground = false;
}


const author = (authorData as any)[model.name.split("/")[1]];

// Strong type coercion needed due to Starlight's component override for hideTitle
Expand Down