Skip to content

Commit 24f710b

Browse files
hturanKianNH
authored andcommitted
Workers AI Model Catalog & Model Pages (#17068)
* Implement catalog and new model pages * Implement build-time model data fetching * Create prompting guide * Clean up schema handling * Fix schema links * Re-add external links * Fix rehypeExternalLinks import * Fix Models navigation link * Styling fixes for Dark Mode * Implement responsive design * Type fixes * Update Model page types * Add llama-3.2 agreement notice * Fix search types * Add static model fetching * Added flux * Add llama-70b --------- Co-authored-by: Kian <[email protected]>
1 parent 6001711 commit 24f710b

File tree

156 files changed

+3007
-3351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+3007
-3351
lines changed

astro.config.mjs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { h } from "hastscript";
1313
import { readdir } from "fs/promises";
1414
import icon from "astro-icon";
1515
import sitemap from "@astrojs/sitemap";
16+
import react from "@astrojs/react";
1617
import rehypeTitleFigure from "rehype-title-figure";
1718

1819
const runLinkCheck = process.env.RUN_LINK_CHECK || false;
@@ -35,25 +36,35 @@ async function autogenSections() {
3536
};
3637
});
3738
}
38-
3939
const AnchorLinkIcon = h(
4040
"span",
41-
{ ariaHidden: "true", class: "anchor-icon" },
41+
{
42+
ariaHidden: "true",
43+
class: "anchor-icon",
44+
},
4245
h(
4346
"svg",
44-
{ width: 16, height: 16, viewBox: "0 0 24 24" },
47+
{
48+
width: 16,
49+
height: 16,
50+
viewBox: "0 0 24 24",
51+
},
4552
h("path", {
4653
fill: "currentcolor",
4754
d: "m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 0 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 1 0-1.42-1.42Zm8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 0 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 1 0 1.42 1.42l3.88-3.89a4.49 4.49 0 0 0 0-6.33ZM8.83 15.17a1 1 0 0 0 1.1.22 1 1 0 0 0 .32-.22l4.92-4.92a1 1 0 0 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42Z",
4855
}),
4956
),
5057
);
51-
5258
const autolinkConfig = {
53-
properties: { class: "anchor-link" },
59+
properties: {
60+
class: "anchor-link",
61+
},
5462
behavior: "after",
5563
group: ({ tagName }) =>
56-
h("div", { tabIndex: -1, class: `heading-wrapper level-${tagName}` }),
64+
h("div", {
65+
tabIndex: -1,
66+
class: `heading-wrapper level-${tagName}`,
67+
}),
5768
content: () => [AnchorLinkIcon],
5869
};
5970

@@ -89,6 +100,7 @@ export default defineConfig({
89100
},
90101
experimental: {
91102
contentIntellisense: true,
103+
contentLayer: true,
92104
},
93105
server: {
94106
port: 1111,
@@ -196,14 +208,17 @@ export default defineConfig({
196208
tailwind({
197209
applyBaseStyles: false,
198210
}),
199-
liveCode({ layout: "~/components/live-code/Layout.astro" }),
211+
liveCode({
212+
layout: "~/components/live-code/Layout.astro",
213+
}),
200214
icon(),
201215
sitemap({
202216
serialize(item) {
203217
item.lastmod = new Date();
204218
return item;
205219
},
206220
}),
221+
react(),
207222
],
208223
vite: {
209224
build: {

bin/fetch-ai-models.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import fs from "fs";
2+
3+
fetch("https://ai.cloudflare.com/api/models")
4+
.then((res) => res.json())
5+
.then((data) => {
6+
data.models.forEach((model) => {
7+
const fileName = model.name.split("/")[2];
8+
fs.writeFileSync(
9+
`./src/content/workers-ai-models/${fileName}.json`,
10+
JSON.stringify(model),
11+
"utf-8",
12+
);
13+
});
14+
});

0 commit comments

Comments
 (0)