Skip to content

Commit 68d711e

Browse files
committed
feat(docs): update documentation and configuration for vitepress and chatluna api
- Reformat social links in `.vitepress/config.ts` for readability - Remove deprecated CSS preprocessor options and adjust code transformers - Add explicit language support for syntax highlighting - Update import statements in theme files to use double quotes - Integrate TwoslashFloatingVue for enhanced code display - Modify markdown documents to change alert types from TIP to IMPORTANT - Revise development guides with updated plugin creation instructions - Adjust frontmatter and component registrations in docs - Update dependencies including koishi, chatluna, and vitepress versions
1 parent 5da1539 commit 68d711e

File tree

12 files changed

+2532
-831
lines changed

12 files changed

+2532
-831
lines changed

docs/.vitepress/config.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export default defineConfig({
4646
},
4747

4848
socialLinks: [
49-
{ icon: "github", link: "https://github.com/ChatLunaLab/chatluna" },
49+
{
50+
icon: "github",
51+
link: "https://github.com/ChatLunaLab/chatluna",
52+
},
5053
],
5154
footer: {
5255
message: "在 CC-BY-SA-4.0 许可下发布",
@@ -106,19 +109,14 @@ export default defineConfig({
106109

107110
md.use(InlineLinkPreviewElementTransform);
108111
},
109-
codeTransformers: [transformerTwoslash() as any],
110112
image: {
111113
lazyLoading: true,
112114
},
115+
codeTransformers: [transformerTwoslash()],
116+
// Explicitly load these languages for types hightlighting
117+
languages: ["js", "jsx", "ts", "tsx"],
113118
},
114119
vite: {
115-
css: {
116-
preprocessorOptions: {
117-
scss: {
118-
api: "modern-compiler", // or "modern"
119-
},
120-
},
121-
},
122120
ssr: {
123121
noExternal: ["@nolebase/*", "vue-demi", "@unlazy/*"],
124122
},

docs/.vitepress/theme/index.ts

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,72 @@
1-
import { h } from 'vue';
2-
import DefaultTheme from 'vitepress/theme';
3-
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client';
4-
import './styles/custom.css';
5-
import ChatPanel from './components/ChatPanel.vue';
6-
import ChatMessage from './components/ChatMessage.vue';
1+
import { h } from "vue";
2+
import DefaultTheme from "vitepress/theme";
3+
import { enhanceAppWithTabs } from "vitepress-plugin-tabs/client";
4+
import "./styles/custom.css";
5+
import ChatPanel from "./components/ChatPanel.vue";
6+
import ChatMessage from "./components/ChatMessage.vue";
77

8-
import { Theme } from 'vitepress';
8+
import { Theme } from "vitepress";
99

1010
import {
1111
InjectionKey as NolebaseEnhancedReadabilitiesInjectionKey,
1212
LayoutMode as NolebaseEnhancedReadabilitiesLayoutMode,
1313
NolebaseEnhancedReadabilitiesMenu,
1414
NolebaseEnhancedReadabilitiesScreenMenu,
15-
} from '@nolebase/vitepress-plugin-enhanced-readabilities/client';
15+
} from "@nolebase/vitepress-plugin-enhanced-readabilities/client";
1616

17-
import { NolebaseInlineLinkPreviewPlugin } from '@nolebase/vitepress-plugin-inline-link-preview/client';
17+
import { NolebaseInlineLinkPreviewPlugin } from "@nolebase/vitepress-plugin-inline-link-preview/client";
1818

19-
import { NolebaseHighlightTargetedHeading } from '@nolebase/vitepress-plugin-highlight-targeted-heading/client';
19+
import { NolebaseHighlightTargetedHeading } from "@nolebase/vitepress-plugin-highlight-targeted-heading/client";
2020

2121
import {
2222
InjectionKey,
2323
NolebaseGitChangelogPlugin,
24-
} from '@nolebase/vitepress-plugin-git-changelog/client';
24+
} from "@nolebase/vitepress-plugin-git-changelog/client";
2525

26-
import { NolebasePagePropertiesPlugin } from '@nolebase/vitepress-plugin-page-properties/client';
26+
import { NolebasePagePropertiesPlugin } from "@nolebase/vitepress-plugin-page-properties/client";
2727

28-
import { NolebaseUnlazyImg } from '@nolebase/vitepress-plugin-thumbnail-hash/client';
28+
import { NolebaseUnlazyImg } from "@nolebase/vitepress-plugin-thumbnail-hash/client";
2929

30-
import AppContainer from './components/AppContainer.vue';
30+
import AppContainer from "./components/AppContainer.vue";
31+
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
3132

32-
import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css';
33-
import '@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css';
34-
import '@nolebase/vitepress-plugin-inline-link-preview/client/style.css';
35-
import '@nolebase/vitepress-plugin-git-changelog/client/style.css';
36-
import '@nolebase/vitepress-plugin-page-properties/client/style.css';
37-
import '@nolebase/vitepress-plugin-thumbnail-hash/client/style.css';
38-
import '@nolebase/vitepress-plugin-enhanced-mark/client/style.css';
33+
import "@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css";
34+
import "@nolebase/vitepress-plugin-highlight-targeted-heading/client/style.css";
35+
import "@nolebase/vitepress-plugin-inline-link-preview/client/style.css";
36+
import "@nolebase/vitepress-plugin-git-changelog/client/style.css";
37+
import "@nolebase/vitepress-plugin-page-properties/client/style.css";
38+
import "@nolebase/vitepress-plugin-thumbnail-hash/client/style.css";
39+
import "@nolebase/vitepress-plugin-enhanced-mark/client/style.css";
3940

40-
import 'virtual:uno.css'
41+
import "virtual:uno.css";
4142

42-
import './styles/main.css';
43-
import './styles/vars.css';
44-
import './styles/sponsor.css';
43+
import "./styles/main.css";
44+
import "./styles/vars.css";
45+
import "./styles/sponsor.css";
4546

46-
import '@shikijs/vitepress-twoslash/style.css';
47-
import Sponsors from './components/Sponsors.vue';
47+
import '@shikijs/vitepress-twoslash/style.css'
48+
import Sponsors from "./components/Sponsors.vue";
4849

49-
import('@nolebase/vitepress-plugin-inline-link-preview/client');
50+
import("@nolebase/vitepress-plugin-inline-link-preview/client");
5051

5152
export default {
5253
extends: DefaultTheme,
5354
Layout: () => {
5455
return h(DefaultTheme.Layout, null, {
5556
// https://vitepress.dev/guide/extending-default-theme#layout-slots
56-
'doc-top': () => [h(NolebaseHighlightTargetedHeading)],
57-
'nav-bar-content-after': () => [
57+
"doc-top": () => [h(NolebaseHighlightTargetedHeading)],
58+
"nav-bar-content-after": () => [
5859
h(NolebaseEnhancedReadabilitiesMenu),
5960
],
60-
'nav-screen-content-after': () => [
61+
"nav-screen-content-after": () => [
6162
h(NolebaseEnhancedReadabilitiesScreenMenu),
6263
],
6364
});
6465
},
6566
enhanceApp({ app }) {
66-
app.component('chat-panel', ChatPanel);
67-
app.component('chat-message', ChatMessage);
68-
app.component('sponsors', Sponsors);
67+
app.component("chat-panel", ChatPanel);
68+
app.component("chat-message", ChatMessage);
69+
app.component("sponsors", Sponsors);
6970

7071
enhanceAppWithTabs(app);
7172

@@ -76,8 +77,8 @@ export default {
7677
* https://github.com/vuejs/vitepress/issues/1918
7778
*/
7879

79-
app.component('AppContainer', AppContainer);
80-
app.component('NolebaseUnlazyImg', NolebaseUnlazyImg);
80+
app.component("AppContainer", AppContainer);
81+
app.component("NolebaseUnlazyImg", NolebaseUnlazyImg);
8182

8283
app.provide(NolebaseEnhancedReadabilitiesInjectionKey, {
8384
layoutSwitch: {
@@ -87,7 +88,7 @@ export default {
8788
spotlight: {
8889
disableHelp: true,
8990
defaultToggle: true,
90-
hoverBlockColor: 'rgb(240 197 52 / 7%)',
91+
hoverBlockColor: "rgb(240 197 52 / 7%)",
9192
},
9293
});
9394

@@ -98,30 +99,31 @@ export default {
9899

99100
app.use(NolebaseInlineLinkPreviewPlugin);
100101
app.use(NolebaseGitChangelogPlugin);
102+
app.use(TwoslashFloatingVue);
101103
app.use(
102104
NolebasePagePropertiesPlugin<{
103105
progress: number;
104106
}>(),
105107
{
106108
properties: {
107-
'zh-CN': [
109+
"zh-CN": [
108110
{
109-
key: 'wordCount',
110-
type: 'dynamic',
111-
title: '字数',
111+
key: "wordCount",
112+
type: "dynamic",
113+
title: "字数",
112114
options: {
113-
type: 'wordsCount',
115+
type: "wordsCount",
114116
},
115117
},
116118
{
117-
key: 'readingTime',
118-
type: 'dynamic',
119-
title: '阅读时间',
119+
key: "readingTime",
120+
type: "dynamic",
121+
title: "阅读时间",
120122
options: {
121-
type: 'readingTime',
122-
dateFnsLocaleName: 'zhCN',
123+
type: "readingTime",
124+
dateFnsLocaleName: "zhCN",
123125
},
124-
}
126+
},
125127
],
126128
},
127129
}

docs/development/api-reference/chatluna-utils/request.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const ua = randomUA()
3535

3636
建立一个 `fetch` 请求。
3737

38-
> [!TIP] 注意
38+
> [!IMPORTANT] 注意
3939
> 如果 `proxy` 参数传递为 'null'(注意是纯文本的 `null`,不是 `null` 变量),则不会使用代理。
4040
4141
### ws(url, init, proxy)
@@ -47,7 +47,7 @@ const ua = randomUA()
4747

4848
建立一个 `ws` 请求。
4949

50-
> [!TIP] 注意
50+
> [!IMPORTANT] 注意
5151
> 如果 `proxy` 参数传递为 'null'(注意是纯文本的 `null`,不是 `null` 变量),则不会使用代理。
5252
5353
### randomUA()

docs/development/api-reference/chatluna-utils/sse.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ for await (const event of sseIterable(response)) {
5050

5151
将 SSE 响应转换为原始数据的异步迭代器。当 `cacheCount` 大于 0 时,将累积指定数量的原始数据后一次性产出。
5252

53-
> [!TIP] 注意
53+
> [!IMPORTANT] 注意
5454
> `rawSeeAsIterable` 返回的是未经解析的原始 SSE 数据流,而 `sseIterable` 返回的是经过解析的事件数据。

docs/development/call-core-services/vector-database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ChatLuna 提供了向量数据库的集成能力,用于高效存储和检索
44

55
向量数据库是 LLM 应用的核心基础设施之一,它通过存储文本的向量表示,实现了基于语义的相似度搜索,为 LLM 提供外部知识库和记忆能力。
66

7-
> [!TIP] 提示
7+
> [!IMPORTANT] 提示
88
> 创建向量数据库时还需要指定嵌入模型,请参考 [嵌入模型](/development/call-core-services/embedding-model)
99
1010
## 基于内存的向量数据库

docs/development/extend-chatluna-api.md

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,13 @@
22

33
另外一个常见的需求是扩展 ChatLuna 的能力。
44

5-
ChatLuna 支持插件聊天模式 (Plugin Chat Mode),允许其他插件定义 [Tool](https://js.langchain.com/docs/concepts/tools/),让模型可以调用这些 Tool 来完成一些任务。
6-
7-
## 添加依赖
8-
9-
首先,需要在你的 Koishi 插件的 `package.json` 文件中添加必要的依赖:
10-
11-
```json
12-
{
13-
"peerDependencies": {
14-
"koishi": "^4.18.0",
15-
"koishi-plugin-chatluna": "^1.0.0-beta.119"
16-
},
17-
"devDependencies": {
18-
"koishi-plugin-chatluna": "^1.0.0-beta.119"
19-
},
20-
"dependencies": {
21-
"@langchain/core": "^0.3.2"
22-
},
23-
"koishi": {
24-
"service": {
25-
"required": ["chatluna"]
26-
}
27-
}
28-
}
29-
```
5+
ChatLuna 支持 Agent 模式,允许其他插件定义 [工具](https://js.langchain.com/docs/concepts/tools/)
306

31-
运行 `npm install``yarn install` 安装依赖后,在插件的主入口文件中引入并声明 ChatLuna 服务:
7+
模型可以调用这些工具来完成各种任务。
328

33-
```typescript
34-
import type {} from "koishi-plugin-chatluna/services/chat";
35-
import { ChatLunaChatModel } from 'koishi-plugin-chatluna/llm-core/platform/model'
9+
## 创建插件
3610

37-
export const inject = ['chatluna']
38-
```
11+
阅读 [创建插件](./getting-started.md#创建插件) 以了解更多。
3912

4013
## 注册工具
4114

@@ -104,7 +77,7 @@ export class EchoTool extends Tool {
10477

10578
```
10679

107-
下面的代码注册了一个名为 `echo` 的 Tool。当聊天记录符合 `selector` 的匹配条件时,会调用 `createTool` 方法创建一个 `EchoTool` 实例。
80+
上面的代码注册了一个名为 `echo` 的 Tool。当聊天记录符合 `selector` 的匹配条件时,会调用 `createTool` 方法创建一个 `EchoTool` 实例。
10881

10982
更详细的工具注册方法,请参考 [模型工具](./development/connect-to-core-services/model-tool)
11083

0 commit comments

Comments
 (0)