惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
C
CXSECURITY Database RSS Feed - CXSecurity.com
NISL@THU
NISL@THU
S
Schneier on Security
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
Hacker News: Ask HN
Hacker News: Ask HN
T
Tenable Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google Online Security Blog
Google Online Security Blog
GbyAI
GbyAI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
Forbes - Security
Forbes - Security
博客园 - 叶小钗
量子位
I
Intezer
腾讯CDC
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
F
Fortinet All Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
Jina AI
Jina AI
Project Zero
Project Zero
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
Latest news
Latest news
Cyberwarzone
Cyberwarzone
Security Latest
Security Latest
Spread Privacy
Spread Privacy
M
MIT News - Artificial intelligence
F
Full Disclosure
P
Proofpoint News Feed
B
Blog
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
AWS News Blog
AWS News Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
The GitHub Blog
The GitHub Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
博客园 - 聂微东
小众软件
小众软件
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives

wuxinhua.com Blog | RSS Feed

写作者与不写作者:AI 时代的思考分水岭 - wuxinhua.com 一文搞懂 Prompt Engineering - wuxinhua.com #30 AI 颠覆我对传统创业团队的认知 - wuxinhua.com 前端面试系列 - 手写代码 - wuxinhua.com #29 微软与 OpenAI 合作内幕 - wuxinhua.com #28 离 30 岁越来越远 - wuxinhua.com Building a Blog Subscription and Pusher with AirCode and Resend - wuxinhua.com #27 创始人是公司灵魂的守护者 - wuxinhua.com 快速上手 Midjourney AI 做图 - wuxinhua.com Building your first Discord ChatGPT Bot - wuxinhua.com ChatGPT 机器人系列 - 用 JavaScript,五分钟将 Siri 接入 ChatGPT - wuxinhua.com ChatGPT 机器人系列 - 用 JavaScript 五分钟开发一个飞书 ChatGPT 机器人 - wuxinhua.com ChatGPT 机器人系列 - 用 JavaScript 开发企业微信 ChatGPT 聊天应用 - wuxinhua.com #26 SVB 硅谷银行为什么倒闭 - wuxinhua.com #25 人人都可以成为 AI 工程师 - wuxinhua.com #24 关注你身体的变化 - wuxinhua.com #23 Be positive - wuxinhua.com 前端面试系列 - 前端八股文 - wuxinhua.com #22 AI 在殖民,社交媒体在衰退 - wuxinhua.com #21 我了解到的新冠后遗症 - wuxinhua.com #20 关于死亡和告别 - wuxinhua.com #19 永远无法准备好 - wuxinhua.com macOS 前端开发环境配置 - wuxinhua.com 我的 Newsletter 321来信 - wuxinhua.com Node.js 包管理及 npm 依赖安装机制 - wuxinhua.com 知识的碎片(2021) - wuxinhua.com 放弃 newsfeed 拥抱 newsletter - wuxinhua.com 混迹于 Clubhouse 两周后的一些想法🤔 - wuxinhua.com 认识Docker - wuxinhua.com 知识的碎片(2020) - wuxinhua.com 初探 Web Components - wuxinhua.com Linux 命令行之 Crontab - wuxinhua.com 今年看的书📚(2019) - wuxinhua.com 适配 iOS 13 - wuxinhua.com React Native 新手常见问题及体验总结 - wuxinhua.com ES10(ECMAScript2019)特征预览 - wuxinhua.com Flexbox布局完全指南 - wuxinhua.com 今年看的书📚(2018) - wuxinhua.com 《从0到1 - 如何创造未来 》书评 - wuxinhua.com www背后的故事 - wuxinhua.com contenteditable 踩坑记 - wuxinhua.com Good Code vs Bad Code in Golang - wuxinhua.com 关于React的几道面试题 - wuxinhua.com SVG动画实践 - wuxinhua.com 今年看的书📚(2017) - wuxinhua.com 对比几种常见的排序算法 - wuxinhua.com React服务端渲染(SSR)初探 - wuxinhua.com 从面试题“输入URL...发生了什么”学到的(下) - wuxinhua.com 从面试题“输入URL...发生了什么?”学到的(上) - wuxinhua.com ES6(ECMAScript 6.0)新特征 - wuxinhua.com 对React-redux中connect方法的理解 - wuxinhua.com 我的 RSS 订阅列表 - wuxinhua.com 《空谷幽兰》书评 - wuxinhua.com 你可能不知道git rerere - wuxinhua.com webpack v2升级踩坑笔记 - wuxinhua.com
Add AI Chatbox to your VitePress document site - wuxinhua.com
2023-09-19 · via wuxinhua.com Blog | RSS Feed

This article will guide you how to quickly empower your VitePress documentation site with AI conversational capabilities using an open-source tool Documate. This will allow it to answer your users' questions based on the content of your documentation, supporting streaming outputs.

documate screenshot gif

The complete source code of the project can be viewed at https://github.com/AirCodeLabs/documate.

Integration Steps

If you want to create a brand-new VitePress project with AI conversational capabilities, use the command below:

1npm create documate@latest --template vitepress

After creation, jump directly to step 3 "Build, Upload, and Configure the Search Backend API".

To add AI conversational capabilities to an existing VitePress project, follow these steps:

1. Initialization

Run the following command in your VitePress project root directory to initialize:

1npx @documate/documate init --framework vue

documate init

This command will create a documate.json configuration file.

1{ 2 "root": ".", 3 "include": [ 4 "**/*.md" 5 ], 6 "backend": "" 7}

A documate:upload command will also be added, which is used to upload documents to create a knowledge base. I will explain its specific usage later.

1{ 2 "scripts": { 3 "docs:dev": "vitepress dev", 4 "docs:build": "vitepress build", 5 "docs:preview": "vitepress preview", 6 "documate:upload": "documate upload" 7 }, 8 "dependencies": { 9 "@documate/vue": "^0.2.3" 10 }, 11 "devDependencies": { 12 "@documate/documate": "^0.1.0" 13 } 14}

2. Add UI Entry to the Project

Add the following code to the file .vitepress/theme/index.js. If it doesn't exist, you need to create it manually. VitePress introduces how to customize your own theme in the Extending the Default Theme documentation.

1import { h } from 'vue' 2import DefaultTheme from 'vitepress/theme' 3 4// Load component and style 5import Documate from '@documate/vue' 6import '@documate/vue/dist/style.css' 7 8export default { 9 ...DefaultTheme, 10 // Add Documate UI to the slot 11 Layout: h(DefaultTheme.Layout, null, { 12 'nav-bar-content-before': () => h(Documate, { 13 endpoint: '', 14 }), 15 }), 16}

The above code will add an AI chat box UI to the navbar. After launching the service locally using npm run docs:dev, you can find the Ask AI button in the top left corner. If you don't see the Ask AI button, check to ensure all the above code has been added correctly and that you've imported the CSS style file from @documate/vue/dist/style.css.

dev

Now, you have successfully integrated the UI. Next, we'll add the interface capability for the chat box to answer questions.

Documate's backend code is used to upload document content to create a knowledge base and to receive user questions and return streaming answers.

Go to the backend folder on GitHub and click on 「Deploy to AirCode」 to quickly copy and deploy your own backend code.

Deploy to AirCode

If you are using AirCode (an online platform for writing and deploying Node.js applications) for the first time, you will be redirected to the login page. It is recommended to log in with GitHub for faster access.

login

After creating the app, set the OPENAI_API_KEY environment variable in the Environments tab to your OpenAI Key value. You can obtain the API Key from the OpenAI platform.

env OPENAI_API_KEY

Click the「Deploy」button on the top bar to deploy all functions online. Once deployed successfully, you will receive URLs to call each function.

Deploy

Here we will use the upload.js and ask.js functions, one for uploading document content and the other for answering questions.

4. Set Up the API Endpoint

In the AirCode Dashboard, select the deployed upload.js file, copy its URL, and add it to the backend field in documate.json.

1// documate.json 2{ 3 "root": ".", 4 "include": [ "**/*.md" ], 5 "backend": "替换为你的 upload.js 的 URL" 6}

API Endpoint

Similarly, in AirCode, select the deployed ask.js file, copy its URL, and modify the endpoint value in .vitepress/theme/index.js.

1// .vitepress/theme/index.js 2import { h } from 'vue' 3import DefaultTheme from 'vitepress/theme' 4import Documate from '@documate/vue' 5import '@documate/vue/dist/style.css' 6 7export default { 8 ...DefaultTheme, 9 Layout: h(DefaultTheme.Layout, null, { 10 'nav-bar-content-before': () => h(Documate, { 11 // Replace the URL with your own one 12 endpoint: '替换为你的 ask.js 的 URL', 13 }, 14 ), 15 }), 16}

5. Run the Project

Use the command below to upload the content to the backend and generate the documentation knowledge base:


documate:upload

Once the command completes, launch the project locally, click the Ask AI button in the top left corner, enter a question in the pop-up dialog box, and receive answers based on your documentation content.


screen shoot

For more usage and configuration methods, please refer to the Documate project on GitHub, Comments and discussions are welcome.

GitHub -> https://github.com/AirCodeLabs/documate.