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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more