Public
Edited
Aug 10, 2024
2 stars
Insert cell
Insert cell
html`${prompt_html}`
Insert cell
html`<textarea style="width: 80%; height: 10em">${escapeHtml(
prompt_html.replaceAll("<br>", "\n")
)}</textarea>`
Insert cell
prompt_html = text_prompts
.map(
(t) =>
(t.prompt &&
`<h3><a href="https://github.com/Explosion-Scratch/apple-intelligence-prompts/tree/main/${
t.path
}">${t.id}</a>: ${t.description}</h3><code>${escapeHtml(
t.prompt
)}</code>`) ||
""
)
.join("</p><p>")
.replaceAll(/&lt;n&gt;/g, "<br>")
Insert cell
text_prompts = results.map((obj, i) => {
const details = prompts[i];
return { ...details, prompt: Object.values(obj.promptTemplates || {})[0] };
})
Insert cell
html`<textarea style="width: 80%; height: 10em">${JSON.stringify(
text_prompts,
null,
4
)}</textarea>`
Insert cell
results = await Promise.all(
prompts.map(async (prompt) => {
const response = await fetch(
"https://raw.githubusercontent.com/Explosion-Scratch/apple-intelligence-prompts/main/" +
prompt.path
);
return response.json();
})
)
Insert cell
html`<textarea>${prompts[0].path}`
Insert cell
prompts = parseTextToJSON(readme)
Insert cell
readme = (
await fetch(
"https://raw.githubusercontent.com/Explosion-Scratch/apple-intelligence-prompts/main/README.md"
)
).text()
Insert cell
function parseTextToJSON(text) {
const result = [];

// Extract file information
const fileRegex = /- \[([^\]]+)\]\(([^:]+)\):\s*(.*)/g;
let match;

while ((match = fileRegex.exec(text)) !== null) {
result.push({
id: match[1],
path: match[2].trim(),
description: match[3].trim()
});
}

return result;
}
Insert cell
function escapeHtml(s) {
return s.replace(/[&<>"']/g, function (m) {
const map = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#39;"
};
return map[m];
});
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more