-
Notifications
You must be signed in to change notification settings - Fork 1
Improve LLM context generation #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,16 +20,28 @@ import { | |
| export interface LlmsTxtPluginOptions { | ||
| siteTitle?: string; | ||
| modelsDir?: string; | ||
| siteUrl: string; | ||
| } | ||
|
|
||
| export default function llmsTxtPlugin( | ||
| options: LlmsTxtPluginOptions = {}, | ||
| ): Plugin { | ||
| const { siteTitle = "Malloy Data Explorer", modelsDir = "models" } = options; | ||
| export default function llmsTxtPlugin(options: LlmsTxtPluginOptions): Plugin { | ||
|
||
| const { | ||
| siteTitle = "Malloy Data Explorer", | ||
| modelsDir = "models", | ||
| siteUrl, | ||
| } = options; | ||
|
|
||
| let config: ResolvedConfig; | ||
|
|
||
| async function generateContent(): Promise<string> { | ||
| // Validate siteUrl is provided | ||
| if (!siteUrl || siteUrl.trim() === "") { | ||
| throw new Error( | ||
| "[llms.txt] SITE_URL environment variable is required. " + | ||
| "Set it in your build command or CI/CD workflow. " + | ||
| "Example: SITE_URL=https://example.com npm run build", | ||
| ); | ||
| } | ||
|
|
||
| const modelsDirPath = path.join(config.root, modelsDir); | ||
|
|
||
| const [models, dataFiles, notebooks] = await Promise.all([ | ||
|
|
@@ -41,6 +53,7 @@ export default function llmsTxtPlugin( | |
| return generateLlmsTxtContent({ | ||
| siteTitle, | ||
| basePath: config.base, | ||
| siteUrl, | ||
| models, | ||
| dataFiles, | ||
| notebooks, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,46 +9,63 @@ import type { ExtractedModel } from "./types"; | |||||
| export interface GeneratorOptions { | ||||||
| siteTitle: string; | ||||||
| basePath: string; | ||||||
| siteUrl: string; | ||||||
| models: ExtractedModel[]; | ||||||
| dataFiles: string[]; | ||||||
| notebooks: string[]; | ||||||
| } | ||||||
|
|
||||||
| export function generateLlmsTxtContent(options: GeneratorOptions): string { | ||||||
| const { siteTitle, basePath, models, dataFiles, notebooks } = options; | ||||||
| const { siteTitle, basePath, siteUrl, models, dataFiles, notebooks } = | ||||||
| options; | ||||||
|
|
||||||
| const sections = [ | ||||||
| generateHeader(siteTitle, basePath), | ||||||
| generateOverview(siteTitle, basePath, models, dataFiles, notebooks), | ||||||
| generateHeader(siteTitle, basePath, siteUrl), | ||||||
| generateOverview( | ||||||
| siteTitle, | ||||||
| basePath, | ||||||
| siteUrl, | ||||||
| models, | ||||||
| dataFiles, | ||||||
| notebooks, | ||||||
| ), | ||||||
| generateModelsSection(models, basePath), | ||||||
|
||||||
| generateModelsSection(models, basePath), | |
| generateModelsSection(models, basePath, siteUrl), |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new URL construction logic and siteUrl integration lack test coverage. Given that the repository has comprehensive unit tests for other utilities (download-utils, notebook-parser, schema-utils), consider adding tests for the generator module to verify URL construction works correctly with various siteUrl and basePath combinations, especially edge cases like trailing slashes and empty basePath.
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL construction logic that removes trailing slashes from both siteUrl and basePath is duplicated across generateHeader (lines 45-46) and generateOverview (lines 63-64). Consider extracting this into a shared utility function like buildFullUrl(siteUrl: string, basePath: string): string to reduce duplication and ensure consistency.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,47 @@ | ||
| /// <reference types="vitest/config" /> | ||
| import { defineConfig, type UserConfig } from "vite"; | ||
| import { defineConfig } from "vite"; | ||
| import type { UserConfigFnObject } from "vite"; | ||
| import react from "@vitejs/plugin-react"; | ||
| import svgr from "vite-plugin-svgr"; | ||
| import copyDownloadsPlugin from "./plugins/vite-plugin-copy-downloads"; | ||
| import llmsTxtPlugin from "./plugins/vite-plugin-llms-txt"; | ||
|
|
||
| // https://vite.dev/config/ | ||
| const config: UserConfig = defineConfig({ | ||
| // NOTE: THIS PATH MUST END WITH A TRAILING SLASH | ||
| base: process.env["BASE_PUBLIC_PATH"] ?? "/", | ||
| plugins: [react(), svgr(), copyDownloadsPlugin(), llmsTxtPlugin()], | ||
| define: { | ||
| "process.env": {}, | ||
| }, | ||
| optimizeDeps: { | ||
| esbuildOptions: { | ||
| target: "esnext", | ||
| const config: ReturnType<typeof defineConfig> = defineConfig((({ mode }) => { | ||
| const siteUrl = | ||
| process.env["SITE_URL"] ?? | ||
| (mode === "development" ? "http://localhost:5173" : null); | ||
|
|
||
| if (null === siteUrl) { | ||
| throw new Error( | ||
| "SITE_URL environment variable is required for production builds. " + | ||
| "Set it in your build command or CI/CD workflow.", | ||
| ); | ||
| } | ||
|
|
||
| return { | ||
| // NOTE: THIS PATH MUST END WITH A TRAILING SLASH | ||
| base: process.env["BASE_PUBLIC_PATH"] ?? "/", | ||
| plugins: [ | ||
| react(), | ||
| svgr(), | ||
| copyDownloadsPlugin(), | ||
| llmsTxtPlugin({ | ||
| siteUrl, | ||
| }), | ||
| ], | ||
| define: { | ||
| "process.env": {}, | ||
| }, | ||
| optimizeDeps: { | ||
| esbuildOptions: { | ||
| target: "esnext", | ||
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| include: ["tests/**/*.test.ts", "tests/**/*.test.tsx"], | ||
| }, | ||
| }); | ||
| test: { | ||
| include: ["tests/**/*.test.ts", "tests/**/*.test.tsx"], | ||
| }, | ||
| }; | ||
| }) satisfies UserConfigFnObject); | ||
|
|
||
| export default config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent terminology between README and generator. This line says "sources" but the implementation in Schema.tsx uses "expandedExplores" and the generator.ts says "expanded explores" (line 231). Consider changing "sources" to "explores" here to match the actual implementation and be consistent with the llms.txt documentation.