this repo has no description

Update prompt and reorder root

Changed files
+23 -13
src
+8 -4
src/page.ts
···
}
}
getPage(url: URL) {
let page = this.#pages.get(url.toString());
if (!page) {
···
}
}
-
async function crawlPages(page: Page, visited = new Set<Page>([page])): Promise<Page[]> {
const links = await page.getLinks();
if (links) {
-
log(`crawling (${links.length} links)`, page.url.pathname);
for (const link of links) {
if (visited.has(link)) {
continue;
} else {
visited.add(page);
-
await crawlPages(link, visited);
}
}
}
···
}
}
const kruskal = new KruskalMST(graph);
-
const output = new Set<Page>();
for (const edge of kruskal.mst) {
const page = pages[edge.from()];
if (page) output.add(page);
···
}
}
+
get origin() {
+
return this.#origin;
+
}
+
getPage(url: URL) {
let page = this.#pages.get(url.toString());
if (!page) {
···
}
}
+
async function crawlPages(page: Page, visited = new Set<Page>([page]), depth = 1): Promise<Page[]> {
const links = await page.getLinks();
if (links) {
+
log(`crawling (${links.length} links, depth = ${depth})`, page.url.pathname);
for (const link of links) {
if (visited.has(link)) {
continue;
} else {
visited.add(page);
+
await crawlPages(link, visited, depth + 1);
}
}
}
···
}
}
const kruskal = new KruskalMST(graph);
+
const output = new Set<Page>([root.origin]);
for (const edge of kruskal.mst) {
const page = pages[edge.from()];
if (page) output.add(page);
+15 -9
src/rewrite.ts
···
const SYSTEM_PROMPT = `
Reformat markdown content you're given into an llms-full.txt file, also in markdown format
-
- Where the format isn't easily understandable by AI, reformat it faithfully to make it processable
-
- Reformat for an AI and paraphrase where necessary, but don't add interpretations
-
- Preserve code snippets and keep them in TypeScript or TypeScript typings format
-
- Avoid using emphasis or excessive markdown syntax, but keep code snippets where they are
-
- Don't mention other content, pages, or external content (Remove sentences such as "Refer to", "Read more")
-
- When encountering a markdown table, ensure that you don't output a separate legend, and keep all relevant information in the table
-
- Don't use any knowledge you may have on the subject. Only output what you're given.
`;
const ai = createOpenAI({
···
const { text } = await generateText({
model: createFallback({
models: [
-
ollama('gemma:7b'),
-
ai('@hf/google/gemma-7b-it'),
],
onError(error, modelId) {
log(`error using model ${modelId}`, error);
},
}),
system: SYSTEM_PROMPT.trim(),
prompt: input,
});
···
const SYSTEM_PROMPT = `
Reformat markdown content you're given into an llms-full.txt file, also in markdown format
+
- Reformat for an AI and paraphrase where necessary, but be faithful to the original
+
- Avoid using emphasis and use Github Flavored markdown syntax
+
- Keep code snippets and keep them in TypeScript or TypeScript typings format
+
- Don't mention other content, pages, or external content (Remove sentences such as "Refer to", "Read more", "Learn how to")
+
- For markdown tables, keep all relevant information in the table and remove table legends and emoji
+
- Remove icon legends or irrelevant text
+
- Don't add to the content or use any knowledge you may have on the subject
+
- Format the output in AI-friendly markdown and preserve inline code
+
- Remove sub-headings if they don't add crucial information or context
+
- Don't wrap your output in a code block
`;
const ai = createOpenAI({
···
const { text } = await generateText({
model: createFallback({
models: [
+
ollama('mistral-small3.1:24b'),
+
ai('@cf/mistralai/mistral-small-3.1-24b-instruct'),
],
onError(error, modelId) {
log(`error using model ${modelId}`, error);
},
}),
+
maxSteps: 5,
+
experimental_continueSteps: true,
+
temperature: 0.05,
system: SYSTEM_PROMPT.trim(),
prompt: input,
});