From 4d832b956f9f0edc21cdd2fc6d6b80e7b8e2afdd Mon Sep 17 00:00:00 2001 From: Saurav Panda Date: Tue, 10 Dec 2024 23:27:31 -0800 Subject: [PATCH 1/2] fix: ai search --- docs/public/context/en_docs.txt | 276 +++++++++---------- docs/src/app/aiSearch/page.tsx | 67 +++-- packages/akiradocs/src/app/aiSearch/page.tsx | 32 ++- 3 files changed, 198 insertions(+), 177 deletions(-) diff --git a/docs/public/context/en_docs.txt b/docs/public/context/en_docs.txt index fb064c6..bd23552 100644 --- a/docs/public/context/en_docs.txt +++ b/docs/public/context/en_docs.txt @@ -474,6 +474,55 @@ Code example: }, } ------------- +[Document: docs/guides/analytics.json] +Title: Analytics Integration +Learn how to add analytics tracking to your documentation +AkiraDocs supports Google Analytics 4 (GA4) out of the box. This guide will help you set up analytics tracking for your documentation. +Setting up Google Analytics +1. Create a Google Analytics 4 property in your [Google Analytics account](https://analytics.google.com/) +2. Get your Measurement ID (starts with "G-") +3. Add the ID to your `akiradocs.config.json`: +Code example: +{ +"analytics": { +"google": { +"measurementId": "G-XXXXXXXXXX", +"enabled": true +}, +"debug": false +} +} +What's Tracked Automatically +Page views +Navigation between pages +Time on page +User language preferences +Device and browser information +Custom Event Tracking +You can track custom events using the `useAnalytics` hook: +Code example: +import { useAnalytics } from '@/hooks/useAnalytics' +function MyComponent() { + const { track } = useAnalytics() + const handleClick = () => { + track('doc_rating', { + rating: 5, + page: 'getting-started', + helpful: true + }) + } + return +} +Debug Mode +Enable debug mode to see analytics events in the console during development: +Code example: +{ +"analytics": { +"debug": true +} +} +This provides a complete analytics integration that's easy for users to set up and extend as needed. +------------- [Document: docs/getting-started/requirements.json] Title: System Requirements Before installing AkiraDocs, ensure your environment meets the following requirements. @@ -582,54 +631,98 @@ Code example: ✓ Docusaurus ✓ ReadTheDocs ------------- -[Document: docs/guides/analytics.json] -Title: Analytics Integration -Learn how to add analytics tracking to your documentation -AkiraDocs supports Google Analytics 4 (GA4) out of the box. This guide will help you set up analytics tracking for your documentation. -Setting up Google Analytics -1. Create a Google Analytics 4 property in your [Google Analytics account](https://analytics.google.com/) -2. Get your Measurement ID (starts with "G-") -3. Add the ID to your `akiradocs.config.json`: +[Document: docs/editor/overview.json] +Title: Editor Overview +AkiraDocs features a modern, Notion-like editor that combines the simplicity of block-based editing with the power of Markdown. +Editor Interface +Main Components +Toolbar: Quick access to formatting options and block types +Content Area: Block-based editing space +Sidebar: Navigation and document structure +Command Palette: Quick commands (Ctrl/Cmd + P) +Block Structure +Each content element is a block that can be: +Dragged and dropped to reorganize +Converted between different types +Duplicated or deleted +Nested within other blocks +Getting Started +Creating Content +1. Click the '+' button or press '/' to add a new block +2. Choose block type from the popup menu +3. Start typing or add content +Basic Operations Code example: -{ -"analytics": { -"google": { -"measurementId": "G-XXXXXXXXXX", -"enabled": true -}, -"debug": false -} -} -What's Tracked Automatically -Page views -Navigation between pages -Time on page -User language preferences -Device and browser information -Custom Event Tracking -You can track custom events using the `useAnalytics` hook: +/ → Open block menu +⌘/Ctrl + P → Command palette +⌘/Ctrl + / → Show keyboard shortcuts +↑↓ → Navigate between blocks +Block Types +Text Blocks +Paragraphs +Headings (H1-H6) +Lists (Bulleted, Numbered) +Quotes +Callouts +Rich Media +Images +Videos +Embeds +Files +Code blocks +Special Blocks +Tables (Coming Soon) +Dividers +Custom components (Coming Soon) +------------- +[Document: docs/editor/features.json] +Title: Editor Features +Detailed overview of AkiraDocs editor capabilities and features. +Block System +Text Formatting +Basic Formatting +Bold, italic, underline +Strikethrough +Highlight +Code inline +Advanced Formatting +Custom colors +Multiple fonts +Text alignment +Indentation +Content Blocks +Rich Text Code example: -import { useAnalytics } from '@/hooks/useAnalytics' -function MyComponent() { - const { track } = useAnalytics() - const handleClick = () => { - track('doc_rating', { - rating: 5, - page: 'getting-started', - helpful: true - }) - } - return -} -Debug Mode -Enable debug mode to see analytics events in the console during development: +# Heading 1 +## Heading 2 +> Blockquote +- Bullet list +1. Numbered list +Code Blocks Code example: -{ -"analytics": { -"debug": true -} -} -This provides a complete analytics integration that's easy for users to set up and extend as needed. +// Syntax highlighting +console.log('Hello World'); +Media Blocks +Image upload and embedding +Video embedding +File attachments +Interactive embeds +AI Features +Content Enhancement +Grammar and style suggestions +Content optimization +SEO recommendations +Translation assistance +Smart Formatting +Auto-formatting +Smart lists +Table formatting +Code block language detection +Collaboration Features +Version Control +Git integration +Change history +Rollback capabilities ------------- [Document: docs/contributing/how-to-contribute.json] Title: Contributing to AkiraDocs @@ -724,99 +817,6 @@ Instances of abusive, harassing, or otherwise unacceptable behavior may be repor Attribution This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. ------------- -[Document: docs/editor/overview.json] -Title: Editor Overview -AkiraDocs features a modern, Notion-like editor that combines the simplicity of block-based editing with the power of Markdown. -Editor Interface -Main Components -Toolbar: Quick access to formatting options and block types -Content Area: Block-based editing space -Sidebar: Navigation and document structure -Command Palette: Quick commands (Ctrl/Cmd + P) -Block Structure -Each content element is a block that can be: -Dragged and dropped to reorganize -Converted between different types -Duplicated or deleted -Nested within other blocks -Getting Started -Creating Content -1. Click the '+' button or press '/' to add a new block -2. Choose block type from the popup menu -3. Start typing or add content -Basic Operations -Code example: -/ → Open block menu -⌘/Ctrl + P → Command palette -⌘/Ctrl + / → Show keyboard shortcuts -↑↓ → Navigate between blocks -Block Types -Text Blocks -Paragraphs -Headings (H1-H6) -Lists (Bulleted, Numbered) -Quotes -Callouts -Rich Media -Images -Videos -Embeds -Files -Code blocks -Special Blocks -Tables (Coming Soon) -Dividers -Custom components (Coming Soon) -------------- -[Document: docs/editor/features.json] -Title: Editor Features -Detailed overview of AkiraDocs editor capabilities and features. -Block System -Text Formatting -Basic Formatting -Bold, italic, underline -Strikethrough -Highlight -Code inline -Advanced Formatting -Custom colors -Multiple fonts -Text alignment -Indentation -Content Blocks -Rich Text -Code example: -# Heading 1 -## Heading 2 -> Blockquote -- Bullet list -1. Numbered list -Code Blocks -Code example: -// Syntax highlighting -console.log('Hello World'); -Media Blocks -Image upload and embedding -Video embedding -File attachments -Interactive embeds -AI Features -Content Enhancement -Grammar and style suggestions -Content optimization -SEO recommendations -Translation assistance -Smart Formatting -Auto-formatting -Smart lists -Table formatting -Code block language detection -Collaboration Features -Version Control -Git integration -Change history -Rollback capabilities -------------- [Document: docs/content-management/creating-pages.json] Title: Creating and Organizing Pages Learn how to create, structure, and organize your documentation pages in AkiraDocs. You can create markdown pages or just use the editor UI. Note in _contents folder, you will only see markdown content created by you. If you use Editor UI, the content will be saved in the compiled folder and will be automatically translated to other languages. diff --git a/docs/src/app/aiSearch/page.tsx b/docs/src/app/aiSearch/page.tsx index 24e4295..1e8ebde 100644 --- a/docs/src/app/aiSearch/page.tsx +++ b/docs/src/app/aiSearch/page.tsx @@ -72,7 +72,8 @@ export default function Home() { setSources([]) // Reset sources try { - // Updated fetch path to use absolute URL + const startEngineTime = performance.now(); + const contextResponse = await fetch('/context/en_docs.txt'); if (!contextResponse.ok) { throw new Error(`Failed to fetch context: ${contextResponse.status}`); @@ -85,47 +86,59 @@ export default function Home() { "Llama-3.2-1B-Instruct-q4f16_1-MLC", { initProgressCallback: (progress: any) => console.log(progress) + }, + { + context_window_size: 100000, } ); + + const engineLoadTime = performance.now() - startEngineTime; + console.log(`Engine initialization took: ${engineLoadTime.toFixed(2)}ms`); // Prepare messages for the chat with context const messages = [ { - role: "system", - content: `You are a technical documentation assistant specialized in providing accurate, concise answers based on the official documentation. - Your responses should be: - 1. Direct and to the point - 2. Based strictly on the provided documentation context - 3. Include relevant code examples when available - 4. Written in a technical but clear style - - Documentation context: ${docsContext}` + role: "system", + content: `You are a technical documentation assistant specialized in providing accurate, concise answers based on the official documentation. + Your responses should be: + 1. Direct and to the point + 2. Based strictly on the provided documentation context + 3. Include relevant code examples when available + 4. Written in a technical but clear style + + Documentation context: ${docsContext}` }, { - role: "user", - content: `Answer the following question using only the provided documentation context. - Question: ${query} - - Requirements for your response: - 1. If the answer isn't clearly supported by the documentation, say "I don't have enough information to answer this question accurately." - 2. Don't make assumptions or provide information not found in the documentation - 3. If relevant, include short code snippets to illustrate your answer. - 4. Only answer questions related to the Documentaion Context. - 5. Try to be concise and to the point. - - After your answer, if you used any sources from the documentation, list them in this format: - ------------- - Sources: - - (<path>)` + role: "user", + content: `Answer the following question using only the provided documentation context. + Question: ${query} + Requirements for your response: + 1. If the answer isn't clearly supported by the documentation and you cant find relevant information in the documentation, say \"I don't have enough information to answer this question accurately.\" + 2. Strictly adhere to the documentation context; do not make assumptions or provide additional commentary. + 3. Include short code snippets if relevant. + 4. Only answer questions related to the Documentation Context. + 5. Be concise and to the point. + After your answer, if you used any sources from the documentation, list them in this format: + ------------- + Sources: + - <title> (<path>) + Example: + Sources: + - Welcome to Akira Docs (articles/welcome.json)` } - ]; + ]; + console.log(messages) + const startChatTime = performance.now(); // Get response from MLC chatbot const reply = await engine.chat.completions.create({ messages: messages as ChatCompletionMessageParam[] }); - const aiContent = reply.choices[0].message.content || ''; + const chatCompletionTime = performance.now() - startChatTime; + console.log(`Chat completion took: ${chatCompletionTime.toFixed(2)}ms`); + const aiContent = reply.choices[0].message.content || ''; + console.log("Response aiContent", aiContent) // Extract sources and clean response const { cleanResponse, sources } = extractSources(aiContent); diff --git a/packages/akiradocs/src/app/aiSearch/page.tsx b/packages/akiradocs/src/app/aiSearch/page.tsx index 24e4295..a620cdf 100644 --- a/packages/akiradocs/src/app/aiSearch/page.tsx +++ b/packages/akiradocs/src/app/aiSearch/page.tsx @@ -69,10 +69,9 @@ export default function Home() { e.preventDefault() setIsLoading(true) setError(null) - setSources([]) // Reset sources + setSources([]) try { - // Updated fetch path to use absolute URL const contextResponse = await fetch('/context/en_docs.txt'); if (!contextResponse.ok) { throw new Error(`Failed to fetch context: ${contextResponse.status}`); @@ -80,15 +79,15 @@ export default function Home() { const contextData = await contextResponse.text(); const docsContext = contextData; - // Initialize MLC Engine const engine = await CreateMLCEngine( "Llama-3.2-1B-Instruct-q4f16_1-MLC", - { - initProgressCallback: (progress: any) => console.log(progress) + { initProgressCallback: (progress: any) => console.log(progress) + }, + { + context_window_size: 100000, } ); - // Prepare messages for the chat with context const messages = [ { role: "system", @@ -120,15 +119,24 @@ export default function Home() { } ]; - console.log(messages) + console.log("messages", messages) + + const chunks = await engine.chat.completions.create({ + messages: messages as ChatCompletionMessageParam[], + stream: true, + stream_options: { include_usage: true } + }); - // Get response from MLC chatbot - const reply = await engine.chat.completions.create({ messages: messages as ChatCompletionMessageParam[] }); - const aiContent = reply.choices[0].message.content || ''; + let aiContent = ""; + for await (const chunk of chunks) { + const newContent = chunk.choices[0]?.delta.content || ""; + aiContent += newContent; + // Update the response in real-time + setAiResponse(aiContent); + } - // Extract sources and clean response + // Extract sources after the full response is received const { cleanResponse, sources } = extractSources(aiContent); - setAiResponse(cleanResponse); setSources(sources); From e8ea5203c9391ff441b2f793345c04bd1d0a046f Mon Sep 17 00:00:00 2001 From: Saurav Panda <sgp65@cornell.edu> Date: Tue, 10 Dec 2024 23:53:25 -0800 Subject: [PATCH 2/2] new version released --- docs/package-lock.json | 5 +- docs/package.json | 2 +- docs/public/context/en_docs.txt | 844 +----------------- docs/public/sitemap.xml | 304 ------- docs/src/app/aiSearch/page.tsx | 89 +- .../src/components/layout/TableOfContents.tsx | 28 +- packages/create-app/package.json | 2 +- 7 files changed, 80 insertions(+), 1194 deletions(-) diff --git a/docs/package-lock.json b/docs/package-lock.json index a68f526..f48f35a 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -1,12 +1,12 @@ { "name": "akiradocs", - "version": "1.0.44", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "akiradocs", - "version": "1.0.44", + "version": "1.0.1", "dependencies": { "@ai-sdk/anthropic": "^1.0.1", "@dnd-kit/core": "^6.1.0", @@ -529,6 +529,7 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", + "extraneous": true, "inBundle": true, "license": "MIT", "engines": { diff --git a/docs/package.json b/docs/package.json index 6d2f6b1..4919faf 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "akiradocs", - "version": "1.0.44", + "version": "1.0.46", "private": true, "scripts": { "translate": "npm run compile && node scripts/translate.js", diff --git a/docs/public/context/en_docs.txt b/docs/public/context/en_docs.txt index bd23552..c52da6a 100644 --- a/docs/public/context/en_docs.txt +++ b/docs/public/context/en_docs.txt @@ -1,36 +1,12 @@ [Document: docs/introduction.json] -Title: Introduction to AkiraDocs -AkiraDocs is a next-generation documentation platform that combines the power of AI with an intuitive content management system. It's designed to transform your documentation workflow from days to minutes. -Why AkiraDocs? -Documentation is often a challenge for teams: -Developers want to keep using Markdown and Git -Content teams need user-friendly editors -Technical writers struggle with version management -Product managers deal with out-of-sync documentation -Enterprise leaders need better analytics -AkiraDocs solves these challenges by providing a unified platform that brings everyone's workflow together. -Core Benefits -<strong>Universal Workflow</strong>: Developers keep their Markdown/Git workflow while content teams get a block-based WYSIWYG editor -<strong>AI-Powered</strong>: Automatic content updates, translations, and optimizations -<strong>SEO-Optimized</strong>: Documentation that ranks well by default -<strong>Multi-Language Support</strong>: AI-powered translations with context awareness -<strong>Enterprise-Ready</strong>: SSO/SAML integration, audit logs, and custom deployment options -Who Is It For? -Developer Documentation -API documentation -SDK guides -Technical specifications -Implementation guides -Product Documentation -User guides -Feature documentation -Release notes -FAQs -Enterprise Documentation -Internal knowledge bases -Process documentation -Compliance documentation -Training materials +Title: Introduction +<strong>Akira Docs</strong> is a modern documentation platform that combines the power of AI with an intuitive block-based content system. This guide will help you understand the core concepts and features. +Key Features +AI-powered search +Block-based content editing +Responsive design +Customizable themes +Markdown support ------------- [Document: articles/welcome.json] Title: Welcome to Akira Doc @@ -90,390 +66,6 @@ ai_assistant: Next Steps Explore our [Advanced AI Features](/advanced-ai-features) guide to learn more about specialized use cases and integration possibilities. ------------- -[Document: docs/seo-and-performance/sitemap-generation.json] -Title: Automatic Sitemap Generation -Learn how AkiraDocs automatically generates and manages your documentation sitemap. -Overview -AkiraDocs automatically generates a sitemap.xml file during the build process, ensuring search engines can efficiently crawl your documentation. -Generated Sitemap Structure -Example Output -Code example: -<?xml version="1.0" encoding="UTF-8"?> -<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> - <url> - <loc>https://yourdocs.com/</loc> - <lastmod>2024-11-26</lastmod> - <changefreq>weekly</changefreq> - <priority>1.0</priority> - </url> - <url> - <loc>https://yourdocs.com/docs/getting-started</loc> - <lastmod>2024-11-26</lastmod> - <changefreq>weekly</changefreq> - <priority>0.8</priority> - </url> -</urlset> -------------- -[Document: docs/seo-and-performance/robot-txt.json] -Title: Robots.txt Configuration -The robots.txt file is automatically generated during the build process and can be found in the `public` folder of your project. -Default Configuration -Basic robots.txt -Code example: -User-agent: * -Allow: / -Sitemap: https://docs.akiradocs.com/sitemap.xml - -# Private sections -Disallow: /admin/ -Disallow: /private/ -------------- -[Document: docs/internationalization/setup.json] -Title: Setting Up Internationalization -Configure AkiraDocs for multiple languages with AI-powered translation support. -Quick Setup -Basic Configuration -Add language settings to `akiradocs.config.json`: -Code example: -{ - "localization": { - "defaultLocale": "en", - "fallbackLocale": "en", - "locales": [ - { - "code": "en", - "name": "English", - "flag": "�🇸" - }, - { - "code": "es", - "name": "Español", - "flag": "🇪🇸" - }, - { - "code": "fr", - "name": "Français", - "flag": "🇫🇷" - } - ] - }, - "translation": { - "auto_translate": true, - "provider": "anthropic", - "targetLanguages": ["es", "fr", "de"], - "excludedPaths": ["_meta.json"] - } -} -Directory Structure -Code example: -docs/ -├── _contents/ -│ ├── en/ # Source language -│ │ └── docs/ -│ ├── es/ # Spanish translation -│ │ └── docs/ -│ └── fr/ # French translation -│ └── docs/ -Configuration Options -Language Settings -`defaultLocale`: Primary content language -`fallbackLocale`: Fallback when translation missing -`locales`: Available language configurations -Translation Settings -`auto_translate`: Enable/disable automatic translation -`provider`: AI translation provider -`targetLanguages`: Languages to translate into -`excludedPaths`: Files to skip during translation -------------- -[Document: docs/internationalization/managing-translation.json] -Title: Managing Translations -Learn how to effectively manage and maintain translated content in AkiraDocs. -Translation Workflow -Automatic Translation -1. Create content in source language -2. Enable auto-translation in config -3. Build/deploy to generate translations -4. Review and refine translations -Manual Translation -1. Create language-specific directories -2. Copy source content -3. Translate manually -4. Update metadata -Content Organization -File Structure -Code example: -_contents/ -├── en/ -│ └── docs/ -│ ├── intro.md -│ └── guide.md -├── es/ -│ └── docs/ -│ ├── intro.md -│ └── guide.md -└── fr/ - └── docs/ - ├── intro.md - └── guide.md -Quality Control -Review Process -1. AI Translation -2. Human Review -3. Technical Verification -4. Publication -Version Control -Track changes across languages -Maintain synchronization -Handle updates efficiently -------------- -[Document: docs/internationalization/ai-translation.json] -Title: AI-Powered Translation -Guide to using AkiraDocs' AI translation capabilities. -Setup -Configuration -Code example: -{ - "translation": { - "auto_translate": true, - "provider": "anthropic", - "model": "claude-3-sonnet-20240229", - "targetLanguages": ["es", "fr", "de"], - "excludedPaths": ["_meta.json"] - } -} -API Setup -Code example: -ANTHROPIC_API_KEY=your_api_key -Features -Automatic Translation -Content translation during build -Context-aware translations -Technical term preservation -Format maintenance -------------- -[Document: docs/installation/troubleshooting.json] -Title: Troubleshooting Guide -Common issues and their solutions when setting up AkiraDocs. -Common Installation Issues -Node.js Version Mismatch -<strong>Problem</strong>: Error about Node.js version compatibility -Code example: -Error: The engine "node" is incompatible with this module -<strong>Solution</strong>: -1. Check your Node.js version: -Code example: -node --version -2. Install the correct version (16.x or higher) -3. Use nvm to manage Node.js versions: -Code example: -nvm install 20 -nvm use 20 -Dependencies Installation Failed -<strong>Problem</strong>: npm install fails with errors -<strong>Solution</strong>: -1. Clear npm cache: -Code example: -npm cache clean --force -2. Delete node_modules and package-lock.json: -Code example: -rm -rf node_modules package-lock.json -npm install -Build Issues -Build Fails -<strong>Problem</strong>: `npm run build` fails -<strong>Solution</strong>: -1. Check for TypeScript errors: -Code example: -npm run type-check -2. Verify environment variables are set correctly -3. Clear next.js cache: -Code example: -rm -rf .next -Static Export Issues -<strong>Problem</strong>: Static export fails with dynamic routes -<strong>Solution</strong>: -1. Configure `next.config.js`: -Code example: -module.exports = { - output: 'export', - images: { - unoptimized: true - } -} -Translation Issues -AI Translation Not Working -<strong>Problem</strong>: Automatic translation fails -<strong>Solution</strong>: -1. Verify API keys are set correctly -2. Check translation configuration: -Code example: -{ - "translation": { - "auto_translate": true, - "provider": "anthropic", - "targetLanguages": ["es", "fr", "de"] - } -} -Content Issues -Content Not Updating -<strong>Problem</strong>: Changes to content files not reflecting -<strong>Solution</strong>: -Content changes are built on build time. If you are using the local development server, you need to restart the server after making changes. -1. Clear the cache: -Code example: -npm run clean -2. Restart the development server -3. Check file permissions -Deployment Issues -Vercel Deployment Failed -<strong>Problem</strong>: Deployment to Vercel fails -<strong>Solution</strong>: -1. Check build logs -2. Verify environment variables are set in Vercel dashboard -3. Ensure all dependencies are listed in package.json -Getting Help -If you're still experiencing issues: -1. Check our [GitHub Issues](https://github.com/Cloud-Code-AI/Akiradocs/issues) -2. Join our [Discord Community](https://discord.gg/zvYZukgeH2) -3. Contact [Support](mailto:saurav.panda@akiradocs.ai) -------------- -[Document: docs/installation/setup.json] -Title: Detailed Installation Guide -Complete guide to installing AkiraDocs in different environments. -Prerequisites -Ensure your system meets the [requirements](../getting-started/requirements.md) before proceeding. -Installation Methods -1. Local Development Setup -1. <strong>Create New Project</strong> -Code example: -npx create-akiradocs@latest my-docs-site -cd my-docs-site -2. <strong>Install Dependencies</strong> -Dependencies are automatically installed during project creation. If you need to reinstall: -Code example: -npm install -3. <strong>Create Environment File</strong> -The environment file is created automatically. You can modify it at `.env.local` -4. <strong>Start Development Server</strong> -Code example: -npm run dev -5. <strong>Update AkiraDocs</strong> -To update an existing installation to the latest version: -Code example: -npx create-akiradocs@latest update -3. Cloud Platform Deployment -Vercel -1. Fork the repository -2. Connect to Vercel -3. Configure environment variables -4. Deploy -Other Platforms -AWS Amplify (Coming Soon) -Netlify (Coming Soon) -Digital Ocean (Coming Soon) -Custom server (Coming Soon) -Post-Installation Steps -1. <strong>Verify Installation</strong> -Code example: -npm run build -npm run start -2. <strong>Configure Git Integration</strong> -Code example: -git remote add origin your-repository-url -3. <strong>Setup Content Directory</strong> -Code example: -mkdir -p docs/_contents/en -Environment-Specific Configurations -Development -Code example: -NODE_ENV=development -DEBUG=true -Production -Code example: -NODE_ENV=production -DEBUG=false -Testing -Code example: -NODE_ENV=test -TEST_MODE=true -------------- -[Document: docs/installation/configuration.json] -Title: Configuration Guide -Complete guide to configuring your AkiraDocs installation. -Core Configuration -Site Configuration -Edit `akiradocs.config.json`: -Code example: -{ - "url": "https://docs.akiradocs.com", - "site": { - "title": "Your Docs", - "description": "Your documentation description" - }, - "branding": { - "logo": { - "path": "/your_logo.svg", - "width": 120, - "height": 30, - "show": true - }, - "favicon": { - "path": "/favicon.png", - "show": true - } - } -} -Navigation Setup -Code example: -{ - "navigation": { - "header": { - "items": [ - { "label": "Docs", "href": "/docs", "icon": "/docs.svg" }, - { "label": "API", "href": "/api", "icon": "/api.svg" } - ] - } - } -} -Internationalization -Language Configuration -Code example: -{ - "localization": { - "defaultLocale": "en", - "fallbackLocale": "en", - "locales": [ - { - "code": "en", - "name": "English", - "flag": "🇺🇸" - }, - { - "code": "es", - "name": "Español", - "flag": "🇪🇸" - }, - { - "code": "fr", - "name": "Français", - "flag": "🇫🇷" - }, - { - "code": "de", - "name": "Deutsch", - "flag": "🇩🇪" - } - ] - }, - "translation": { - "auto_translate": true, - "provider": "anthropic", - "model": "claude-3-sonnet-20240229", - "targetLanguages": ["es", "fr", "de"], - "excludedPaths": ["_meta.json"] - }, -} -------------- [Document: docs/guides/analytics.json] Title: Analytics Integration Learn how to add analytics tracking to your documentation @@ -523,428 +115,14 @@ Code example: } This provides a complete analytics integration that's easy for users to set up and extend as needed. ------------- -[Document: docs/getting-started/requirements.json] -Title: System Requirements -Before installing AkiraDocs, ensure your environment meets the following requirements. -Minimum Requirements -Node.js -Version: 16.x or higher -Recommended: Latest LTS version -System Memory -Minimum: 2GB RAM -Recommended: 4GB RAM or more -Storage -Recommended: 1GB free space -Software Dependencies -Required -Git (latest version recommended) -npm or yarn package manager -Modern web browser (Chrome, Firefox, Safari, Edge) -Optional -Docker (for containerized deployment) -PostgreSQL (for enterprise features) -Development Environment -Supported Operating Systems -macOS (10.15 or later) -Windows 10/11 -Linux (Ubuntu 20.04 or later recommended) -IDE/Editor Support -VS Code (coming soon) -WebStorm (coming soon) -Any text editor with Markdown support -------------- [Document: docs/getting-started/quickstart.json] Title: Quickstart Guide -Get up and running with AkiraDocs in minutes. -Quick Deploy -Option 1: Deploy with Vercel -The fastest way to get started is using Vercel: -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FCloud-Code-AI%2Fakiradocs-template) -Option 2: Using CLI -Create a new project using our CLI: -Code example: -npx create-akiradocs@latest my-docs -Basic Setup Steps -1. <strong>Clone the Repository</strong> (if not using Quick Deploy) +Follow these steps to start using Akira Docs for your documentation needs. Code example: +bash git clone https://github.com/your-org/akira-docs-template cd akira-docs-template -2. <strong>Install Dependencies</strong> -Code example: -npm install -# or -yarn install -3. <strong>Start Development Server</strong> -Code example: -npm run dev -# or -yarn dev -4. Open `http://localhost:3000` in your browser -Initial Configuration -1. <strong>Update Site Configuration</strong> -Edit `akiradocs.config.json`: -Code example: -{ - "site": { - "title": "Your Docs", - "description": "Your documentation description" - } -} -2. <strong>Configure Translation</strong> (Optional) -Code example: -{ - "translation": { - "auto_translate": true, - "provider": "anthropic", - "targetLanguages": ["es", "fr", "de"] - } -} -------------- -[Document: docs/getting-started/features.json] -Title: AkiraDocs Features -A comprehensive overview of AkiraDocs' core features and capabilities. -Content Creation & Management -<strong>Notion-like Editor</strong>: Intuitive block-based interface with real-time preview -<strong>Markdown Support</strong>: Native Markdown and MDX compatibility -<strong>Custom Components</strong>: Create and reuse your own content blocks -Internationalization & Translation -<strong>Multi-Language Support</strong>: Maintain documentation in multiple languages -<strong>AI-Powered Translation</strong>: Automated, context-aware content translation -<strong>Translation Management</strong>: Built-in tools for managing localized content -Search & Discovery -<strong>AI-Powered Search</strong>: Natural language question answering with context awareness -<strong>SEO Optimization</strong>: Automated SEO tools and optimizations -<strong>Smart Indexing</strong>: Real-time search index updates -Build & Performance -<strong>Static Generation</strong>: Optimized build process with asset optimization -<strong>Developer Experience</strong>: Fast refresh and comprehensive debugging tools -<strong>Performance Focus</strong>: Built-in best practices for speed and efficiency -Enterprise Features (Coming Soon) -<strong>Security & Compliance</strong>: SSO, RBAC, and audit logging -<strong>Analytics & Insights</strong>: Usage tracking and documentation metrics -<strong>Team Collaboration</strong>: Enterprise-grade collaboration tools -Migration Support (Coming Soon) -Code example: -# Supported platforms for easy migration -✓ Nextra -✓ GitBook -✓ Docusaurus -✓ ReadTheDocs -------------- -[Document: docs/editor/overview.json] -Title: Editor Overview -AkiraDocs features a modern, Notion-like editor that combines the simplicity of block-based editing with the power of Markdown. -Editor Interface -Main Components -<strong>Toolbar</strong>: Quick access to formatting options and block types -<strong>Content Area</strong>: Block-based editing space -<strong>Sidebar</strong>: Navigation and document structure -<strong>Command Palette</strong>: Quick commands (Ctrl/Cmd + P) -Block Structure -Each content element is a block that can be: -Dragged and dropped to reorganize -Converted between different types -Duplicated or deleted -Nested within other blocks -Getting Started -Creating Content -1. Click the '+' button or press '/' to add a new block -2. Choose block type from the popup menu -3. Start typing or add content -Basic Operations -Code example: -/ → Open block menu -⌘/Ctrl + P → Command palette -⌘/Ctrl + / → Show keyboard shortcuts -↑↓ → Navigate between blocks -Block Types -Text Blocks -Paragraphs -Headings (H1-H6) -Lists (Bulleted, Numbered) -Quotes -Callouts -Rich Media -Images -Videos -Embeds -Files -Code blocks -Special Blocks -Tables (Coming Soon) -Dividers -Custom components (Coming Soon) -------------- -[Document: docs/editor/features.json] -Title: Editor Features -Detailed overview of AkiraDocs editor capabilities and features. -Block System -Text Formatting -<strong>Basic Formatting</strong> -Bold, italic, underline -Strikethrough -Highlight -Code inline -<strong>Advanced Formatting</strong> -Custom colors -Multiple fonts -Text alignment -Indentation -Content Blocks -Rich Text -Code example: -# Heading 1 -## Heading 2 -> Blockquote -- Bullet list -1. Numbered list -Code Blocks -Code example: -// Syntax highlighting -console.log('Hello World'); -Media Blocks -Image upload and embedding -Video embedding -File attachments -Interactive embeds -AI Features -Content Enhancement -Grammar and style suggestions -Content optimization -SEO recommendations -Translation assistance -Smart Formatting -Auto-formatting -Smart lists -Table formatting -Code block language detection -Collaboration Features -Version Control -Git integration -Change history -Rollback capabilities -------------- -[Document: docs/contributing/how-to-contribute.json] -Title: Contributing to AkiraDocs -Guide to contributing to the AkiraDocs open-source project. -Getting Started -Setup Development Environment -Code example: -# Clone repository -git clone https://github.com/Cloud-Code-AI/akiradocs -cd akiradocs - -# Install dependencies npm install - -# Start development server npm run dev -Contribution Guidelines -Types of Contributions -Bug fixes -Feature additions -Documentation improvements -Translation help -Issue reporting -Pull Request Process -1. Fork the repository -2. Create feature branch -3. Make changes -4. Submit pull request -Commit Messages -Code example: -# Format -type(scope): description - -# Examples -feat(editor): add new block type -fix(translation): correct language detection -docs(api): update authentication guide -Development Guidelines -Code Style -Follow existing patterns -Use TypeScript -Add comments -Write tests -Testing -Code example: -# Run tests -npm run test - -# Check types -npm run type-check - -# Lint code -npm run lint -Documentation -Update Docs -1. Edit relevant files -2. Update examples -3. Check links -4. Verify formatting -Create Examples -Clear and concise -Well-documented -Tested -Maintainable -Getting Help -Join [Discord](https://discord.gg/zvYZukgeH2) -Check [Issues](https://github.com/Cloud-Code-AI/akiradocs/issues) -Read [Documentation](https://docs.akiradocs.com) -------------- -[Document: docs/contributing/code-of-conduct.json] -Title: Code of Conduct -Our Pledge -We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. -Our Standards -Examples of behavior that contributes to a positive environment: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes -* Focusing on what is best for the overall community -Examples of unacceptable behavior: -* The use of sexualized language or imagery, and sexual attention or advances -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting -Enforcement Responsibilities -Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. -Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement. All complaints will be reviewed and investigated promptly and fairly. -Attribution -This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. -------------- -[Document: docs/content-management/creating-pages.json] -Title: Creating and Organizing Pages -Learn how to create, structure, and organize your documentation pages in AkiraDocs. You can create markdown pages or just use the editor UI. Note in _contents folder, you will only see markdown content created by you. If you use Editor UI, the content will be saved in the compiled folder and will be automatically translated to other languages. -Page Structure -Basic Page Template -Code example: ---- -title: Your Page Title -description: Brief description of the page -author: Your Name -publishDate: 2024-11-26 -modifiedDate: 2024-11-26 -category: Category Name -keywords: - - keyword1 - - keyword2 ---- - -# Main Title - -Content starts here... -Directory Structure -Code example: -folder_name/ -├── _contents/ -│ ├── en/ -│ │ ├── getting-started/ -│ │ ├── guides/ -│ │ └── api/ -You can just create pages for default language (en) and AkiraDocs will automatically translate them to other languages. -Creating New Pages -Method 1: Using the UI -1. Click "New Page" in the sidebar -2. Start adding content -Method 2: Direct File Creation -1. Create a new `.md` file in the appropriate directory -2. Add required frontmatter -3. Write content using Markdown -4. Save and compile -Page Organization -Categories and Tags -Use consistent categories -Apply relevant tags -Organize by topic -Create logical hierarchies -Navigation Structure -This is automatically generated from the folder structure. You can customize it by editing the `_meta.json` file inside compiled folder. -Code example: -{ - "docs": { - "getting-started": { - "title": "Getting Started", - "items": { - "introduction": { - "title": "Introduction", - "path": "/docs/getting-started/introduction" - } - } - } - } -} -------------- -[Document: docs/api-reference/usage-guide.json] -Title: API Documentation Guide -Learn how to generate comprehensive API documentation using AkiraDocs. -Quick Start -Upload API Spec -1. Place your OpenAPI/Swagger spec in: -Code example: -_contents/{language_code}/api/apiSpec.json -2. AkiraDocs automatically generates documentation. -Example API Spec -Code example: -{ - "openapi": "3.0.0", - "info": { - "title": "Sample API", - "version": "1.0.0" - }, - "paths": { - "/users": { - "get": { - "summary": "Get users", - "responses": { - "200": { - "description": "Success" - } - } - } - } - } -} -Generated Documentation -Automatic Features -Interactive API explorer -Code samples in multiple languages -Request/response examples -Authentication documentation -Example Output -Code example: -// Example: Get Users -const response = await fetch('https://api.example.com/users', { - method: 'GET', - headers: { - 'Authorization': 'Bearer YOUR_TOKEN' - } -}); - -const users = await response.json(); -Customization -Theme Options -Code example: -{ - "api": { - "docs": { - "theme": "dark", - "syntaxHighlight": true, - "showExamples": true - } - } -} -Language Selection -Code example: -{ - "api": { - "examples": { - "languages": ["javascript", "python", "curl"] - } - } -} +Warning: Make sure you have Node.js 16 or higher installed on your system. ------------- \ No newline at end of file diff --git a/docs/public/sitemap.xml b/docs/public/sitemap.xml index d0f5e6d..14340cc 100644 --- a/docs/public/sitemap.xml +++ b/docs/public/sitemap.xml @@ -9,78 +9,10 @@ <loc>https://docs.akiradocs.com/fr/docs/_meta</loc> </url> - <url> - <loc>https://docs.akiradocs.com/fr/docs/seo-and-performance/sitemap-generation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/seo-and-performance/robot-txt</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/internationalization/setup</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/internationalization/managing-translation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/internationalization/ai-translation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/installation/troubleshooting</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/installation/setup</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/installation/configuration</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/guides/analytics</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/getting-started/requirements</loc> - </url> - <url> <loc>https://docs.akiradocs.com/fr/docs/getting-started/quickstart</loc> </url> - <url> - <loc>https://docs.akiradocs.com/fr/docs/getting-started/features</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/editor/overview</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/editor/features</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/contributing/how-to-contribute</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/contributing/code-of-conduct</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/content-management/creating-pages</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/fr/docs/api-reference/usage-guide</loc> - </url> - <url> <loc>https://docs.akiradocs.com/fr/articles/welcome</loc> </url> @@ -109,78 +41,10 @@ <loc>https://docs.akiradocs.com/es/docs/_meta</loc> </url> - <url> - <loc>https://docs.akiradocs.com/es/docs/seo-and-performance/sitemap-generation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/seo-and-performance/robot-txt</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/internationalization/setup</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/internationalization/managing-translation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/internationalization/ai-translation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/installation/troubleshooting</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/installation/setup</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/installation/configuration</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/guides/analytics</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/getting-started/requirements</loc> - </url> - <url> <loc>https://docs.akiradocs.com/es/docs/getting-started/quickstart</loc> </url> - <url> - <loc>https://docs.akiradocs.com/es/docs/getting-started/features</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/editor/overview</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/editor/features</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/contributing/how-to-contribute</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/contributing/code-of-conduct</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/content-management/creating-pages</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/es/docs/api-reference/usage-guide</loc> - </url> - <url> <loc>https://docs.akiradocs.com/es/articles/welcome</loc> </url> @@ -209,114 +73,14 @@ <loc>https://docs.akiradocs.com/en/docs/_meta</loc> </url> - <url> - <loc>https://docs.akiradocs.com/en/docs/seo-and-performance/sitemap-generation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/seo-and-performance/robot-txt</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/seo-and-performance/_meta</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/internationalization/setup</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/internationalization/managing-translation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/internationalization/ai-translation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/internationalization/_meta</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/installation/troubleshooting</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/installation/setup</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/installation/configuration</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/installation/_meta</loc> - </url> - <url> <loc>https://docs.akiradocs.com/en/docs/guides/analytics</loc> </url> - <url> - <loc>https://docs.akiradocs.com/en/docs/guides/_meta</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/getting-started/requirements</loc> - </url> - <url> <loc>https://docs.akiradocs.com/en/docs/getting-started/quickstart</loc> </url> - <url> - <loc>https://docs.akiradocs.com/en/docs/getting-started/features</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/getting-started/_meta</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/editor/overview</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/editor/features</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/editor/_meta</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/contributing/how-to-contribute</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/contributing/code-of-conduct</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/contributing/_meta</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/content-management/creating-pages</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/content-management/_meta</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/api-reference/usage-guide</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/en/docs/api-reference/_meta</loc> - </url> - <url> <loc>https://docs.akiradocs.com/en/articles/welcome</loc> </url> @@ -345,78 +109,10 @@ <loc>https://docs.akiradocs.com/de/docs/_meta</loc> </url> - <url> - <loc>https://docs.akiradocs.com/de/docs/seo-and-performance/sitemap-generation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/seo-and-performance/robot-txt</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/internationalization/setup</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/internationalization/managing-translation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/internationalization/ai-translation</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/installation/troubleshooting</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/installation/setup</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/installation/configuration</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/guides/analytics</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/getting-started/requirements</loc> - </url> - <url> <loc>https://docs.akiradocs.com/de/docs/getting-started/quickstart</loc> </url> - <url> - <loc>https://docs.akiradocs.com/de/docs/getting-started/features</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/editor/overview</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/editor/features</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/contributing/how-to-contribute</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/contributing/code-of-conduct</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/content-management/creating-pages</loc> - </url> - - <url> - <loc>https://docs.akiradocs.com/de/docs/api-reference/usage-guide</loc> - </url> - <url> <loc>https://docs.akiradocs.com/de/articles/welcome</loc> </url> diff --git a/docs/src/app/aiSearch/page.tsx b/docs/src/app/aiSearch/page.tsx index 1e8ebde..a620cdf 100644 --- a/docs/src/app/aiSearch/page.tsx +++ b/docs/src/app/aiSearch/page.tsx @@ -69,11 +69,9 @@ export default function Home() { e.preventDefault() setIsLoading(true) setError(null) - setSources([]) // Reset sources + setSources([]) try { - const startEngineTime = performance.now(); - const contextResponse = await fetch('/context/en_docs.txt'); if (!contextResponse.ok) { throw new Error(`Failed to fetch context: ${contextResponse.status}`); @@ -81,67 +79,64 @@ export default function Home() { const contextData = await contextResponse.text(); const docsContext = contextData; - // Initialize MLC Engine const engine = await CreateMLCEngine( "Llama-3.2-1B-Instruct-q4f16_1-MLC", - { - initProgressCallback: (progress: any) => console.log(progress) + { initProgressCallback: (progress: any) => console.log(progress) }, { context_window_size: 100000, } ); - - const engineLoadTime = performance.now() - startEngineTime; - console.log(`Engine initialization took: ${engineLoadTime.toFixed(2)}ms`); - // Prepare messages for the chat with context const messages = [ { - role: "system", - content: `You are a technical documentation assistant specialized in providing accurate, concise answers based on the official documentation. - Your responses should be: - 1. Direct and to the point - 2. Based strictly on the provided documentation context - 3. Include relevant code examples when available - 4. Written in a technical but clear style - - Documentation context: ${docsContext}` + role: "system", + content: `You are a technical documentation assistant specialized in providing accurate, concise answers based on the official documentation. + Your responses should be: + 1. Direct and to the point + 2. Based strictly on the provided documentation context + 3. Include relevant code examples when available + 4. Written in a technical but clear style + + Documentation context: ${docsContext}` }, { - role: "user", - content: `Answer the following question using only the provided documentation context. - Question: ${query} - Requirements for your response: - 1. If the answer isn't clearly supported by the documentation and you cant find relevant information in the documentation, say \"I don't have enough information to answer this question accurately.\" - 2. Strictly adhere to the documentation context; do not make assumptions or provide additional commentary. - 3. Include short code snippets if relevant. - 4. Only answer questions related to the Documentation Context. - 5. Be concise and to the point. - After your answer, if you used any sources from the documentation, list them in this format: - ------------- - Sources: - - <title> (<path>) - Example: - Sources: - - Welcome to Akira Docs (articles/welcome.json)` + role: "user", + content: `Answer the following question using only the provided documentation context. + Question: ${query} + + Requirements for your response: + 1. If the answer isn't clearly supported by the documentation, say "I don't have enough information to answer this question accurately." + 2. Don't make assumptions or provide information not found in the documentation + 3. If relevant, include short code snippets to illustrate your answer. + 4. Only answer questions related to the Documentaion Context. + 5. Try to be concise and to the point. + + After your answer, if you used any sources from the documentation, list them in this format: + ------------- + Sources: + - <title> (<path>)` } - ]; - + ]; + + console.log("messages", messages) - console.log(messages) + const chunks = await engine.chat.completions.create({ + messages: messages as ChatCompletionMessageParam[], + stream: true, + stream_options: { include_usage: true } + }); - const startChatTime = performance.now(); - // Get response from MLC chatbot - const reply = await engine.chat.completions.create({ messages: messages as ChatCompletionMessageParam[] }); - const chatCompletionTime = performance.now() - startChatTime; - console.log(`Chat completion took: ${chatCompletionTime.toFixed(2)}ms`); + let aiContent = ""; + for await (const chunk of chunks) { + const newContent = chunk.choices[0]?.delta.content || ""; + aiContent += newContent; + // Update the response in real-time + setAiResponse(aiContent); + } - const aiContent = reply.choices[0].message.content || ''; - console.log("Response aiContent", aiContent) - // Extract sources and clean response + // Extract sources after the full response is received const { cleanResponse, sources } = extractSources(aiContent); - setAiResponse(cleanResponse); setSources(sources); diff --git a/docs/src/components/layout/TableOfContents.tsx b/docs/src/components/layout/TableOfContents.tsx index 30e470e..5386510 100644 --- a/docs/src/components/layout/TableOfContents.tsx +++ b/docs/src/components/layout/TableOfContents.tsx @@ -17,7 +17,7 @@ export function TableOfContents({ publishDate, modifiedDate, author, locale }: T const t = getTranslation(locale as keyof typeof locales); useEffect(() => { - const elements = Array.from(document.querySelectorAll('h2:not([data-toc-ignore]), h3:not([data-toc-ignore]), h4:not([data-toc-ignore])')); + const elements = Array.from(document.querySelectorAll('h2:not([data-toc-ignore]), h3:not([data-toc-ignore]), h4:not([data-toc-ignore]), h5:not([data-toc-ignore])')); setHeadings(elements as HTMLHeadingElement[]); const observer = new IntersectionObserver( @@ -106,19 +106,35 @@ export function TableOfContents({ publishDate, modifiedDate, author, locale }: T <ul className="space-y-2"> {headings.map((heading) => { - const level = parseInt(heading.tagName[1]) - 2; + const level = parseInt(heading.tagName[1]) - 1; + const indentClass = { + 0: '', + 1: 'ml-3', // h2 + 2: 'ml-6', // h3 + 3: 'ml-9', // h4 + 4: 'ml-12', // h5 + 5: 'ml-15', // h6 + }[level] || ''; + + console.log(heading.textContent, level, indentClass); return ( <li key={heading.id}> <a href={`#${heading.id}`} onClick={(e) => handleClick(e, heading.id)} className={` - text-sm block px-3 py-2 transition-colors duration-200 rounded-md - ${level > 0 ? 'pl-' + (level * 4 + 3) : ''} + text-sm block px-3 py-2 rounded-md + ${indentClass} + transition-all duration-200 ease-in-out + relative + before:absolute before:left-0 before:top-1/2 before:-translate-y-1/2 + before:h-4 before:w-0.5 before:bg-primary before:opacity-0 + before:transition-all before:duration-200 + hover:before:opacity-100 ${ activeId === heading.id - ? 'text-primary font-medium bg-primary/5' - : 'text-muted-foreground hover:text-foreground hover:bg-muted/40' + ? 'text-primary font-medium bg-primary/5 before:opacity-100' + : 'text-muted-foreground hover:text-foreground hover:bg-muted/40 hover:translate-x-1' } `} > diff --git a/packages/create-app/package.json b/packages/create-app/package.json index 60e9605..caf1ad8 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,6 +1,6 @@ { "name": "create-akiradocs", - "version": "1.0.45", + "version": "1.0.46", "description": "Create Akira Docs documentation sites with one command", "main": "./dist/index.js", "type": "module",