Repository: severus27/OpenML-Guide
Branch: main
Commit: addca949df70
Files: 59
Total size: 89.8 KB
Directory structure:
gitextract_b1h8jdvd/
├── .env-example
├── .gitignore
├── CITATION.cff
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── app/
│ ├── [lang]/
│ │ ├── (home)/
│ │ │ ├── layout.tsx
│ │ │ └── page.tsx
│ │ ├── api/
│ │ │ └── search/
│ │ │ └── route.ts
│ │ ├── docs/
│ │ │ ├── [[...slug]]/
│ │ │ │ └── page.tsx
│ │ │ ├── layout.tsx
│ │ │ └── raw/
│ │ │ └── [...slug]/
│ │ │ └── route.ts
│ │ ├── global.css
│ │ ├── layout.tsx
│ │ └── llms.mdx/
│ │ └── [[...slug]]/
│ │ └── route.ts
│ ├── layout.config.tsx
│ └── llms-full.txt/
│ └── route.ts
├── components/
│ ├── ai/
│ │ └── page-actions.tsx
│ ├── banner.tsx
│ ├── feedback.tsx
│ ├── footer.tsx
│ └── mdx/
│ └── mermaid.tsx
├── content/
│ └── docs/
│ ├── math/
│ │ ├── index.mdx
│ │ └── meta.json
│ ├── meta.json
│ └── python/
│ ├── index.mdx
│ ├── matplotlib/
│ │ └── index.mdx
│ ├── meta.json
│ ├── numpy/
│ │ └── index.mdx
│ ├── pandas/
│ │ └── index.mdx
│ ├── python/
│ │ ├── control-flow.mdx
│ │ ├── data-structures.mdx
│ │ ├── data-types.mdx
│ │ ├── error-handling.mdx
│ │ ├── file-handling.mdx
│ │ ├── functions.mdx
│ │ ├── hello-world.mdx
│ │ ├── index.mdx
│ │ ├── meta.json
│ │ ├── oop.mdx
│ │ └── operators.mdx
│ ├── scikit-learn/
│ │ └── index.mdx
│ └── setup.mdx
├── lib/
│ ├── cn.ts
│ ├── get-llm-text.ts
│ ├── github.ts
│ ├── i18n.ts
│ ├── metadata.ts
│ └── source.ts
├── mdx-components.tsx
├── next.config.mjs
├── package.json
├── postcss.config.mjs
├── proxy.ts
├── source.config.ts
├── tsconfig.json
└── utils/
└── process-markdown-links.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .env-example
================================================
GITHUB_APP_ID=app_id
GITHUB_APP_PRIVATE_KEY="-----Base64 encoded GitHub App private key-----"
================================================
FILE: .gitignore
================================================
# deps
/node_modules
# generated content
.contentlayer
.content-collections
.source
# test & build
/coverage
/.next/
/out/
/build
*.tsbuildinfo
# misc
.DS_Store
*.pem
/.pnp
.pnp.js
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# others
.env*.local
.vercel
next-env.d.ts
================================================
FILE: CITATION.cff
================================================
cff-version: 1.2.0
title: AIcademy
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Epsilon
repository-code: "https://github.com/aicademyorg/AIcademy"
url: "https://theaicademy.org"
abstract: A friendly community offering free AI education.
license: MIT
date-released: "2023-03-25"
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Code of Conduct
AIcademy is a friendly place to learn about AI. We’re committed to keeping it that way.
By using AIcademy, you agree to follow this Code of Conduct.
In short: **Be kind**. **No harassment**, **trolling**, or **spamming**.
- **Harassment**: We don’t allow behavior that targets or demeans individuals or groups. This includes offensive comments, unwanted attention, doxxing, stalking, slurs, or anything that makes others feel unsafe — regardless of gender, background, identity, ability, or beliefs.
- **Trolling**: Provoking arguments, derailing discussions, or posting deliberately disruptive messages wastes everyone's time. Stay constructive and kind, even when disagreeing.
- **Spamming**: Posting irrelevant links, excessive self-promotion, or repeatedly sharing off-topic content disrupts the learning experience. Keep the space clean and focused.
If you see someone harassing, trolling, or spamming in any part of the AIcademy community (website, GitHub, discussions, discord etc.), please email us at [`hiaicademy@gmail.com`](mailto:hiaicademy@gmail.com) — ideally with a screenshot or link to the incident.
The moderator team will take any action we believe necessary to keep AIcademy a safe, respectful space — including content removal or account bans.
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to AIcademy
Thank you for your interest in contributing to AIcademy.
Whether you're fixing a typo, improving content, or adding new features, your contributions are appreciated.
## How to Contribute
1. Fork this repository
2. Create a new branch
3. Make your changes
4. Open a pull request with a clear description
Please keep changes focused and respectful. For questions or suggestions, feel free to open an issue or email us at `hiaicademy@gmail.com`.
By contributing, you agree to follow our [Code of Conduct](https://github.com/aicademyorg/AIcademy/blob/main/CODE_OF_CONDUCT.md).
================================================
FILE: LICENSE
================================================
MIT License
Copyright © 2025 AIcademy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# AIcademy
AIcademy is a friendly community offering free AI education.
## Installation
Ensure [pnpm](https://pnpm.io) is installed on your system.
```
# install the dependencies.
pnpm install
# start the development server
pnpm dev
```
The server will be running at [http://localhost:3000](http://localhost:3000).
## Contributing
Contributions are welcome! Whether you're improving content, fixing bugs, or adding new features, your help makes AIcademy better for everyone.
> [Please follow these steps to contribute](/CONTRIBUTING.md).
Recent Contributions:

## License
Copyright © 2025 AIcademy
AIcademy is open-source and released under the MIT License.
================================================
FILE: SECURITY.md
================================================
# Security Policy
At AIcademy, we take platform security seriously.
While we don’t collect personal data or require sign-ups, we’re committed to keeping our open-source learning environment safe and trustworthy for everyone.
### Reporting a Vulnerability
If you discover a security issue in our website or codebase, please report it privately by emailing:
📧 **hiaicademy@gmail.com**
We appreciate responsible disclosures and will review all reports promptly. Please avoid public disclosure until we’ve had a chance to investigate and address the issue.
Thank you for helping keep AIcademy safe.
================================================
FILE: app/[lang]/(home)/layout.tsx
================================================
import type { ReactNode } from "react";
import { HomeLayout } from "fumadocs-ui/layouts/home";
import { baseOptions, linkItems } from "@/app/layout.config";
import {
NavbarMenu,
NavbarMenuContent,
NavbarMenuLink,
NavbarMenuTrigger,
} from "fumadocs-ui/layouts/home/navbar";
import { Footer } from "@/components/footer";
import Link from "fumadocs-core/link";
import Image from "next/image";
import Preview from "@/public/learn/python/banner.png";
import { Code } from "lucide-react";
export default async function Layout({
params,
children,
}: {
params: Promise<{ lang: string }>;
children: ReactNode;
}) {
const { lang } = await params;
return (
<HomeLayout
{...baseOptions(lang)}
links={[
{
type: "custom",
on: "nav",
children: (
<NavbarMenu>
<NavbarMenuTrigger>
<Link href="/docs/python">Learn</Link>
</NavbarMenuTrigger>
<NavbarMenuContent className="text-[15px]">
<NavbarMenuLink href="/docs/python" className="md:row-span-2">
<div className="-mx-3 -mt-3">
<Image
src={Preview}
alt="Perview"
className="rounded-t-lg object-cover"
style={{
maskImage:
"linear-gradient(to bottom,white 60%,transparent)",
}}
/>
</div>
<p className="font-medium">Python</p>
<p className="text-fd-muted-foreground text-sm">
Learn Python for Data Science
</p>
</NavbarMenuLink>
<NavbarMenuLink href="/docs/pytorch" className="lg:col-start-2">
<Code className="bg-fd-primary text-fd-primary-foreground p-1 mb-2 rounded-md" />
<p className="font-medium">Pytorch</p>
<p className="text-fd-muted-foreground text-sm">
Learn Pytorch
</p>
</NavbarMenuLink>
<NavbarMenuLink
href="/docs/deeplearning"
className="lg:col-start-2"
>
<Code className="bg-fd-primary text-fd-primary-foreground p-1 mb-2 rounded-md" />
<p className="font-medium">Deep Learning</p>
<p className="text-fd-muted-foreground text-sm">
Learn Deep Learning
</p>
</NavbarMenuLink>
<NavbarMenuLink
href="/docs/ml"
className="lg:col-start-3 lg:row-start-1"
>
<Code className="bg-fd-primary text-fd-primary-foreground p-1 mb-2 rounded-md" />
<p className="font-medium">Machine Learning</p>
<p className="text-fd-muted-foreground text-sm">
Learn machine learning
</p>
</NavbarMenuLink>
</NavbarMenuContent>
</NavbarMenu>
),
},
{
icon: <Code />,
text: "Blog",
url: "/blog",
active: "nested-url",
},
{
icon: <Code />,
text: "About",
url: "/about",
},
...linkItems,
]}
className="dark:bg-neutral-950 dark:[--color-fd-background:var(--color-neutral-950)]"
>
{children}
<Footer />
</HomeLayout>
);
}
================================================
FILE: app/[lang]/(home)/page.tsx
================================================
import Link from 'next/link';
export default function HomePage() {
return (
<main
style={{
flex: 1,
display: 'flex',
flexDirection: 'column',
textAlign: 'center',
justifyContent: 'center',
}}
>
<h1
style={{
fontSize: '2rem',
fontWeight: 'bold',
marginBottom: '1rem',
}}
>
Hello World
</h1>
<p>
You can open{' '}
<Link
href="/docs"
style={{
fontWeight: '600',
textDecoration: 'underline',
}}
>
/docs
</Link>{' '}
and see the documentation.
</p>
</main>
);
}
================================================
FILE: app/[lang]/api/search/route.ts
================================================
import { source } from '@/lib/source';
import { createFromSource } from 'fumadocs-core/search/server';
export const { GET } = createFromSource(source);
================================================
FILE: app/[lang]/docs/[[...slug]]/page.tsx
================================================
import { source } from "@/lib/source";
import {
DocsPage,
DocsBody,
DocsDescription,
DocsTitle,
PageLastUpdate,
} from "fumadocs-ui/layouts/docs/page";
import { notFound } from "next/navigation";
import { createRelativeLink } from "fumadocs-ui/mdx";
import { getMDXComponents } from "@/mdx-components";
import { getGithubLastEdit } from "fumadocs-core/content/github";
import { getPageTreePeers } from "fumadocs-core/page-tree";
import { Feedback } from "@/components/feedback";
import { onRateAction } from "@/lib/github";
import { i18n } from "@/lib/i18n";
import { Card, Cards } from "fumadocs-ui/components/card";
import { LLMCopyButtonWithDropdown } from "@/components/ai/page-actions";
import { SquarePen } from "lucide-react";
function DocsCategory({ url, lang }: { url: string; lang: string }) {
return (
<Cards>
{getPageTreePeers(source.pageTree[lang], url).map((peer) => (
<Card key={peer.url} title={peer.name} href={peer.url}>
{peer.description}
</Card>
))}
</Cards>
);
}
export default async function Page(props: {
params: Promise<{ lang: string; slug?: string[] }>;
}) {
const { slug, lang } = await props.params;
const page = source.getPage(slug, lang);
if (!page) notFound();
const MDXContent = page.data.body;
let githubPath: string;
if (lang === i18n.defaultLanguage) {
githubPath = `content/docs/${page.path}`;
} else {
githubPath = `content/docs/${page.path.replace(/\.mdx$/, `.${lang}.mdx`)}`;
}
const lastModifiedTime = await getGithubLastEdit({
owner: "aicademyorg",
repo: "aicademy",
path: githubPath,
token: process.env.GITHUB_TOKEN,
});
const githubUrl = `https://github.com/aicademyorg/aicademy/blob/main/${githubPath}`;
return (
<DocsPage
toc={page.data.toc}
full={page.data.full}
tableOfContent={{
style: "clerk",
single: false,
}}
>
<div className="flex flex-col sm:flex-row sm:justify-between sm:items-start">
<div className="flex-1">
<DocsTitle>{page.data.title}</DocsTitle>
<div className="mt-4">
<DocsDescription>{page.data.description}</DocsDescription>
</div>
</div>
<div className="flex-shrink-0 sm:ml-4 pb-4 sm:pb-0">
<LLMCopyButtonWithDropdown
markdownUrl={`${page.url}.mdx`}
githubUrl={githubUrl}
colab={page.data.colab}
/>
</div>
</div>
<DocsBody className="max-sm:pb-16">
<MDXContent
components={getMDXComponents({
a: createRelativeLink(source, page),
DocsCategory: ({ url }) => {
return <DocsCategory url={url ?? page.url} lang={lang} />;
},
})}
/>
{page.data.index && <DocsCategory url={page.url} lang={lang} />}
</DocsBody>
<Feedback onRateAction={onRateAction} lang={lang} />
<div className="flex items-center justify-between">
<a
href={githubUrl}
rel="noreferrer noopener"
target="_blank"
className="w-fit border rounded-lg py-1.5 px-2 font-medium text-xs text-fd-secondary-foreground bg-fd-secondary transition-colors hover:text-fd-accent-foreground hover:bg-fd-accent inline-flex items-center gap-1.5"
>
<SquarePen className="size-3.5" />
Edit on GitHub
</a>
{lastModifiedTime && <PageLastUpdate date={lastModifiedTime} />}
</div>
</DocsPage>
);
}
export async function generateStaticParams() {
return source.generateParams("slug", "lang");
}
export async function generateMetadata(props: {
params: Promise<{ lang: string; slug?: string[] }>;
}) {
const { slug, lang } = await props.params;
const page = source.getPage(slug, lang);
if (!page) notFound();
return {
title: page.data.title,
description: page.data.description,
};
}
================================================
FILE: app/[lang]/docs/layout.tsx
================================================
import { DocsLayout, type DocsLayoutProps } from "fumadocs-ui/layouts/docs";
import type { ReactNode } from "react";
import { baseOptions, linkItems } from "@/app/layout.config";
import { source } from "@/lib/source";
// import { Footer } from "@/components/footer";
const docsOptions: DocsLayoutProps = {
...baseOptions,
tree: source.pageTree as any,
links: linkItems,
sidebar: {
tabs: {
transform(option, node) {
const meta = source.getNodeMeta(node);
if (!meta || !node.icon) return option;
const color = `var(--ui-color)`;
return {
...option,
icon: (
<div
className="[&_svg]:size-11/12 rounded-lg size-full max-md:bg-(--tab-color)/10 max-md:border max-md:p-1.5"
style={
{
color,
"--tab-color": color,
} as object
}
>
{node.icon}
</div>
),
};
},
},
},
};
export default async function Layout({
params,
children,
}: {
params: Promise<{ lang: string }>;
children: ReactNode;
}) {
const { lang } = await params;
return (
<DocsLayout
{...baseOptions(lang)}
{...docsOptions}
tree={source.pageTree[lang]}
>
{children}
{/* <Footer /> */}
</DocsLayout>
);
}
================================================
FILE: app/[lang]/docs/raw/[...slug]/route.ts
================================================
import { existsSync } from 'node:fs';
import { readdir, readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { type NextRequest, NextResponse } from 'next/server';
async function findFileWithParentheses(
basePath: string,
segments: string[],
): Promise<string | null> {
if (segments.length === 0) return null;
const [current, ...rest] = segments;
const currentPath = join(basePath, current);
if (rest.length === 0) {
if (existsSync(currentPath)) {
return currentPath;
}
} else if (existsSync(currentPath)) {
const found = await findFileWithParentheses(currentPath, rest);
if (found) return found;
}
try {
const entries = await readdir(basePath, { withFileTypes: true });
for (const entry of entries) {
if (entry.isDirectory() && entry.name.startsWith('(') && entry.name.endsWith(')')) {
const parenthesesPath = join(basePath, entry.name);
if (rest.length === 0) {
const filePath = join(parenthesesPath, current);
if (existsSync(filePath)) {
return filePath;
}
} else {
const found = await findFileWithParentheses(parenthesesPath, [current, ...rest]);
if (found) return found;
}
}
}
} catch (error) {
console.error(error);
}
return null;
}
export async function GET(
_request: NextRequest,
{ params }: { params: Promise<{ slug: string[] }> },
) {
try {
const { slug = [] } = await params;
const basePath = join(process.cwd(), 'content/docs');
const directPath = join(basePath, ...slug);
if (existsSync(directPath)) {
const content = await readFile(directPath, 'utf-8');
return new NextResponse(content, {
headers: {
'Content-Type': 'text/markdown; charset=utf-8',
},
});
}
const foundPath = await findFileWithParentheses(basePath, slug);
if (foundPath) {
const content = await readFile(foundPath, 'utf-8');
return new NextResponse(content, {
headers: {
'Content-Type': 'text/markdown; charset=utf-8',
},
});
}
return new NextResponse('File not found', { status: 404 });
} catch (error) {
return new NextResponse('File not found', { status: 404 });
}
}
================================================
FILE: app/[lang]/global.css
================================================
@import "tailwindcss";
@import "fumadocs-ui/css/neutral.css";
@import "fumadocs-ui/css/preset.css";
:root {
--purple-color: #2563eb;
--ui-color: #2563eb;
--color-fd-primary: var(--ui-color);
}
body {
overscroll-behavior-y: none;
background-color: var(--color-fd-background);
}
.dark {
--purple-color: #818cf8;
--ui-color: #60a5fa;
--color-fd-primary: var(--ui-color);
}
================================================
FILE: app/[lang]/layout.tsx
================================================
import "./global.css";
import "katex/dist/katex.css";
import { RootProvider } from 'fumadocs-ui/provider/next';
import { defineI18nUI } from "fumadocs-ui/i18n";
import type { ReactNode } from "react";
import { Inter, Geist, Geist_Mono } from "next/font/google";
import { baseUrl, createMetadata } from "@/lib/metadata";
import { i18n, uiDictionary } from "@/lib/i18n";
import { Metadata } from "next";
const { provider } = defineI18nUI(i18n, {
translations: {
en: {
displayName: "English",
},
// Add other languages
// cn: {
// displayName: 'Chinese',
// search: '搜尋文檔',
// },
},
});
export async function generateMetadata({
params,
}: {
params: Promise<{ lang: string }>;
}): Promise<Metadata> {
const lang = (await params).lang;
const t =
uiDictionary[lang as keyof typeof uiDictionary]?.metadata ||
uiDictionary.en.metadata;
return createMetadata({
title: {
template: t.titleTemplate,
default: t.defaultTitle,
},
description: t.description,
metadataBase: baseUrl,
});
}
const geist = Geist({
variable: "--font-sans",
subsets: ["latin"],
});
const mono = Geist_Mono({
variable: "--font-mono",
subsets: ["latin"],
});
export const inter = Inter({
subsets: ['latin'],
variable: '--font-inter',
})
export default async function RootLayout({
params,
children,
}: {
params: Promise<{ lang: string }>;
children: ReactNode;
}) {
const lang = (await params).lang;
return (
<html
lang={lang}
className={`${inter.className} ${mono.variable}`}
suppressHydrationWarning
>
<body
className="bg-neutral-100 dark:bg-neutral-900"
style={{
display: "flex",
flexDirection: "column",
minHeight: "100vh",
}}
>
<RootProvider i18n={provider(lang)}>{children}</RootProvider>
</body>
</html>
);
}
================================================
FILE: app/[lang]/llms.mdx/[[...slug]]/route.ts
================================================
import { type NextRequest, NextResponse } from "next/server";
import { getLLMText } from "@/lib/get-llm-text";
import { source } from "@/lib/source";
import { notFound } from "next/navigation";
export const revalidate = false;
export async function GET(
_req: NextRequest,
{ params }: { params: Promise<{ lang: string; slug?: string[] }> }
) {
const { slug, lang } = await params;
const page = source.getPage(slug, lang);
if (!page) notFound();
return new NextResponse(await getLLMText(page));
}
export function generateStaticParams() {
return source.generateParams();
}
================================================
FILE: app/layout.config.tsx
================================================
import type { LinkItemType } from "fumadocs-ui/layouts/shared";
import type { BaseLayoutProps } from "fumadocs-ui/layouts/shared";
import { i18n, uiDictionary } from "@/lib/i18n";
import { SiDiscord, SiGithub } from "react-icons/si";
export const linkItems: LinkItemType[] = [
{
type: "icon",
icon: <SiGithub />,
text: "Github",
url: "https://github.com/aicademyorg/AIcademy",
},
{
type: "icon",
icon: <SiDiscord />,
text: "Discord",
url: "https://discord.com/invite/bxnwugmNZg",
},
];
export const logo = (
<>
<svg
className="dark:hidden w-5 md:w-5 text-[color:var(--ui-color)]"
role="img"
aria-label="AIcademy Logo"
viewBox="0 0 500 500"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M228.5 0.981853C153.412 5.91485 79.941 49.8029 39.811 113.693C0.252014 176.676 -8.69499 254.291 15.048 328.504C18.912 340.58 26.616 358.778 32.192 369C34.442 373.125 37.864 379.425 39.796 383C52.807 407.077 79.559 438.119 101.687 454.816C124.459 471.999 152.044 485.119 180.936 492.508C195.886 496.331 206.088 497.862 225.238 499.158C281.901 502.99 339.138 488.09 385.929 457.325C441.019 421.104 479.598 364.441 492.911 300.196C500.335 264.368 499.452 223.317 490.498 187.991C471.541 113.207 418.007 50.6099 346.961 20.1519C310.593 4.55985 271.158 -1.82115 228.5 0.981853ZM231.5 76.6679C177.356 83.3199 133.235 109.92 105.127 152.859C101.757 158.007 99 162.582 99 163.026C99 163.469 104.514 161.057 111.253 157.666C134.392 146.021 153.558 141.155 179.665 140.296C206.546 139.412 227.571 143.077 250.054 152.567C323.985 183.773 364.869 262.271 347.936 340.5C342.801 364.225 333.213 384.653 316.28 407.949C314.841 409.928 317.028 409.084 327.71 403.534C376.693 378.088 409.271 333.885 419.688 278.736C422.427 264.236 422.158 232.102 419.173 217.166C407.241 157.465 366.457 108.691 310.623 87.3509C290.861 79.7969 269.155 75.9519 247.5 76.1689C240.35 76.2409 233.15 76.4659 231.5 76.6679ZM168 217.373C149.565 221.641 135.627 229.236 122.932 241.932C93.858 271.005 88.206 315.596 109.087 351.171C121.665 372.601 137.318 386.073 156.445 391.929C176.253 397.994 202.672 396.021 222.676 386.983C271.44 364.951 290.377 305.477 263.206 259.694C251.597 240.133 230.633 224.188 209 218.466C200.559 216.233 175.778 215.573 168 217.373Z"
/>
</svg>
<svg
className="hidden dark:flex w-5 md:w-5 text-[color:var(--ui-color)]"
role="img"
aria-label="AIcademy Logo"
viewBox="0 0 500 500"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M228.5 0.981853C153.412 5.91485 79.941 49.8029 39.811 113.693C0.252014 176.676 -8.69499 254.291 15.048 328.504C18.912 340.58 26.616 358.778 32.192 369C34.442 373.125 37.864 379.425 39.796 383C52.807 407.077 79.559 438.119 101.687 454.816C124.459 471.999 152.044 485.119 180.936 492.508C195.886 496.331 206.088 497.862 225.238 499.158C281.901 502.99 339.138 488.09 385.929 457.325C441.019 421.104 479.598 364.441 492.911 300.196C500.335 264.368 499.452 223.317 490.498 187.991C471.541 113.207 418.007 50.6099 346.961 20.1519C310.593 4.55985 271.158 -1.82115 228.5 0.981853ZM231.5 76.6679C177.356 83.3199 133.235 109.92 105.127 152.859C101.757 158.007 99 162.582 99 163.026C99 163.469 104.514 161.057 111.253 157.666C134.392 146.021 153.558 141.155 179.665 140.296C206.546 139.412 227.571 143.077 250.054 152.567C323.985 183.773 364.869 262.271 347.936 340.5C342.801 364.225 333.213 384.653 316.28 407.949C314.841 409.928 317.028 409.084 327.71 403.534C376.693 378.088 409.271 333.885 419.688 278.736C422.427 264.236 422.158 232.102 419.173 217.166C407.241 157.465 366.457 108.691 310.623 87.3509C290.861 79.7969 269.155 75.9519 247.5 76.1689C240.35 76.2409 233.15 76.4659 231.5 76.6679ZM168 217.373C149.565 221.641 135.627 229.236 122.932 241.932C93.858 271.005 88.206 315.596 109.087 351.171C121.665 372.601 137.318 386.073 156.445 391.929C176.253 397.994 202.672 396.021 222.676 386.983C271.44 364.951 290.377 305.477 263.206 259.694C251.597 240.133 230.633 224.188 209 218.466C200.559 216.233 175.778 215.573 168 217.373Z"
/>
</svg>
</>
);
export function baseOptions(locale: string): BaseLayoutProps {
const navLinks =
uiDictionary[locale as keyof typeof uiDictionary]?.nav?.navigation ||
uiDictionary.en.nav.navigation;
return {
i18n,
nav: {
title: (
<>
{logo}
<span className="text-[15px] font-medium">
<span>AIcademy</span>
</span>
</>
),
url: locale === i18n.defaultLanguage ? "/" : `/${locale}`,
transparentMode: "top",
},
links: [
...navLinks.map((link) => ({
text: link.name,
url: link.href,
})),
],
};
}
================================================
FILE: app/llms-full.txt/route.ts
================================================
import { source } from "@/lib/source";
import { getLLMText } from "@/lib/get-llm-text";
// cached forever
export const revalidate = false;
export async function GET() {
const scan = source.getPages().map(getLLMText);
const scanned = await Promise.all(scan);
return new Response(scanned.join("\n\n"));
}
================================================
FILE: components/ai/page-actions.tsx
================================================
"use client";
import { useMemo, useState } from "react";
import { Check, ChevronDown, Copy, ExternalLinkIcon } from "lucide-react";
import { usePathname } from "next/navigation";
import { cn } from "../../lib/cn";
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
import { buttonVariants } from "fumadocs-ui/components/ui/button";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "fumadocs-ui/components/ui/popover";
import { cva } from "class-variance-authority";
const cache = new Map<string, string>();
export function LLMCopyButton({ markdownUrl }: { markdownUrl: string }) {
const [isLoading, setLoading] = useState(false);
const [checked, onClick] = useCopyButton(async () => {
const cached = cache.get(markdownUrl);
if (cached) return navigator.clipboard.writeText(cached);
setLoading(true);
try {
await navigator.clipboard.write([
new ClipboardItem({
"text/plain": fetch(markdownUrl).then(async (res) => {
const content = await res.text();
cache.set(markdownUrl, content);
return content;
}),
}),
]);
} finally {
setLoading(false);
}
});
return (
<button
disabled={isLoading}
className={cn(
buttonVariants({
color: "secondary",
size: "sm",
className: "gap-2 [&_svg]:size-3.5 [&_svg]:text-fd-muted-foreground",
})
)}
onClick={onClick}
>
{checked ? <Check /> : <Copy />}
Copy Markdown
</button>
);
}
export function LLMCopyButtonWithDropdown({
markdownUrl,
githubUrl,
colab,
}: {
markdownUrl: string;
githubUrl: string;
colab?: string;
}) {
const [isLoading, setLoading] = useState(false);
const [isOpen, setIsOpen] = useState(false);
const pathname = usePathname();
const [checked, onClick] = useCopyButton(async () => {
const cached = cache.get(markdownUrl);
if (cached) return navigator.clipboard.writeText(cached);
setLoading(true);
try {
await navigator.clipboard.write([
new ClipboardItem({
"text/plain": fetch(markdownUrl).then(async (res) => {
const content = await res.text();
cache.set(markdownUrl, content);
return content;
}),
}),
]);
} finally {
setLoading(false);
}
});
const handleViewMarkdown = () => {
if (!pathname) return;
// Open the current path with .md extension in a new window
window.open(`${pathname}.md`, "_blank");
};
const items = useMemo(() => {
const fullMarkdownUrl =
typeof window !== "undefined"
? new URL(markdownUrl, window.location.origin)
: "loading";
const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
const items = [
{
title: "View as Markdown",
onClick: handleViewMarkdown,
icon: (
<svg strokeLinejoin="round" viewBox="0 0 22 16">
<path
fillRule="evenodd"
clipRule="evenodd"
d="M19.5 2.25H2.5C1.80964 2.25 1.25 2.80964 1.25 3.5V12.5C1.25 13.1904 1.80964 13.75 2.5 13.75H19.5C20.1904 13.75 20.75 13.1904 20.75 12.5V3.5C20.75 2.80964 20.1904 2.25 19.5 2.25ZM2.5 1C1.11929 1 0 2.11929 0 3.5V12.5C0 13.8807 1.11929 15 2.5 15H19.5C20.8807 15 22 13.8807 22 12.5V3.5C22 2.11929 20.8807 1 19.5 1H2.5ZM3 4.5H4H4.25H4.6899L4.98715 4.82428L7 7.02011L9.01285 4.82428L9.3101 4.5H9.75H10H11V5.5V11.5H9V7.79807L7.73715 9.17572L7 9.97989L6.26285 9.17572L5 7.79807V11.5H3V5.5V4.5ZM15 8V4.5H17V8H19.5L17 10.5L16 11.5L15 10.5L12.5 8H15Z"
fill="currentColor"
/>
</svg>
),
},
...(colab
? [
{
title: "Open in Colab",
href: colab,
icon: (
<svg fill="currentColor" role="img" viewBox="0 0 24 24">
<title>Google Colab</title>
<path d="M16.9414 4.9757a7.033 7.033 0 0 0-4.9308 2.0646 7.033 7.033 0 0 0-.1232 9.8068l2.395-2.395a3.6455 3.6455 0 0 1 5.1497-5.1478l2.397-2.3989a7.033 7.033 0 0 0-4.8877-1.9297zM7.07 4.9855a7.033 7.033 0 0 0-4.8878 1.9316l2.3911 2.3911a3.6434 3.6434 0 0 1 5.0227.1271l1.7341-2.9737-.0997-.0802A7.033 7.033 0 0 0 7.07 4.9855zm15.0093 2.1721l-2.3892 2.3911a3.6455 3.6455 0 0 1-5.1497 5.1497l-2.4067 2.4068a7.0362 7.0362 0 0 0 9.9456-9.9476zM1.932 7.1674a7.033 7.033 0 0 0-.002 9.6816l2.397-2.397a3.6434 3.6434 0 0 1-.004-4.8916zm7.664 7.4235c-1.38 1.3816-3.5863 1.411-5.0168.1134l-2.397 2.395c2.4693 2.3328 6.263 2.5753 9.0072.5455l.1368-.1115z" />
</svg>
),
},
]
: []),
{
title: "Open in ChatGPT",
href: `https://chatgpt.com/?${new URLSearchParams({
hints: "search",
q,
})}`,
icon: (
<svg
role="img"
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
>
<title>OpenAI</title>
<path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z" />
</svg>
),
},
{
title: "Open in Claude",
href: `https://claude.ai/new?${new URLSearchParams({
q,
})}`,
icon: (
<svg
fill="currentColor"
role="img"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<title>Anthropic</title>
<path d="m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z" />
</svg>
),
},
];
return items;
}, [githubUrl, markdownUrl, colab]);
return (
<div className="flex">
<button
disabled={isLoading}
onClick={onClick}
className={cn(
buttonVariants({
color: "secondary",
size: "sm",
className:
"gap-2 [&_svg]:size-3.5 [&_svg]:text-fd-muted-foreground rounded-r-none border-r-0 cursor-pointer",
})
)}
>
{checked ? <Check /> : <Copy />}
Copy page
</button>
<Popover open={isOpen} onOpenChange={setIsOpen}>
<PopoverTrigger
className={cn(
buttonVariants({
color: "secondary",
size: "sm",
className:
"gap-2 [&_svg]:size-3.5 [&_svg]:text-fd-muted-foreground rounded-l-none border-l cursor-pointer",
})
)}
>
<ChevronDown
className={cn(
"size-3.5 text-fd-muted-foreground transition-transform duration-200",
isOpen && "rotate-180"
)}
/>
</PopoverTrigger>
<PopoverContent
className="flex flex-col overflow-auto w-auto min-w-44"
align="end"
>
{items.map((item, index) => {
if (item.onClick) {
return (
<button
key={index}
onClick={item.onClick}
className={cn(
optionVariants(),
"w-full text-left justify-start"
)}
>
{item.icon}
<span className="font-normal mr-4">{item.title}</span>
<ExternalLinkIcon className="text-fd-muted-foreground size-3.5 ms-auto" />
</button>
);
}
return (
<a
key={index}
href={item.href}
rel="noreferrer noopener"
target="_blank"
className={cn(
optionVariants(),
"w-full text-left justify-start"
)}
>
{item.icon}
<span className="font-normal mr-4">{item.title}</span>
<ExternalLinkIcon className="text-fd-muted-foreground size-3.5 ms-auto" />
</a>
);
})}
</PopoverContent>
</Popover>
</div>
);
}
const optionVariants = cva(
"text-sm p-2 rounded-lg inline-flex items-center gap-2 hover:text-fd-accent-foreground hover:bg-fd-accent [&_svg]:size-4 cursor-pointer"
);
================================================
FILE: components/banner.tsx
================================================
import { Banner } from "fumadocs-ui/components/banner";
import Link from "next/link";
export function SiteBanner() {
return (
<Banner id="close">
<Link
href="https://github.com/aicademyorg/AIcademy"
target="_blank"
rel="noopener noreferrer"
className="flex items-center"
>
Give AIcademy a star on GitHub!
</Link>
</Banner>
);
}
================================================
FILE: components/feedback.tsx
================================================
"use client";
import { cn } from "@/lib/cn";
import { buttonVariants } from "fumadocs-ui/components/ui/button";
import { ThumbsDown, ThumbsUp } from "lucide-react";
import { type SyntheticEvent, useEffect, useState, useTransition } from "react";
import {
Collapsible,
CollapsibleContent,
} from "fumadocs-ui/components/ui/collapsible";
import { cva } from "class-variance-authority";
import { usePathname } from "next/navigation";
import { uiDictionary } from "@/lib/i18n";
const rateButtonVariants = cva(
"inline-flex cursor-pointer items-center gap-2 px-3 py-2 rounded-full font-medium border text-sm [&_svg]:size-4 disabled:cursor-not-allowed",
{
variants: {
active: {
true: "bg-fd-accent text-fd-accent-foreground [&_svg]:fill-current",
false: "text-fd-muted-foreground",
},
},
}
);
export interface Feedback {
opinion: "good" | "bad";
url?: string;
message: string;
}
export interface ActionResponse {
githubUrl: string;
}
interface Result extends Feedback {
response?: ActionResponse;
}
export function Feedback({
onRateAction,
lang = "en",
}: {
onRateAction: (url: string, feedback: Feedback) => Promise<ActionResponse>;
lang?: string;
}) {
const url = usePathname();
const [previous, setPrevious] = useState<Result | null>(null);
const [opinion, setOpinion] = useState<"good" | "bad" | null>(null);
const [message, setMessage] = useState("");
const [isPending, startTransition] = useTransition();
const t =
uiDictionary[lang as keyof typeof uiDictionary]?.feedback ||
uiDictionary.en.feedback;
useEffect(() => {
const item = localStorage.getItem(`docs-feedback-${url}`);
if (item === null) return;
setPrevious(JSON.parse(item) as Result);
}, [url]);
useEffect(() => {
const key = `docs-feedback-${url}`;
if (previous) localStorage.setItem(key, JSON.stringify(previous));
else localStorage.removeItem(key);
}, [previous, url]);
function submit(e?: SyntheticEvent) {
if (opinion == null) return;
startTransition(async () => {
const feedback: Feedback = {
opinion,
message,
};
void onRateAction(url, feedback).then((response) => {
setPrevious({
response,
...feedback,
});
setMessage("");
setOpinion(null);
});
});
e?.preventDefault();
}
const activeOpinion = previous?.opinion ?? opinion;
return (
<Collapsible
open={opinion !== null || previous !== null}
onOpenChange={(v) => {
if (!v) setOpinion(null);
}}
className="border-y py-3"
>
<div className="flex flex-row items-center gap-2">
<p className="text-sm font-medium pe-2">{t.wasHelpful}</p>
<button
disabled={previous !== null}
className={cn(
rateButtonVariants({
active: activeOpinion === "good",
})
)}
onClick={() => setOpinion("good")}
>
<ThumbsUp />
{t.good}
</button>
<button
disabled={previous !== null}
className={cn(
rateButtonVariants({
active: activeOpinion === "bad",
})
)}
onClick={() => setOpinion("bad")}
>
<ThumbsDown />
{t.bad}
</button>
</div>
<CollapsibleContent className="mt-3">
{previous ? (
<div className="px-3 py-6 flex flex-col items-center gap-3 bg-fd-card text-fd-card-foreground text-sm text-center rounded-xl text-fd-muted-foreground">
<p>{t.thankYou}</p>
<div className="flex flex-row items-center gap-2">
<a
href={previous.response?.githubUrl}
rel="noreferrer noopener"
target="_blank"
className={cn(
buttonVariants({ color: "primary" }),
"text-xs cursor-pointer"
)}
>
{t.viewOnGitHub}
</a>
<button
className={cn(
buttonVariants({ color: "secondary" }),
"text-xs cursor-pointer"
)}
onClick={() => {
setOpinion(previous.opinion);
setPrevious(null);
}}
>
{t.submitAgain}
</button>
</div>
</div>
) : (
<form className="flex flex-col gap-3" onSubmit={submit}>
<textarea
autoFocus
required
value={message}
onChange={(e) => setMessage(e.target.value)}
className="border rounded-lg bg-fd-secondary text-fd-secondary-foreground p-3 resize-none focus-visible:outline-none placeholder:text-fd-muted-foreground"
placeholder={t.placeholder}
onKeyDown={(e) => {
if (!e.shiftKey && e.key === "Enter") {
submit(e);
}
}}
/>
<button
type="submit"
disabled={isPending}
className={cn(
buttonVariants({ color: "outline" }),
"w-fit px-3 cursor-pointer disabled:cursor-not-allowed"
)}
>
{t.submit}
</button>
</form>
)}
</CollapsibleContent>
</Collapsible>
);
}
================================================
FILE: components/footer.tsx
================================================
import Image from "next/image";
import {
SiDiscord,
SiGithub,
SiX,
SiYoutube,
SiInstagram,
SiLinkedin,
// SiDiscourse,
} from "react-icons/si";
import DarkLogo from "@/public/logo-dark.png";
import LightLogo from "@/public/logo-light.png";
const YEAR = new Date().getFullYear();
export const Footer = (): React.ReactElement => {
const socialLinks = [
{ href: "https://twitter.com/aicademyorg", icon: SiX, label: "Twitter" },
{
href: "https://www.youtube.com/@aicademyorg",
icon: SiYoutube,
label: "YouTube",
},
{ href: "https://github.com/aicademyorg", icon: SiGithub, label: "GitHub" },
{
href: "https://discord.com/invite/bxnwugmNZg",
icon: SiDiscord,
label: "Discord",
},
{
href: "https://www.instagram.com/aicademyorg",
icon: SiInstagram,
label: "Instagram",
},
{
href: "https://www.linkedin.com/company/aicademyorg",
icon: SiLinkedin,
label: "LinkedIn",
},
// { href: "#", icon: SiDiscourse, label: "Discourse" },
];
return (
<footer className="mt-auto border-t bg-fd-card py-16 text-fd-secondary-foreground">
<div className="flex flex-col items-center gap-5 sm:flex-row sm:items-center sm:justify-between md:px-13">
<div className="flex items-center gap-2">
<Image
src={LightLogo}
className="dark:hidden w-5 md:w-5"
alt="AIcademy Logo"
/>
<Image
src={DarkLogo}
className="hidden dark:flex w-5 md:w-5"
alt="AIcademy Logo"
/>
<p className="text-[15px] font-medium">
AIcademy{" "}
<span className="text-[13px] font-normal text-[#757575] dark:text-[#989898] pl-[3px]">
© {YEAR}
</span>
</p>
</div>
<div className="flex items-center gap-4.5">
{socialLinks.map(({ href, icon: Icon, label }) => (
<a
key={label}
href={href}
target="_blank"
rel="noopener noreferrer"
aria-label={label}
className="text-[#757575] dark:text-[#989898] hover:text-gray-900 dark:hover:text-white transition-colors"
>
<Icon className="size-4.25" />
</a>
))}
</div>
</div>
</footer>
);
};
================================================
FILE: components/mdx/mermaid.tsx
================================================
'use client';
import { useEffect, useId, useRef, useState } from 'react';
import { useTheme } from 'next-themes';
export function Mermaid({ chart }: { chart: string }) {
const id = useId();
const [svg, setSvg] = useState('');
const containerRef = useRef<HTMLDivElement>(null);
const currentChartRef = useRef<string>(null);
const { resolvedTheme } = useTheme();
useEffect(() => {
const container = containerRef.current;
if (currentChartRef.current === chart || !container) return;
currentChartRef.current = chart;
async function renderChart() {
const { default: mermaid } = await import('mermaid');
try {
mermaid.initialize({
startOnLoad: false,
securityLevel: 'loose',
fontFamily: 'inherit',
themeCSS: 'margin: 1.5rem auto 0;',
theme: resolvedTheme === 'dark' ? 'dark' : 'default',
});
const { svg, bindFunctions } = await mermaid.render(
id,
chart.replaceAll('\\n', '\n'),
);
bindFunctions?.(container!);
setSvg(svg);
} catch (error) {
console.error('Error while rendering mermaid', error);
}
}
void renderChart();
}, [chart, id, resolvedTheme]);
return <div ref={containerRef} dangerouslySetInnerHTML={{ __html: svg }} />;
}
================================================
FILE: content/docs/math/index.mdx
================================================
---
title: Mathematics
description: Mathematics for Machine Learning
icon: Code
---
================================================
FILE: content/docs/math/meta.json
================================================
{
"title": "Mathematics",
"description": "Maths for Machine Learning",
"root": true,
"icon": "Sigma"
}
================================================
FILE: content/docs/meta.json
================================================
{
"pages": ["python", "math"],
"description": "Welcome to the AIcademy documentation!"
}
================================================
FILE: content/docs/python/index.mdx
================================================
---
title: Welcome
description: Learn Python for Data Science
icon: Album
---
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
import { SiNumpy, SiPandas, SiPython, SiScikitlearn } from "react-icons/si";
Welcome to the **Python for Data Science** course!
This course will teach you Python and key libraries for data science, from basics to advanced.
This is a hands-on course where you'll learn by solving Python problems. At the end of each module, you'll find exercises to help reinforce and apply what you've learned.
## What you'll learn
You’ll begin with Python basics and then learn key libraries for data science.
<Cards>
<Card icon={<SiPython className="text-purple-300" />} title='Python' href="/docs/python/python">
A powerful and versatile programming language widely used in machine learning.
</Card>
<Card icon={<SiNumpy className="text-blue-300" />} title='NumPy' href="/docs/python/numpy">
A library for fast numerical computations and working with arrays.
</Card>
<Card icon={<SiPandas />} title='Pandas' href="/docs/python/pandas">
A tool for data manipulation and analysis using DataFrames.
</Card>
<Card icon={<SiPandas />} title='Matplotlib' href="/docs/python/matplotlib">
A library for creating static, interactive, and animated visualizations.
</Card>
<Card icon={<SiScikitlearn />} title='Scikit Learn' href="/docs/python/scikit-learn">
A library for building and evaluating machine learning models.
</Card>
</Cards>
By the end, you’ll have a solid foundation to explore, analyze, and work with data.
## Getting Help
If you need help or have questions, feel free to ask on our [Discord](https://discord.com/invite/bxnwugmNZg) server.
## FAQ
Some answers to frequently asked questions.
<Accordions>
<Accordion title="Who is this course for?">
This course is for anyone curious about AI and programming with Python, from
complete beginners to professionals seeking to boost productivity.
</Accordion>
<Accordion title="Do I need prior coding experience?">
No prior coding experience is required. This course is designed to be
accessible to complete beginners while also providing valuable insights for
those with some coding background.
</Accordion>
<Accordion title="Do I need to take the courses in a specific order?">
We recommend taking the courses in the prescribed order for a logical and
consistent learning experience.
</Accordion>
<Accordion title="What kind of support will I have during the course?">
You will have access to a community of learners and professionals, as well
as continuous guidance and feedback from your AI companions.
</Accordion>
</Accordions>
## Let’s go
Let's get started by [setting up](/docs/python/setup) your Python environment.
================================================
FILE: content/docs/python/matplotlib/index.mdx
================================================
---
title: Matplotlib
description: Getting started with Python
icon: Terminal
index: true
---
## Matplotlib
================================================
FILE: content/docs/python/meta.json
================================================
{
"title": "Python",
"description": "Python for Data Science",
"icon": "SiPython",
"root": true,
"pages": [
"---Introduction---",
"index",
"setup",
"---Modules---",
"python",
"numpy",
"pandas",
"matplotlib",
"---Optional---",
"scikit-learn"
]
}
================================================
FILE: content/docs/python/numpy/index.mdx
================================================
---
title: NumPy
description: Getting started with Python
icon: SiNumpy
index: true
---
## NumPy
================================================
FILE: content/docs/python/pandas/index.mdx
================================================
---
title: Pandas
description: Getting started with Python
icon: SiPandas
index: true
---
## Pandas
================================================
FILE: content/docs/python/python/control-flow.mdx
================================================
---
title: Control Flow
description: Direct the logic of your program with conditions and loops.
---
5.1 Conditional Statements
- if, else, elif
Nested if
- 5.2 Loops
- for and while Loops
- range() and enumerate()
- Loop Control: break, continue
- Nested Loops
================================================
FILE: content/docs/python/python/data-structures.mdx
================================================
---
title: Data Structures
description: Store and organize data with Python's built-in collections.
---
6.1 Lists
- Creation, Indexing, Slicing
- List Methods
6.2 Tuples
6.3 Sets
6.4 Dictionaries
- Creating and Accessing Elements
- Dictionary Methods
================================================
FILE: content/docs/python/python/data-types.mdx
================================================
---
title: Data Types
description: Work with and manipulate different types of data.
---
In Python, data types classify the types of values a variable can hold. Every value in Python has a data type. Python is a dynamically typed language, so you don’t need to explicitly declare the type of a variable.
Since everything in Python is an object, data types are actually classes, and the variables are instances (objects) of these classes.
<Mermaid
chart={`
graph TD
A[Python Data Types] --> B[Numeric]
A --> C[Dictionary]
A --> D[Boolean]
A --> E[Set]
A --> F[Sequence Type]
B --> B1[Integer]
B --> B2[Float]
B --> B3[Complex Number]
F --> F1[Strings]
F --> F2[List]
F --> F3[Tuple]
`}
/>
## Numeric
The numeric data type in Python represents the data that has a numeric value.
### Integer (`int`)
Whole numbers, positive or negative, without decimal points.
```py
x = 10
print(type(x)) # <class 'int'>
```
Python integers can be arbitrarily large (limited by memory).
### Float (`float`)
Real numbers with decimal points. Also supports scientific notation.
```py
x = 10.5
y = 1.5e2
print(type(x), type(y)) # <class 'float'> <class 'float'>
```
### Complex (`complex`)
Used to represent complex numbers (real + imaginary). Suffix `j` is used for the imaginary part
```py
x = 2 + 3j
print(type(x)) # <class 'complex'>
```
## Sequence Type
The sequence Data Type in Python is the ordered collection of similar or different Python data types.
### String (`str`)
A string is a collection of one or more characters put in a single quote, double-quote or triple quote. In python there is no character data type, a character is a string of length one.
Example:
```py
# String with single quotes
print('Welcome to the Geeks World')
# String with double quotes
print("I'm a Geek")
# String with triple quotes
print('''I'm a Geek and I live in a world of "Geeks"''')
```
Output:
```sh
Welcome to the Geeks World
I'm a Geek
I'm a Geek and I live in a world of "Geeks"
```
#### Accessing elements of string:
| Character | A | I | c | a | d | e | m | y |
| ------------------ | --- | --- | --- | --- | --- | --- | --- | --- |
| **Positive Index** | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| **Negative Index** | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 |
```py
String1 = "AIcademy"
# Printing First character
print(String1[0])
# Printing Last character
print(String1[-1])
```
output:
```sh
A
y
```
#### Deleting/Updating from a String:
In Python, Updation or deletion of characters from a String is not allowed because Strings are immutable. Only new strings can be reassigned to the same name.
### List
Lists are just like arrays, declared in other languages which is an ordered collection of data. It is very flexible as the items in a list do not need to be of the same type.
Lists in Python can be created by just placing the sequence inside the square brackets[].
```py
# Empty list
a = []
# list with int values
a = [1, 2, 3]
print(a)
# list with mixed int and string
b = ["Geeks", "For", "Geeks", 4, 5]
print(b)
```
output:
```sh
[1, 2, 3]
['Geeks', 'For', 'Geeks', 4, 5]
```
#### Access List Items
Use the index operator [ ] to access an item in a list. In Python, negative sequence indexes represent positions from the end of the array. Instead of having to compute the offset as in List[len(List)-3], it is enough to just write List[-3].
```py
List = [1, 2, 3, 4, 5, 6]
# accessing a element
print(List[0])
print(List[2])
# Negative indexing
# print the last element of list
print(List[-1])
# print the third last element of list
print(List[-3])
```
output:
```sh
1
3
6
4
```
Adding Elements to a List: Using append(), insert() and extend()
```py
# Creating a List
List = []
# Using append()
List.append(1)
List.append(2)
print(List)
# Using insert()
List.insert(3, 12)
List.insert(0, 'Geeks')
print(List)
# Using extend()
List.extend([8, 'Geeks', 'Always'])
print(List)
```
outuput:
```sh
[1, 2]
['Geeks', 1, 2, 12]
['Geeks', 1, 2, 12, 8, 'Geeks', 'Always']
```
Removing Elements from the List: Using remove() and pop()
```py
# Creating a List
List = [1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12]
# using Remove() method
List.remove(5)
List.remove(6)
print(List)
# using pop()
List.pop()
print(List)
```
output:
```sh
[1, 2, 3, 4, 7, 8, 9, 10, 11, 12]
[1, 2, 3, 4, 7, 8, 9, 10, 11]
```
### Tuple
Just like a list, a tuple is also an ordered collection of Python objects. The only difference between a tuple and a list is that tuples are immutable. Tuples cannot be modified after it is created.
```py
Tuple1 = ()
print (Tuple1)
# Creating a tuple of strings
print(('Geeks', 'For'))
# Creating a Tuple of list
print(tuple([1, 2, 4, 5, 6]))
# Creating a nested Tuple
Tuple1 = (0, 1, 2, 3)
Tuple2 = ('python', 'geek')
Tuple3 = (Tuple1, Tuple2)
print(Tuple3)
```
output:
```sh
()
('Geeks', 'For')
(1, 2, 4, 5, 6)
((0, 1, 2, 3), ('python', 'geek'))
```
#### Accessing element of a tuple
Use the index operator [ ] to access an item in a tuple.
```py
tuple1 = tuple([1, 2, 3, 4, 5])
# Accessing element using indexing
print(tuple1[0])
# Accessing element using Negative
# Indexing
print(tuple1[-1])
```
output:
```sh
1
5
```
### Deleting/updating elements of tuple
Items of a tuple cannot be deleted as tuples are immutable in Python. Only new tuples can be reassigned to the same name.
```py
tuple1 = tuple([1, 2, 3, 4, 5])
# Updating an element
tuple1[0] = -1
# Deleting an element
del tuple1[2]
```
## Boolean
Only two values: `True` and `False`.
```py
x = True
y = False
print(type(x)) # <class 'bool'>
```
Booleans are often returned from comparison or logical operations.
```py
print(1 == 1) # True
print(1 < 2 and 3 > 1) # True
```
## Set (`set`)
Unordered collection of unique, immutable elements.
```py
s = {1, 2, 3, 2}
print(s) # {1, 2, 3}
```
#### Adding elements: Using add() and update()
```py
set1 = set()
# Adding to the Set using add()
set1.add(8)
set1.add((6, 7))
print(set1)
# Additio to the Set using Update()
set1.update([10, 11])
print(set1)
```
output:
```sh
{8, (6, 7)}
{8, 10, 11, (6, 7)}
```
#### Accessing a Set
```py
# Creating a set
set1 = set(["Geeks", "For", "Geeks"])
# Accessing using for loop
for i in set1:
print(i, end =" ")
```
output:
```sh
Geeks For
```
#### Removing elements from a set: Using remove(), discard(), pop() and clear()
```py
set1 = set([1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12])
# using Remove() method
set1.remove(5)
set1.remove(6)
print(set1)
# using Discard() method
set1.discard(8)
set1.discard(9)
print(set1)
# Set using the pop() method
set1.pop()
print(set1)
# Set using clear() method
set1.clear()
print(set1)
```
output:
```sh
{1, 2, 3, 4, 7, 8, 9, 10, 11, 12}
{1, 2, 3, 4, 7, 10, 11, 12}
{2, 3, 4, 7, 10, 11, 12}
set()
```
## Dictionary (`dict`)
Unordered collection of key-value pairs. Keys must be unique and immutable.
```py
person = {
"name": "Alice",
"age": 30
}
print(person["name"]) # Alice
```
output:
```sh
{}
{1: 'Geeks', 2: 'For', 3: 'Geeks'}
{1: [1, 2, 3, 4], 'Name': 'Geeks'}
```
#### Nested Dictionary
<Mermaid
chart={`
graph TD
%% Main keys
K1["1"] --> V1["Geeks"]
K2["2"] --> V2["For"]
K3["3"] --> NK["Nested Keys"]
%% Nested keys and their values
NK --> NA["A"] --> VA["Welcome"]
NK --> NB["B"] --> VB["To"]
NK --> NC["C"] --> VC["Geeks"]
%% Grouping (optional visual clarity)
subgraph Keys
K1
K2
K3
end
subgraph Value Set 1
V1
V2
end
subgraph Value Set 2
VA
VB
VC
end
`}
/>
```py
# Creating a Nested Dictionary
# as shown in the below image
Dict = {1: 'Geeks', 2: 'For',
3:{'A' : 'Welcome', 'B' : 'To', 'C' : 'Geeks'}}
print(Dict)
```
output:
```sh
{1: 'Geeks', 2: 'For', 3: {'A': 'Welcome', 'B': 'To', 'C': 'Geeks'}}
```
#### Adding elements to a Dictionary
One value at a time can be added to a Dictionary by defining value along with the key e.g. Dict[Key] = ‘Value’.
```py
# Creating an empty Dictionary
Dict = {}
# Adding elements one at a time
Dict[0] = 'Geeks'
Dict[2] = 'For'
Dict[3] = 1
print(Dict)
# Updating existing Key's Value
Dict[2] = 'Welcome'
print(Dict)
```
output:
```sh
{0: 'Geeks', 2: 'For', 3: 1}
{0: 'Geeks', 2: 'Welcome', 3: 1}
```
#### Accessing elements from a Dictionary
In order to access the items of a dictionary refer to its key name or use get() method.
```py
# Creating a Dictionary
Dict = {1: 'Geeks', 'name': 'For', 3: 'Geeks'}
# accessing a element using key
print(Dict['name'])
# accessing a element using get()
print(Dict.get(3))
```
Output:
```sh
For
Geeks
```
#### Removing Elements from Dictionary
Using pop() and popitem()
```py
# Initial Dictionary
Dict = { 5 : 'Welcome', 6 : 'To', 7 : 'Geeks',
'A' : {1 : 'Geeks', 2 : 'For', 3 : 'Geeks'},
}
# using pop()
Dict.pop(5)
print(Dict)
# using popitem()
Dict.popitem()
print(Dict)
```
output:
```sh
{'A': {1: 'Geeks', 2: 'For', 3: 'Geeks'}, 6: 'To', 7: 'Geeks'}
{6: 'To', 7: 'Geeks'}
```
================================================
FILE: content/docs/python/python/error-handling.mdx
================================================
---
title: Error Handling
description: Handle errors gracefully and write reliable code.
---
10.1 Types of Exceptions
10.2 try, except, finally
10.3 Handling Multiple Exceptions
10.4 Raising Custom Exceptions
10.5 Debugging Tips
================================================
FILE: content/docs/python/python/file-handling.mdx
================================================
---
title: File Handling
description: Reading and writing files with Python
---
7.1 Opening Files with open()
7.2 Reading Text Files
7.3 Writing Text Files
7.4 Using with for File Handling
7.5 Working with JSON
- Reading JSON Files
- Writing JSON Files
================================================
FILE: content/docs/python/python/functions.mdx
================================================
---
title: Functions
description: Write modular, reusable code.
---
8.1 Defining Functions with def
8.2 Arguments and Return Values
8.3 Default Arguments, *args, **kwargs
8.4 Built-in vs User-defined Functions
8.5 Lambda (Anonymous) Functions
8.6 Functional Tools: map(), filter(), zip(), sorted()
================================================
FILE: content/docs/python/python/hello-world.mdx
================================================
---
title: Hello, World!
description: Understand the building blocks of a Python program.
---
Hello, World! in python is the first python program which we learn when we start learning any program. It’s a simple program that displays the message “Hello, World!” on the screen.
================================================
FILE: content/docs/python/python/index.mdx
================================================
---
title: Python
description: Getting started with Python
icon: SiPython
index: true
---
Python is a high-level programming language known for its simplicity and flexibility. It supports structured, object-oriented, and functional programming, with syntax inspired by elements of C.
Created in the late 1980s by Guido van Rossum, it was designed to be both powerful and easy to use.
## Why Python
Python is the most popular language for data science because:
- **Easy to learn**: Python’s simple, readable syntax is great for beginners and efficient for experienced developers.
- **Free and open source**: Completely free to use, with a rich ecosystem of libraries at no cost.
- **Powerful libraries**: Libraries like **NumPy**, **pandas**, and **matplotlib** make data analysis and visualization simple. Frameworks like **scikit-learn**, **TensorFlow**, and **PyTorch** let you build and train machine learning models with minimal code.
- **Vast ecosystem**: From web scraping to automation, Python offers libraries for nearly every task.
- **Scalable and versatile**: Python runs on all major platforms and scales from small scripts to large systems.
- **Strong community**: A large and active user base ensures plenty of tutorials, documentation, and support.
Python is also chosen for data science and machine learning for its object-oriented design, clear syntax, and dynamic memory management, making it ideal for a wide range of applications.
## Modules
================================================
FILE: content/docs/python/python/meta.json
================================================
{
"pages": [
"hello-world",
"operators",
"data-types",
"control-flow",
"data-structures",
"file-handling",
"functions",
"oop",
"error-handling"
]
}
================================================
FILE: content/docs/python/python/oop.mdx
================================================
---
title: Object Oriented
description: Model real-world systems using classes and objects.
---
9.1 What is OOP?
9.2 Creating Classes and Objects
9.3 Instance vs Class Attributes
9.4 Encapsulation and Access Modifiers
9.5 self and Class Members
9.6 Static Methods vs Class Methods
9.7 Inheritance
- Single and Multiple Inheritance
- super() and issubclass()
9.8 Polymorphism
9.9 Abstract Classes
================================================
FILE: content/docs/python/python/operators.mdx
================================================
---
title: Operators
description: Calculations and comparisons using operators.
---
Operators are symbols used to perform operations on variables and values, such as arithmetic calculations, comparisons, or logical checks.
Let's explore the most commonly used operators in Python:
## Arithmetic Operators
These are used to do basic math operations like addition, subtraction, multiplication and division.
| Operator | Description | Syntax |
| -------- | ---------------------------- | -------- |
| `+` | Addition | `x + y` |
| `-` | Subtraction | `x - y` |
| `*` | Multiplication | `x * y` |
| `/` | Division (decimal) | `x / y` |
| `//` | Floor Division (rounds down) | `x // y` |
| `%` | Modulus (remainder) | `x % y` |
| `**` | Power (exponent) | `x ** y` |
Example:
```py
a = 7
b = 2
print(a + b) # Addition
print(a - b) # Subtraction
print(a * b) # Multiplication
print(a / b) # Division
print(a // b) # Floor Division
print(a % b) # Modulus
print(a ** b) # Exponent
```
Output:
```sh
9
5
14
3.5
3
1
49
```
## Comparison Operators
These are used to compare two values. The result is either `True` or `False`.
| Operator | Description | Syntax |
| -------- | ------------------------ | -------- |
| `>` | Greater than | `x > y` |
| `<` | Less than | `x < y` |
| `==` | Equal to | `x == y` |
| `!=` | Not equal to | `x != y` |
| `>=` | Greater than or equal to | `x >= y` |
| `<=` | Less than or equal to | `x <= y` |
Example:
```py
x = 8
y = 10
print(x > y) # Greater than
print(x < y) # Less than
print(x == y) # Equal to
print(x != y) # Not equal to
print(x >= y) # Greater than or equal to
print(x <= y) # Less than or equal to
```
Output:
```sh
False
True
False
True
False
True
```
## Logical Operators
These are used to combine multiple conditions.
| Operator | Description | Syntax | Example |
| -------- | -------------------------------- | --------- | ------------------ |
| `and` | True if both conditions are true | `x and y` | `x > 5 and x < 10` |
| `or` | True if at least one is true | `x or y` | `x < 5 or x > 15` |
| `not` | Reverses the condition | `not x` | `not(x > 5)` |
Example:
```py
x = 7
print(x > 5 and x < 10) # True
print(x < 5 or x > 10) # False
print(not(x > 5)) # False
```
Output:
```sh
True
False
False
```
## Bitwise Operators
Bitwise operators work with binary (0s and 1s). These are advanced but useful for certain tasks.
| Operator | Description | Syntax |
| -------- | ------------------- | -------- |
| `&` | Bitwise AND | `x & y` |
| `~` | Bitwise NOT | `~x` |
| `^` | Bitwise XOR | `x ^ y` |
| `>>` | Bitwise right shift | `x >> y` |
| `<<` | Bitwise left shift | `x << y` |
Example:
```py
a = 6
b = 3
print(a & b) # AND
print(~a) # NOT
print(a ^ b) # XOR
print(a >> 1) # Right shift
print(a << 1) # Left shift
```
Output:
```sh
2
-7
5
3
12
```
## Assignment Operators
These are used to assign values to variables, sometimes after performing a calculation.
| Operator | Meaning | Example |
| -------- | ----------------------------- | --------- |
| `=` | Assign value | `x = 5` |
| `+=` | Add and assign | `x += 2` |
| `-=` | Subtract and assign | `x -= 2` |
| `*=` | Multiply and assign | `x *= 2` |
| `/=` | Divide and assign | `x /= 2` |
| `//=` | Floor divide and assign | `x //= 2` |
| `%=` | Modulus and assign | `x %= 2` |
| `**=` | Power and assign | `x **= 2` |
| `:=` | Assign in expression (Walrus) | `x := 5` |
Example:
```py
# = : Assign value
x = 5
print(x) # 5
# += : Add and assign
x += 3 # x = x + 3
print(x) # 8
# -= : Subtract and assign
x -= 2 # x = x - 2
print(x) # 6
# *= : Multiply and assign
x *= 4 # x = x * 4
print(x) # 24
# /= : Divide and assign
x /= 6 # x = x / 6
print(x) # 4.0
# //= : Floor divide and assign
x //= 3 # x = x // 3
print(x) # 1.0
# %= : Modulus and assign
x = 10
x %= 4 # x = x % 4
print(x) # 2
# **= : Power and assign
x **= 3 # x = x ** 3
print(x) # 8
# := : Walrus operator (Python 3.8+)
items = [1, 2, 3, 4]
while (length := len(items)) > 2:
print(length)
items.pop()
```
## Identity Operators
These check whether two variables refer to the same object in memory.
| Operator | Meaning | Example |
| -------- | ---------------------------- | ------------ |
| `is` | True if same memory location | `a is b` |
| `is not` | True if different location | `a is not b` |
Example
```py
a = 10
b = 20
c = a
print(a is not b)
print(a is c)
```
Output:
```
True
True
```
## Membership Operators
These check whether a value exists in a list, string, or other sequence.
| Operator | Meaning | Example |
| -------- | ---------------------------- | --------------- |
| `in` | True if value is present | `x in list` |
| `not in` | True if value is not present | `x not in list` |
Example:
```py
fruits = ["apple", "banana", "cherry"]
print("apple" in fruits) # True
print("mango" not in fruits) # True
```
Output:
```sh
True
True
```
================================================
FILE: content/docs/python/scikit-learn/index.mdx
================================================
---
title: Scikit Learn
description: Getting started with Python
icon: SiScikitlearn
index: true
---
## Scikit Learn
================================================
FILE: content/docs/python/setup.mdx
================================================
---
title: Setup
description: Setting up your Python environment
icon: Settings2
colab: https://colab.research.google.com/drive/1example
---
Let’s set up the tools you’ll use to write and execute your code. There are two main environments for working with Python: **Shell** and **Notebook**. Let’s explore both.
<Callout>
Make sure [Python](https://www.python.org/downloads/) and
[IPython](https://ipython.org/install.html) are installed on your system.
</Callout>
## Shell
The Shell lets you run Python commands interactively in your terminal, line by line.
Start the Python shell by running `python3` in your terminal (`python` on Windows).
```sh title="Python shell"
(base) ➜ ~ python3 # [!code highlight]
Python 3.11.4 (main, Jul 5 2023, 08:54:11) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello, World!") # print hello world
Hello, World!
>>> 4 + 9 # add numbers
13
```
### IPython
[IPython](https://ipython.org/) is an enhanced shell with features like syntax highlighting, auto-completion, and better debugging.
To start IPython, run `ipython` in your terminal.
```sh title="IPython shell"
(base) ➜ ~ ipython # [!code highlight]
Python 3.11.4 (main, Jul 5 2023, 08:54:11) [Clang 14.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: print("Hello, IPython!")
Hello, IPython!
In [2]: 3 + 39
Out[2]: 42
```
Shells are great for quick tests but not ideal for complex projects. That’s where **Notebooks** come in.
## Notebooks
A notebook is a web-based interactive environment built on top of IPython. While working in the shell can be limiting, notebooks simplify the process by bringing code, visualizations, and explanations together in one place.
### Jupyter Notebook
[Jupyter Notebook](https://jupyter.org/) is a local web-based notebook, ideal for development, collaboration, and sharing.
Install it with the command `pip install notebook`, then launch it using `jupyter notebook`.
This will start a local web server, show the server log in your terminal, and automatically open the notebook in your browser at [localhost:8888](http://localhost:8888).

There is also an enhanced version of Jupyter Notebook called [JupyterLab](https://jupyterlab.readthedocs.io/en/stable/), which provides a more flexible and powerful environment.
Install it with the command `pip install jupyterlab`, then launch it using `jupyter lab`.

Learn more about JupyterLab in this [tutorial](https://youtu.be/A5YyoCKxEOU?si=vQJXKYTakXIe-DJC) by the Jupyter team.
### Google Colab
[Google Colab](https://colab.research.google.com/) is a cloud-based notebook that runs in your browser. It comes with machine learning libraries pre-installed and offers free compute resources, such as GPUs and TPUs, for smaller workloads.
Due to its ease of use, flexibility, and access to more compute, most people now prefer Colab over Jupyter.

Learn more about Colab in this [tutorial](https://colab.research.google.com/notebooks/intro.ipynb) by the Colab team.
### Kaggle Notebook
[Kaggle Notebook](https://www.kaggle.com/code) is like Colab but fully connected to Kaggle’s datasets and competitions, making it easy to access data and join competitions right from the notebook.

Learn more about Kaggle Notebooks in this [tutorial](https://www.kaggle.com/docs/notebooks) by the Kaggle team.
## Which one to use?
If you’re unsure which environment to choose, [Colab](#google-colab) is a great option. It’s user-friendly, provides free access to more compute power, and comes with pre-installed machine learning libraries.
For this course, we’ll be using Colab as our primary environment.
You’re all set and ready to get started!
================================================
FILE: lib/cn.ts
================================================
export { twMerge as cn } from 'tailwind-merge';
================================================
FILE: lib/get-llm-text.ts
================================================
import { source } from "@/lib/source";
import type { InferPageType } from "fumadocs-core/source";
export async function getLLMText(page: InferPageType<typeof source>) {
const processed = await page.data.getText("processed");
return `# ${page.data.title}
URL: ${page.url}
Source: https://raw.githubusercontent.com/aicademyorg/AIcademy/refs/heads/main/content/docs/${page.path}
${page.data.description ?? ''}
${processed}`;
}
================================================
FILE: lib/github.ts
================================================
import { App, Octokit } from "octokit";
import type { Feedback } from "@/components/feedback";
export const repo = "AIcademy";
export const owner = "aicademyorg";
export const DocsCategory = "Feedback";
let instance: Octokit | undefined;
async function getOctokit(): Promise<Octokit> {
if (instance) return instance;
const appId = process.env.GITHUB_APP_ID;
const privateKey = process.env.GITHUB_APP_PRIVATE_KEY;
if (!appId || !privateKey) {
throw new Error(
"No GitHub keys provided for Github app, docs feedback feature will not work."
);
}
const app = new App({
appId,
privateKey,
});
const { data } = await app.octokit.request(
"GET /repos/{owner}/{repo}/installation",
{
owner,
repo,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
}
);
instance = await app.getInstallationOctokit(data.id);
return instance;
}
interface RepositoryInfo {
id: string;
discussionCategories: {
nodes: {
id: string;
name: string;
}[];
};
}
let cachedDestination: RepositoryInfo | undefined;
async function getFeedbackDestination() {
if (cachedDestination) return cachedDestination;
const octokit = await getOctokit();
const {
repository,
}: {
repository: RepositoryInfo;
} = await octokit.graphql(`
query {
repository(owner: "${owner}", name: "${repo}") {
id
discussionCategories(first: 25) {
nodes { id name }
}
}
}
`);
return (cachedDestination = repository);
}
export interface ActionResponse {
githubUrl: string;
}
export async function onRateAction(
url: string,
feedback: Feedback
): Promise<ActionResponse> {
"use server";
const octokit = await getOctokit();
const destination = await getFeedbackDestination();
if (!octokit || !destination)
throw new Error("GitHub comment integration is not configured.");
const category = destination.discussionCategories.nodes.find(
(category) => category.name === DocsCategory
);
if (!category)
throw new Error(
`Please create a "${DocsCategory}" category in GitHub Discussion`
);
const title = `Feedback for ${url}`;
const body = `[${feedback.opinion}] ${feedback.message}\n\n> Forwarded from user feedback.`;
let discussion: { id: string; url: string } | undefined;
const searchResult = await octokit.graphql<any>(`
query {
search(type: DISCUSSION, query: ${JSON.stringify(
`${title} in:title repo:${owner}/${repo} author:@me`
)}, first: 1) {
nodes {
... on Discussion { id, url }
}
}
}
`);
const nodes: { id: string; url: string }[] = searchResult.search.nodes;
if (nodes && nodes.length > 0 && nodes[0]) {
discussion = nodes[0];
try {
await octokit.graphql(`
mutation {
addDiscussionComment(input: { body: ${JSON.stringify(
body
)}, discussionId: "${discussion.id}" }) {
comment { id }
}
}
`);
} catch (err) {
console.error(
"[onRateAction] Failed to add comment to existing discussion",
{
url,
feedback,
discussionId: discussion.id,
error: err,
}
);
throw new Error("Failed to add comment to existing discussion.");
}
} else {
let result;
try {
result = await octokit.graphql<any>(`
mutation {
createDiscussion(input: { repositoryId: "${
destination.id
}", categoryId: "${category.id}", body: ${JSON.stringify(
body
)}, title: ${JSON.stringify(title)} }) {
discussion { id, url }
}
}
`);
discussion = result?.createDiscussion?.discussion || result?.discussion;
} catch (err) {
console.error("[onRateAction] Error creating discussion", {
url,
feedback,
error: err,
});
}
if (!discussion) {
try {
const retrySearch = await octokit.graphql<any>(`
query {
search(type: DISCUSSION, query: ${JSON.stringify(
`${title} in:title repo:${owner}/${repo} author:@me`
)}, first: 1) {
nodes {
... on Discussion { id, url }
}
}
}
`);
const retryNodes: { id: string; url: string }[] =
retrySearch.search.nodes;
if (retryNodes && retryNodes.length > 0 && retryNodes[0]) {
discussion = retryNodes[0];
}
} catch (err) {
console.error(
"[onRateAction] Error retrying discussion search after creation failure",
{
url,
feedback,
error: err,
}
);
}
}
}
if (!discussion) {
console.error(
"[onRateAction] Final failure: could not find or create discussion",
{
url,
feedback,
title,
}
);
throw new Error(
"Failed to create or find a discussion for feedback. Please ensure the 'Feedback' category exists in your GitHub Discussions and your GitHub App has the correct permissions."
);
}
return {
githubUrl: discussion.url,
};
}
================================================
FILE: lib/i18n.ts
================================================
import { defineI18n } from "fumadocs-core/i18n";
export const i18n = defineI18n({
defaultLanguage: "en",
languages: ["en" /*, "cn", "zh", "ja", "ru", "fr"*/],
hideLocale: "default-locale",
});
export type Language = (typeof i18n.languages)[number];
export function localizeUrl(url: string, lang: Language): string {
return lang === i18n.defaultLanguage ? url : `/${lang}${url}`;
}
interface FeedbackTranslations {
wasHelpful: string;
good: string;
bad: string;
thankYou: string;
submitAgain: string;
placeholder: string;
submit: string;
viewOnGitHub: string;
}
interface UIDictionary {
metadata: {
titleTemplate: string;
defaultTitle: string;
description: string;
};
nav: {
navigation: Array<{
name: string;
href: string;
}>;
};
feedback: FeedbackTranslations;
}
export const uiDictionary: Record<Language, UIDictionary> = {
en: {
metadata: {
titleTemplate: "%s | AIcademy",
defaultTitle: "AIcademy - Free AI Education for All",
description: "A friendly community offering free AI education",
},
nav: {
navigation: [
{ name: "Courses", href: "/courses" },
{ name: "Blog", href: "/blog" },
{ name: "About", href: "/about" },
],
},
feedback: {
wasHelpful: "Was this page helpful?",
good: "Yes",
bad: "No",
thankYou: "Thank you for your feedback!",
submitAgain: "Submit Again?",
placeholder: "Leave your feedback...",
submit: "Submit",
viewOnGitHub: "View on GitHub",
},
},
/*
zh: {
metadata: {
titleTemplate: "%s | AIcademy",
defaultTitle: "AIcademy - 免费AI教育平台",
description: "一个提供免费AI教育的友好社区",
},
nav: {
navigation: [
{ name: "课程", href: "/cn/courses" },
{ name: "博客", href: "/cn/blog" },
{ name: "关于我们", href: "/cn/about" },
],
},
feedback: {
wasHelpful: "这个页面对您有帮助吗?",
good: "有帮助",
bad: "没帮助",
thankYou: "感谢您的反馈!",
submitAgain: "要再次提交吗?",
placeholder: "欢迎留下您的反馈……",
submit: "提交",
viewOnGitHub: "在 GitHub 查看",
},
},
ja: {
metadata: {
titleTemplate: "%s | AIcademy",
defaultTitle: "AIcademy - 無料で学べるAI教育",
description: "誰でも無料で学べる、フレンドリーなAI教育コミュニティ",
},
nav: {
navigation: [
{ name: "コース", href: "/ja/courses" },
{ name: "ブログ", href: "/ja/blog" },
{ name: "概要", href: "/ja/about" },
],
},
feedback: {
wasHelpful: "このページは役に立ちましたか?",
good: "はい",
bad: "いいえ",
thankYou: "ご意見ありがとうございます!",
submitAgain: "もう一度送信しますか?",
placeholder: "ご意見・ご感想をご記入ください…",
submit: "送信する",
viewOnGitHub: "GitHub で見る",
},
},
ru: {
metadata: {
titleTemplate: "%s | AIcademy",
defaultTitle: "AIcademy — бесплатное образование в сфере ИИ",
description:
"Дружелюбное сообщество, предлагающее бесплатное обучение ИИ",
},
nav: {
navigation: [
{ name: "Курсы", href: "/ru/courses" },
{ name: "Блог", href: "/ru/blog" },
{ name: "О проекте", href: "/ru/about" },
],
},
feedback: {
wasHelpful: "Эта страница была полезной?",
good: "Да",
bad: "Нет",
thankYou: "Спасибо за отзыв!",
submitAgain: "Отправить снова?",
placeholder: "Оставьте свой отзыв...",
submit: "Отправить",
viewOnGitHub: "Посмотреть на GitHub",
},
},
fr: {
metadata: {
titleTemplate: "%s | AIcademy",
defaultTitle: "AIcademy - Éducation gratuite à l'IA",
description:
"Une communauté bienveillante proposant une éducation gratuite à l'IA",
},
nav: {
navigation: [
{ name: "Cours", href: "/fr/courses" },
{ name: "Blog", href: "/fr/blog" },
{ name: "À propos", href: "/fr/about" },
],
},
feedback: {
wasHelpful: "Cette page vous a-t-elle été utile ?",
good: "Oui",
bad: "Non",
thankYou: "Merci pour votre retour !",
submitAgain: "Envoyer un autre retour ?",
placeholder: "Laissez-nous votre avis...",
submit: "Envoyer",
viewOnGitHub: "Voir sur GitHub",
},
},
*/
};
================================================
FILE: lib/metadata.ts
================================================
import type { Metadata } from "next/types";
export function createMetadata(override: Metadata): Metadata {
return {
...override,
openGraph: {
title: override.title ?? undefined,
description: override.description ?? undefined,
url: "https://aicademyorg.netlify.app",
images: "/banner.png",
siteName: "AIcademy",
...override.openGraph,
},
twitter: {
card: "summary_large_image",
creator: "@aicademyorg",
title: override.title ?? undefined,
description: override.description ?? undefined,
images: "/banner.png",
...override.twitter,
},
icons: {
icon: "/favicon.ico",
},
};
}
export const baseUrl =
process.env.NODE_ENV === "development" || !process.env.VERCEL_URL
? new URL("http://localhost:3000")
: new URL(`https://${process.env.VERCEL_URL}`);
================================================
FILE: lib/source.ts
================================================
import { docs } from "@/.source/server";
import { loader } from "fumadocs-core/source";
import { i18n } from "@/lib/i18n";
import { icons } from "lucide-react";
import { createElement } from "react";
import * as SiIcons from "react-icons/si";
// See https://fumadocs.vercel.app/docs/headless/source-api for more info
export const source = loader({
// it assigns a URL to your pages
i18n,
baseUrl: "/docs",
icon(icon) {
if (icon && icon in icons)
return createElement(icons[icon as keyof typeof icons]);
if (icon && icon in SiIcons)
return createElement(SiIcons[icon as keyof typeof SiIcons]);
},
source: docs.toFumadocsSource(),
});
================================================
FILE: mdx-components.tsx
================================================
import defaultMdxComponents from "fumadocs-ui/mdx";
import * as FilesComponents from "fumadocs-ui/components/files";
import * as TabsComponents from "fumadocs-ui/components/tabs";
import type { MDXComponents } from "mdx/types";
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
import * as icons from "lucide-react";
import { ImageZoom } from "fumadocs-ui/components/image-zoom";
import { Mermaid } from "@/components/mdx/mermaid";
export function getMDXComponents(components?: MDXComponents): MDXComponents {
return {
...(icons as unknown as MDXComponents),
...defaultMdxComponents,
...TabsComponents,
...FilesComponents,
img: (props) => <ImageZoom {...(props as any)} />,
Accordion,
Accordions,
Mermaid,
...components,
};
}
================================================
FILE: next.config.mjs
================================================
import { createMDX } from "fumadocs-mdx/next";
const withMDX = createMDX();
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
async rewrites() {
return [
{
source: "/:lang/docs/:path*.mdx",
destination: "/:lang/llms.mdx/:path*",
},
];
},
};
export default withMDX(config);
================================================
FILE: package.json
================================================
{
"name": "aicademy",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "next build",
"dev": "next dev --turbo",
"start": "next start",
"postinstall": "fumadocs-mdx"
},
"dependencies": {
"@tailwindcss/postcss": "^4.1.18",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"fumadocs-core": "16.6.3",
"fumadocs-mdx": "14.2.7",
"fumadocs-ui": "16.6.3",
"katex": "^0.16.28",
"lucide-react": "^0.574.0",
"mermaid": "^11.12.3",
"next": "16.1.6",
"next-themes": "^0.4.6",
"octokit": "^5.0.5",
"postcss": "^8.5.6",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-icons": "^5.5.0",
"rehype-katex": "^7.0.1",
"remark": "^15.0.1",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"remark-mdx": "^3.1.1",
"shiki": "^3.22.0",
"tailwind-merge": "^3.4.1",
"tailwindcss": "^4.1.18",
"zod": "^4.3.6"
},
"devDependencies": {
"@types/mdx": "^2.0.13",
"@types/node": "25.2.3",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"typescript": "^5.9.3"
}
}
================================================
FILE: postcss.config.mjs
================================================
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};
export default config;
================================================
FILE: proxy.ts
================================================
import type { NextRequest, NextFetchEvent } from "next/server";
import { NextResponse } from "next/server";
import { createI18nMiddleware } from "fumadocs-core/i18n/middleware";
import { i18n } from "@/lib/i18n";
const i18nMiddleware = createI18nMiddleware(i18n);
export function proxy(request: NextRequest, event: NextFetchEvent) {
const { pathname } = request.nextUrl;
// Handle .md requests
if (pathname.endsWith(".md")) {
const pathWithoutMd = pathname.slice(0, -3);
const langMatch = pathWithoutMd.match(/^\/([a-z]{2})(\/.*)?$/);
let lang = i18n.defaultLanguage;
let docPath = pathWithoutMd;
if (langMatch && i18n.languages.includes(langMatch[1] as any)) {
lang = langMatch[1] as any;
docPath = langMatch[2] || "";
} else {
docPath = pathWithoutMd;
}
// Remove leading slash from docPath if present
if (docPath.startsWith("/")) {
docPath = docPath.slice(1);
}
// Handle root/index case
if (!docPath || docPath === "") {
docPath = "index";
}
// Remove 'docs' prefix if present (since the source system handles docs structure)
if (docPath.startsWith("docs/")) {
docPath = docPath.slice(5); // Remove 'docs/'
} else if (docPath === "docs") {
docPath = "index";
}
// Construct the llms.mdx route with language and slug
const slugParts = docPath.split("/").filter(Boolean);
const llmsRoute =
slugParts.length > 0
? `/${lang}/llms.mdx/${slugParts.join("/")}`
: `/${lang}/llms.mdx`;
return NextResponse.rewrite(new URL(llmsRoute, request.url));
}
// Continue with i18n middleware for non-.md requests
return i18nMiddleware(request, event);
}
export const config = {
// Matcher ignoring `/_next/` and `/api/` but including .md files
matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
};
================================================
FILE: source.config.ts
================================================
import {
defineConfig,
defineDocs,
frontmatterSchema,
metaSchema,
} from "fumadocs-mdx/config";
import rehypeKatex from "rehype-katex";
import remarkMath from "remark-math";
import { z } from "zod";
export const docs = defineDocs({
dir: "./content/docs",
docs: {
schema: frontmatterSchema.extend({
index: z.boolean().default(false),
colab: z.string().optional(),
}),
postprocess: {
includeProcessedMarkdown: true,
},
},
meta: {
schema: metaSchema,
},
});
export default defineConfig({
mdxOptions: {
remarkPlugins: [remarkMath],
rehypePlugins: (v) => [rehypeKatex, ...v],
},
});
================================================
FILE: tsconfig.json
================================================
{
"compilerOptions": {
"baseUrl": ".",
"target": "ESNext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true,
"paths": {
"@/.source": [
"./.source/server.ts"
],
"@/*": [
"./*"
]
},
"plugins": [
{
"name": "next"
}
]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"tailwind.config.js",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
================================================
FILE: utils/process-markdown-links.ts
================================================
/**
* Processes markdown content to convert relative links to absolute URLs with .md extension
* This is used when copying markdown content for LLMs
*/
export function processMarkdownLinks(
content: string,
baseUrl: string = 'https://aicademyorg.netlify.app/',
): string {
// Process standard markdown links: [text](/path)
content = content.replace(/\[([^\]]+)\]\(\/([^)]+)\)/g, (match, text, path) => {
// Skip if it's already an absolute URL
if (path.startsWith('http://') || path.startsWith('https://')) {
return match;
}
// Remove any trailing slashes
const cleanPath = path.replace(/\/$/, '');
// Don't add .md if it already has an extension or is an anchor
if (cleanPath.includes('.') || cleanPath.includes('#')) {
return `[${text}](${baseUrl}/${cleanPath})`;
}
// Add .md extension for documentation links
return `[${text}](${baseUrl}/${cleanPath}.md)`;
});
// Process HTML links: <a href="/path">
content = content.replace(/href="\/([^"]+)"/g, (match, path) => {
// Skip if it's already an absolute URL
if (path.startsWith('http://') || path.startsWith('https://')) {
return match;
}
// Remove any trailing slashes
const cleanPath = path.replace(/\/$/, '');
// Don't add .md if it already has an extension or is an anchor
if (cleanPath.includes('.') || cleanPath.includes('#')) {
return `href="${baseUrl}/${cleanPath}"`;
}
// Add .md extension for documentation links
return `href="${baseUrl}/${cleanPath}.md"`;
});
// Process reference-style links: [text]: /path
content = content.replace(/^\[([^\]]+)\]:\s*\/(.+)$/gm, (match, ref, path) => {
// Skip if it's already an absolute URL
if (path.startsWith('http://') || path.startsWith('https://')) {
return match;
}
// Remove any trailing slashes
const cleanPath = path.replace(/\/$/, '');
// Don't add .md if it already has an extension
if (cleanPath.includes('.') || cleanPath.includes('#')) {
return `[${ref}]: ${baseUrl}/${cleanPath}`;
}
// Add .md extension for documentation links
return `[${ref}]: ${baseUrl}/${cleanPath}.md`;
});
return content;
}
gitextract_b1h8jdvd/
├── .env-example
├── .gitignore
├── CITATION.cff
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── app/
│ ├── [lang]/
│ │ ├── (home)/
│ │ │ ├── layout.tsx
│ │ │ └── page.tsx
│ │ ├── api/
│ │ │ └── search/
│ │ │ └── route.ts
│ │ ├── docs/
│ │ │ ├── [[...slug]]/
│ │ │ │ └── page.tsx
│ │ │ ├── layout.tsx
│ │ │ └── raw/
│ │ │ └── [...slug]/
│ │ │ └── route.ts
│ │ ├── global.css
│ │ ├── layout.tsx
│ │ └── llms.mdx/
│ │ └── [[...slug]]/
│ │ └── route.ts
│ ├── layout.config.tsx
│ └── llms-full.txt/
│ └── route.ts
├── components/
│ ├── ai/
│ │ └── page-actions.tsx
│ ├── banner.tsx
│ ├── feedback.tsx
│ ├── footer.tsx
│ └── mdx/
│ └── mermaid.tsx
├── content/
│ └── docs/
│ ├── math/
│ │ ├── index.mdx
│ │ └── meta.json
│ ├── meta.json
│ └── python/
│ ├── index.mdx
│ ├── matplotlib/
│ │ └── index.mdx
│ ├── meta.json
│ ├── numpy/
│ │ └── index.mdx
│ ├── pandas/
│ │ └── index.mdx
│ ├── python/
│ │ ├── control-flow.mdx
│ │ ├── data-structures.mdx
│ │ ├── data-types.mdx
│ │ ├── error-handling.mdx
│ │ ├── file-handling.mdx
│ │ ├── functions.mdx
│ │ ├── hello-world.mdx
│ │ ├── index.mdx
│ │ ├── meta.json
│ │ ├── oop.mdx
│ │ └── operators.mdx
│ ├── scikit-learn/
│ │ └── index.mdx
│ └── setup.mdx
├── lib/
│ ├── cn.ts
│ ├── get-llm-text.ts
│ ├── github.ts
│ ├── i18n.ts
│ ├── metadata.ts
│ └── source.ts
├── mdx-components.tsx
├── next.config.mjs
├── package.json
├── postcss.config.mjs
├── proxy.ts
├── source.config.ts
├── tsconfig.json
└── utils/
└── process-markdown-links.ts
SYMBOL INDEX (41 symbols across 23 files)
FILE: app/[lang]/(home)/layout.tsx
function Layout (line 16) | async function Layout({
FILE: app/[lang]/(home)/page.tsx
function HomePage (line 3) | function HomePage() {
FILE: app/[lang]/docs/[[...slug]]/page.tsx
function DocsCategory (line 21) | function DocsCategory({ url, lang }: { url: string; lang: string }) {
function Page (line 33) | async function Page(props: {
function generateStaticParams (line 111) | async function generateStaticParams() {
function generateMetadata (line 115) | async function generateMetadata(props: {
FILE: app/[lang]/docs/layout.tsx
method transform (line 13) | transform(option, node) {
function Layout (line 40) | async function Layout({
FILE: app/[lang]/docs/raw/[...slug]/route.ts
function findFileWithParentheses (line 6) | async function findFileWithParentheses(
function GET (line 48) | async function GET(
FILE: app/[lang]/layout.tsx
function generateMetadata (line 24) | async function generateMetadata({
function RootLayout (line 59) | async function RootLayout({
FILE: app/[lang]/llms.mdx/[[...slug]]/route.ts
function GET (line 8) | async function GET(
function generateStaticParams (line 19) | function generateStaticParams() {
FILE: app/layout.config.tsx
function baseOptions (line 54) | function baseOptions(locale: string): BaseLayoutProps {
FILE: app/llms-full.txt/route.ts
function GET (line 7) | async function GET() {
FILE: components/ai/page-actions.tsx
function LLMCopyButton (line 17) | function LLMCopyButton({ markdownUrl }: { markdownUrl: string }) {
function LLMCopyButtonWithDropdown (line 59) | function LLMCopyButtonWithDropdown({
FILE: components/banner.tsx
function SiteBanner (line 4) | function SiteBanner() {
FILE: components/feedback.tsx
type Feedback (line 26) | interface Feedback {
type ActionResponse (line 32) | interface ActionResponse {
type Result (line 36) | interface Result extends Feedback {
function Feedback (line 40) | function Feedback({
FILE: components/footer.tsx
constant YEAR (line 14) | const YEAR = new Date().getFullYear();
FILE: components/mdx/mermaid.tsx
function Mermaid (line 6) | function Mermaid({ chart }: { chart: string }) {
FILE: lib/get-llm-text.ts
function getLLMText (line 4) | async function getLLMText(page: InferPageType<typeof source>) {
FILE: lib/github.ts
function getOctokit (line 10) | async function getOctokit(): Promise<Octokit> {
type RepositoryInfo (line 41) | interface RepositoryInfo {
function getFeedbackDestination (line 52) | async function getFeedbackDestination() {
type ActionResponse (line 74) | interface ActionResponse {
function onRateAction (line 78) | async function onRateAction(
FILE: lib/i18n.ts
type Language (line 9) | type Language = (typeof i18n.languages)[number];
function localizeUrl (line 11) | function localizeUrl(url: string, lang: Language): string {
type FeedbackTranslations (line 15) | interface FeedbackTranslations {
type UIDictionary (line 26) | interface UIDictionary {
FILE: lib/metadata.ts
function createMetadata (line 3) | function createMetadata(override: Metadata): Metadata {
FILE: lib/source.ts
method icon (line 13) | icon(icon) {
FILE: mdx-components.tsx
function getMDXComponents (line 10) | function getMDXComponents(components?: MDXComponents): MDXComponents {
FILE: next.config.mjs
method rewrites (line 8) | async rewrites() {
FILE: proxy.ts
function proxy (line 8) | function proxy(request: NextRequest, event: NextFetchEvent) {
FILE: utils/process-markdown-links.ts
function processMarkdownLinks (line 5) | function processMarkdownLinks(
Condensed preview — 59 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (100K chars).
[
{
"path": ".env-example",
"chars": 93,
"preview": "GITHUB_APP_ID=app_id\nGITHUB_APP_PRIVATE_KEY=\"-----Base64 encoded GitHub App private key-----\""
},
{
"path": ".gitignore",
"chars": 274,
"preview": "# deps\n/node_modules\n\n# generated content\n.contentlayer\n.content-collections\n.source\n\n# test & build\n/coverage\n/.next/\n/"
},
{
"path": "CITATION.cff",
"chars": 366,
"preview": "cff-version: 1.2.0\ntitle: AIcademy\nmessage: >-\n If you use this software, please cite it using the\n metadata from this"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 1290,
"preview": "# Code of Conduct\n\nAIcademy is a friendly place to learn about AI. We’re committed to keeping it that way.\n\nBy using AIc"
},
{
"path": "CONTRIBUTING.md",
"chars": 606,
"preview": "# Contributing to AIcademy\n\nThank you for your interest in contributing to AIcademy.\n\nWhether you're fixing a typo, impr"
},
{
"path": "LICENSE",
"chars": 1062,
"preview": "MIT License\n\nCopyright © 2025 AIcademy\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof "
},
{
"path": "README.md",
"chars": 789,
"preview": "# AIcademy\n\nAIcademy is a friendly community offering free AI education.\n\n## Installation\n\nEnsure [pnpm](https://pnpm.io"
},
{
"path": "SECURITY.md",
"chars": 603,
"preview": "# Security Policy\n\nAt AIcademy, we take platform security seriously. \n\nWhile we don’t collect personal data or require s"
},
{
"path": "app/[lang]/(home)/layout.tsx",
"chars": 3586,
"preview": "import type { ReactNode } from \"react\";\nimport { HomeLayout } from \"fumadocs-ui/layouts/home\";\nimport { baseOptions, lin"
},
{
"path": "app/[lang]/(home)/page.tsx",
"chars": 714,
"preview": "import Link from 'next/link';\n\nexport default function HomePage() {\n return (\n <main\n style={{\n flex: 1,"
},
{
"path": "app/[lang]/api/search/route.ts",
"chars": 153,
"preview": "import { source } from '@/lib/source';\nimport { createFromSource } from 'fumadocs-core/search/server';\n\nexport const { G"
},
{
"path": "app/[lang]/docs/[[...slug]]/page.tsx",
"chars": 3933,
"preview": "import { source } from \"@/lib/source\";\nimport {\n DocsPage,\n DocsBody,\n DocsDescription,\n DocsTitle,\n PageLastUpdate"
},
{
"path": "app/[lang]/docs/layout.tsx",
"chars": 1373,
"preview": "import { DocsLayout, type DocsLayoutProps } from \"fumadocs-ui/layouts/docs\";\nimport type { ReactNode } from \"react\";\nimp"
},
{
"path": "app/[lang]/docs/raw/[...slug]/route.ts",
"chars": 2291,
"preview": "import { existsSync } from 'node:fs';\nimport { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:p"
},
{
"path": "app/[lang]/global.css",
"chars": 389,
"preview": "@import \"tailwindcss\";\n@import \"fumadocs-ui/css/neutral.css\";\n@import \"fumadocs-ui/css/preset.css\";\n\n:root {\n --purple-"
},
{
"path": "app/[lang]/layout.tsx",
"chars": 1907,
"preview": "import \"./global.css\";\nimport \"katex/dist/katex.css\";\nimport { RootProvider } from 'fumadocs-ui/provider/next';\nimport {"
},
{
"path": "app/[lang]/llms.mdx/[[...slug]]/route.ts",
"chars": 590,
"preview": "import { type NextRequest, NextResponse } from \"next/server\";\nimport { getLLMText } from \"@/lib/get-llm-text\";\nimport { "
},
{
"path": "app/layout.config.tsx",
"chars": 4895,
"preview": "import type { LinkItemType } from \"fumadocs-ui/layouts/shared\";\nimport type { BaseLayoutProps } from \"fumadocs-ui/layout"
},
{
"path": "app/llms-full.txt/route.ts",
"chars": 313,
"preview": "import { source } from \"@/lib/source\";\nimport { getLLMText } from \"@/lib/get-llm-text\";\n\n// cached forever\nexport const "
},
{
"path": "components/ai/page-actions.tsx",
"chars": 11466,
"preview": "\"use client\";\nimport { useMemo, useState } from \"react\";\nimport { Check, ChevronDown, Copy, ExternalLinkIcon } from \"luc"
},
{
"path": "components/banner.tsx",
"chars": 399,
"preview": "import { Banner } from \"fumadocs-ui/components/banner\";\nimport Link from \"next/link\";\n\nexport function SiteBanner() {\n "
},
{
"path": "components/feedback.tsx",
"chars": 5495,
"preview": "\"use client\";\nimport { cn } from \"@/lib/cn\";\nimport { buttonVariants } from \"fumadocs-ui/components/ui/button\";\nimport {"
},
{
"path": "components/footer.tsx",
"chars": 2397,
"preview": "import Image from \"next/image\";\nimport {\n SiDiscord,\n SiGithub,\n SiX,\n SiYoutube,\n SiInstagram,\n SiLinkedin,\n // "
},
{
"path": "components/mdx/mermaid.tsx",
"chars": 1324,
"preview": "'use client';\n\nimport { useEffect, useId, useRef, useState } from 'react';\nimport { useTheme } from 'next-themes';\n\nexpo"
},
{
"path": "content/docs/math/index.mdx",
"chars": 86,
"preview": "---\ntitle: Mathematics\ndescription: Mathematics for Machine Learning\nicon: Code \n---\n\n"
},
{
"path": "content/docs/math/meta.json",
"chars": 111,
"preview": "{\n \"title\": \"Mathematics\",\n \"description\": \"Maths for Machine Learning\",\n \"root\": true,\n \"icon\": \"Sigma\"\n}\n"
},
{
"path": "content/docs/meta.json",
"chars": 93,
"preview": "{\n \"pages\": [\"python\", \"math\"],\n \"description\": \"Welcome to the AIcademy documentation!\"\n}\n"
},
{
"path": "content/docs/python/index.mdx",
"chars": 2799,
"preview": "---\ntitle: Welcome\ndescription: Learn Python for Data Science\nicon: Album\n---\n\nimport { Accordion, Accordions } from \"fu"
},
{
"path": "content/docs/python/matplotlib/index.mdx",
"chars": 108,
"preview": "---\ntitle: Matplotlib\ndescription: Getting started with Python\nicon: Terminal\nindex: true\n---\n\n## Matplotlib"
},
{
"path": "content/docs/python/meta.json",
"chars": 297,
"preview": "{\n \"title\": \"Python\",\n \"description\": \"Python for Data Science\",\n \"icon\": \"SiPython\",\n \"root\": true,\n \"pages\": [\n "
},
{
"path": "content/docs/python/numpy/index.mdx",
"chars": 97,
"preview": "---\ntitle: NumPy\ndescription: Getting started with Python\nicon: SiNumpy\nindex: true\n---\n\n## NumPy"
},
{
"path": "content/docs/python/pandas/index.mdx",
"chars": 100,
"preview": "---\ntitle: Pandas\ndescription: Getting started with Python\nicon: SiPandas\nindex: true\n---\n\n## Pandas"
},
{
"path": "content/docs/python/python/control-flow.mdx",
"chars": 265,
"preview": "---\ntitle: Control Flow\ndescription: Direct the logic of your program with conditions and loops.\n---\n\n5.1 Conditional St"
},
{
"path": "content/docs/python/python/data-structures.mdx",
"chars": 258,
"preview": "---\ntitle: Data Structures\ndescription: Store and organize data with Python's built-in collections.\n---\n\n6.1 Lists\n\n- Cr"
},
{
"path": "content/docs/python/python/data-types.mdx",
"chars": 9058,
"preview": "---\ntitle: Data Types\ndescription: Work with and manipulate different types of data.\n---\n\nIn Python, data types classify"
},
{
"path": "content/docs/python/python/error-handling.mdx",
"chars": 233,
"preview": "---\ntitle: Error Handling\ndescription: Handle errors gracefully and write reliable code.\n---\n\n10.1 Types of Exceptions\n\n"
},
{
"path": "content/docs/python/python/file-handling.mdx",
"chars": 258,
"preview": "---\ntitle: File Handling\ndescription: Reading and writing files with Python\n---\n\n7.1 Opening Files with open()\n\n7.2 Read"
},
{
"path": "content/docs/python/python/functions.mdx",
"chars": 305,
"preview": "---\ntitle: Functions\ndescription: Write modular, reusable code.\n---\n\n8.1 Defining Functions with def\n\n8.2 Arguments and "
},
{
"path": "content/docs/python/python/hello-world.mdx",
"chars": 276,
"preview": "---\ntitle: Hello, World!\ndescription: Understand the building blocks of a Python program.\n---\n\nHello, World! in python i"
},
{
"path": "content/docs/python/python/index.mdx",
"chars": 1469,
"preview": "---\ntitle: Python\ndescription: Getting started with Python\nicon: SiPython\nindex: true\n---\n\nPython is a high-level progra"
},
{
"path": "content/docs/python/python/meta.json",
"chars": 188,
"preview": "{\n \"pages\": [\n \"hello-world\",\n \"operators\",\n \"data-types\",\n \"control-flow\",\n \"data-structures\",\n \"fil"
},
{
"path": "content/docs/python/python/oop.mdx",
"chars": 406,
"preview": "---\ntitle: Object Oriented \ndescription: Model real-world systems using classes and objects.\n---\n\n9.1 What is OOP?\n\n9.2 "
},
{
"path": "content/docs/python/python/operators.mdx",
"chars": 5571,
"preview": "---\ntitle: Operators\ndescription: Calculations and comparisons using operators.\n---\n\nOperators are symbols used to perfo"
},
{
"path": "content/docs/python/scikit-learn/index.mdx",
"chars": 117,
"preview": "---\ntitle: Scikit Learn\ndescription: Getting started with Python\nicon: SiScikitlearn\nindex: true\n---\n\n## Scikit Learn"
},
{
"path": "content/docs/python/setup.mdx",
"chars": 4006,
"preview": "---\ntitle: Setup\ndescription: Setting up your Python environment\nicon: Settings2\ncolab: https://colab.research.google.co"
},
{
"path": "lib/cn.ts",
"chars": 48,
"preview": "export { twMerge as cn } from 'tailwind-merge';\n"
},
{
"path": "lib/get-llm-text.ts",
"chars": 433,
"preview": "import { source } from \"@/lib/source\";\nimport type { InferPageType } from \"fumadocs-core/source\";\n\nexport async function"
},
{
"path": "lib/github.ts",
"chars": 5258,
"preview": "import { App, Octokit } from \"octokit\";\nimport type { Feedback } from \"@/components/feedback\";\n\nexport const repo = \"AIc"
},
{
"path": "lib/i18n.ts",
"chars": 4232,
"preview": "import { defineI18n } from \"fumadocs-core/i18n\";\n\nexport const i18n = defineI18n({\n defaultLanguage: \"en\",\n languages:"
},
{
"path": "lib/metadata.ts",
"chars": 866,
"preview": "import type { Metadata } from \"next/types\";\n\nexport function createMetadata(override: Metadata): Metadata {\n return {\n "
},
{
"path": "lib/source.ts",
"chars": 666,
"preview": "import { docs } from \"@/.source/server\";\nimport { loader } from \"fumadocs-core/source\";\nimport { i18n } from \"@/lib/i18n"
},
{
"path": "mdx-components.tsx",
"chars": 791,
"preview": "import defaultMdxComponents from \"fumadocs-ui/mdx\";\nimport * as FilesComponents from \"fumadocs-ui/components/files\";\nimp"
},
{
"path": "next.config.mjs",
"chars": 349,
"preview": "import { createMDX } from \"fumadocs-mdx/next\";\n\nconst withMDX = createMDX();\n\n/** @type {import('next').NextConfig} */\nc"
},
{
"path": "package.json",
"chars": 1114,
"preview": "{\n \"name\": \"aicademy\",\n \"version\": \"0.0.0\",\n \"private\": true,\n \"scripts\": {\n \"build\": \"next build\",\n \"dev\": \"n"
},
{
"path": "postcss.config.mjs",
"chars": 93,
"preview": "const config = {\n plugins: {\n \"@tailwindcss/postcss\": {},\n },\n};\nexport default config;\n"
},
{
"path": "proxy.ts",
"chars": 1874,
"preview": "import type { NextRequest, NextFetchEvent } from \"next/server\";\nimport { NextResponse } from \"next/server\";\nimport { cre"
},
{
"path": "source.config.ts",
"chars": 648,
"preview": "import {\n defineConfig,\n defineDocs,\n frontmatterSchema,\n metaSchema,\n} from \"fumadocs-mdx/config\";\nimport rehypeKat"
},
{
"path": "tsconfig.json",
"chars": 850,
"preview": "{\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"target\": \"ESNext\",\n \"lib\": [\n \"dom\",\n \"dom.iterable\",\n "
},
{
"path": "utils/process-markdown-links.ts",
"chars": 2334,
"preview": "/**\n * Processes markdown content to convert relative links to absolute URLs with .md extension\n * This is used when cop"
}
]
About this extraction
This page contains the full source code of the severus27/OpenML-Guide GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 59 files (89.8 KB), approximately 28.4k tokens, and a symbol index with 41 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.