diff --git a/src/components/models/code/DeepgramAura.astro b/src/components/models/code/DeepgramAura.astro new file mode 100644 index 00000000000000..d93e2f0821277e --- /dev/null +++ b/src/components/models/code/DeepgramAura.astro @@ -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; + +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 { + const resp = await env.AI.run("${name}", { + "text":"Hello World!" + }, { + returnRawResponse: true + }); + + return resp; + }, +} satisfies ExportedHandler; +`; + +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!" +}' +`; +--- + +<> +
+ +
+ +
+ +
+ diff --git a/src/components/models/code/DeepgramNova.astro b/src/components/models/code/DeepgramNova.astro new file mode 100644 index 00000000000000..27af576d68aa46 --- /dev/null +++ b/src/components/models/code/DeepgramNova.astro @@ -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; + +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 { + const URL = "https://URL_TO_MP3_FILE/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;`; + +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" +`; +--- + +<> +
+ +
+ +
+ +
+ diff --git a/src/pages/workers-ai/models/[name].astro b/src/pages/workers-ai/models/[name].astro index b798aad5519aca..2ce3b94a44418e 100644 --- a/src/pages/workers-ai/models/[name].astro +++ b/src/pages/workers-ai/models/[name].astro @@ -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"); @@ -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( @@ -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