ctod 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +251 -251
  3. package/dist/index.js +20 -20
  4. package/dist/index.js.map +7 -7
  5. package/esbuild.mjs +21 -21
  6. package/eslint.config.mjs +29 -29
  7. package/examples/anthropic.ts +101 -101
  8. package/examples/google.ts +97 -97
  9. package/examples/llama.cpp.ts +54 -54
  10. package/examples/openai.ts +97 -97
  11. package/examples/plugin.ts +115 -115
  12. package/examples/x.ts +97 -97
  13. package/lib/broker/chat.ts +435 -435
  14. package/lib/core/parser.ts +62 -62
  15. package/lib/core/plugin.ts +46 -46
  16. package/lib/core/translator.ts +116 -116
  17. package/lib/ctod.ts +71 -71
  18. package/lib/index.ts +21 -20
  19. package/lib/plugins/index.ts +38 -38
  20. package/lib/plugins/limiter.ts +103 -103
  21. package/lib/plugins/print-log.ts +35 -35
  22. package/lib/plugins/retry.ts +25 -25
  23. package/lib/plugins/role.ts +28 -28
  24. package/lib/service/anthropic/chat.ts +154 -154
  25. package/lib/service/anthropic/index.ts +70 -70
  26. package/lib/service/google/chat.ts +133 -133
  27. package/lib/service/google/index.ts +104 -104
  28. package/lib/service/llama3.cpp/completion.ts +314 -314
  29. package/lib/service/llama3.cpp/index.ts +57 -53
  30. package/lib/service/openai/chat.ts +243 -243
  31. package/lib/service/openai/images-generation.ts +64 -64
  32. package/lib/service/openai/index.ts +112 -112
  33. package/lib/service/openai/vision.ts +111 -111
  34. package/lib/service/x/chat.ts +216 -216
  35. package/lib/service/x/images-generation.ts +57 -57
  36. package/lib/service/x/index.ts +91 -91
  37. package/lib/templates.ts +71 -71
  38. package/lib/types.ts +4 -4
  39. package/lib/utils/chinese-conv.json +4114 -4114
  40. package/lib/utils/chinese-conv.ts +23 -13
  41. package/lib/utils/error.ts +14 -14
  42. package/lib/utils/validate.ts +64 -64
  43. package/package.json +65 -65
  44. package/tsconfig.json +26 -26
  45. package/types/examples/anthropic.d.ts +1 -1
  46. package/types/examples/basic.d.ts +1 -1
  47. package/types/examples/chat-demo.d.ts +2 -2
  48. package/types/examples/chat-for-llama.cpp-demo.d.ts +2 -2
  49. package/types/examples/chat-with-json-schema-demo.d.ts +2 -2
  50. package/types/examples/google.d.ts +1 -1
  51. package/types/examples/llama.cpp.d.ts +1 -1
  52. package/types/examples/openai.d.ts +1 -1
  53. package/types/examples/plugin-demo.d.ts +2 -2
  54. package/types/examples/plugin.d.ts +1 -1
  55. package/types/examples/stream-for-llama.cpp-demo.d.ts +2 -2
  56. package/types/examples/vision-demo.d.ts +2 -2
  57. package/types/examples/x.d.ts +1 -1
  58. package/types/lib/broker/chat.d.ts +150 -150
  59. package/types/lib/core/parser.d.ts +32 -32
  60. package/types/lib/core/plugin.d.ts +34 -34
  61. package/types/lib/core/translator.d.ts +67 -67
  62. package/types/lib/ctod.d.ts +32 -32
  63. package/types/lib/index.d.ts +18 -17
  64. package/types/lib/plugins/index.d.ts +47 -47
  65. package/types/lib/plugins/limiter.d.ts +36 -36
  66. package/types/lib/plugins/print-log.d.ts +5 -5
  67. package/types/lib/plugins/retry.d.ts +6 -6
  68. package/types/lib/plugins/role.d.ts +5 -5
  69. package/types/lib/service/anthropic/chat.d.ts +52 -52
  70. package/types/lib/service/anthropic/index.d.ts +25 -25
  71. package/types/lib/service/google/chat.d.ts +64 -64
  72. package/types/lib/service/google/index.d.ts +25 -25
  73. package/types/lib/service/llama3.cpp/completion.d.ts +60 -60
  74. package/types/lib/service/llama3.cpp/index.d.ts +20 -19
  75. package/types/lib/service/openai/chat.d.ts +110 -110
  76. package/types/lib/service/openai/completion.d.ts +59 -59
  77. package/types/lib/service/openai/images-generation.d.ts +35 -35
  78. package/types/lib/service/openai/index.d.ts +36 -36
  79. package/types/lib/service/openai/vision.d.ts +74 -74
  80. package/types/lib/service/x/chat.d.ts +100 -100
  81. package/types/lib/service/x/images-generation.d.ts +30 -30
  82. package/types/lib/service/x/index.d.ts +27 -27
  83. package/types/lib/templates.d.ts +20 -20
  84. package/types/lib/types.d.ts +1 -1
  85. package/types/lib/utils/chinese-conv.d.ts +10 -2
  86. package/types/lib/utils/error.d.ts +11 -11
  87. package/types/lib/utils/validate.d.ts +16 -16
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Metal Sheep
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Metal Sheep
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,251 +1,251 @@
1
- <br>
2
- <p align="center"><img style="max-width: 300px" src="./logo.png"></p>
3
- <h1 align="center">CtoD</h1>
4
- <h3 align="center">Chat To Data</h3>
5
-
6
- <h6 align="center">
7
- <a href="https://www.npmjs.com/package/ctod">
8
- <img src="https://img.shields.io/npm/v/ctod.svg">
9
- </a>
10
- <a href="https://github.com/KHC-ZhiHao/ctod">
11
- <img src="https://img.shields.io/github/stars/KHC-ZhiHao/ctod.svg?style=social">
12
- </a>
13
- <br>
14
- </h6>
15
-
16
- <br>
17
-
18
- ## 摘要
19
-
20
- 現在我們頻繁的有透過口語化的方式交付任務 LLM 處理並要求回應 JSON 的需求,透過 CtoD 你可以讓這個模式有架構化的進行。
21
-
22
- 在對話過程中,CtoD 採用 [yup](https://github.com/jquense/yup) 來驗證請求與回復資料是否符合預期,以確保一致性,只要保持這個互動模式,就可以利用在 API 串接或是自動化系統上。
23
-
24
- 我們還附帶支援 `OpenAI`, `Google`, `Llama3` 等相關 LLM 服務。
25
-
26
- ## 安裝
27
-
28
- npm:
29
-
30
- ```bash
31
- npm install ctod
32
- ```
33
-
34
- yarn:
35
-
36
- ```bash
37
- yarn add ctod
38
- ```
39
-
40
- ## 快速開始
41
-
42
- 這個例子示範如何將藥物索引與客戶需求傳遞給聊天機器人,並返回最適合的結果,開發人員可以利用索引結果去資料庫搜尋最適合的藥物給消費者:
43
-
44
- ```ts
45
- import { CtoD, OpenAICtodService } from 'ctod'
46
-
47
- const ctod = new CtoD({
48
- request: OpenAICtodService.createChatRequestWithJsonSchema({
49
- apiKey: 'YOUR_API_KEY',
50
- config: {
51
- model: 'gpt-4o'
52
- }
53
- })
54
- })
55
-
56
- const brokerBuilder = ctod.createBrokerBuilder<{
57
- indexes: string[]
58
- question: string
59
- }>({
60
- install: ({ attach }) => {
61
- attach('start', async({ setPreMessages }) => {
62
- setPreMessages([
63
- {
64
- role: 'system',
65
- content: '你現在是一位擅長分類索引的藥師'
66
- }
67
- ])
68
- })
69
- }
70
- })
71
-
72
- const broker = brokerBuilder.create(async({ yup, data, setMessages }) => {
73
- const { indexes, question } = data
74
- setMessages([
75
- {
76
- role: 'user',
77
- content: [
78
- '我有以下索引',
79
- `${JSON.stringify(indexes)}`,
80
- `請幫我解析"${question}"可能是哪個索引`,
81
- '且相關性由高到低排序並給予分數,分數由 0 ~ 1'
82
- ]
83
- }
84
- ])
85
- const item = yup.object({
86
- name: yup.string().required().meta({
87
- jsonSchema: {
88
- description: '索引名稱'
89
- }
90
- }),
91
- score: yup.number().required().meta({
92
- jsonSchema: {
93
- description: '評比分數'
94
- }
95
- })
96
- }).required()
97
- return {
98
- indexes: yup.array(item).required().meta({
99
- jsonSchema: {
100
- description: '由高到低排序的索引'
101
- }
102
- })
103
- }
104
- })
105
-
106
- broker.request({
107
- indexes: ['胃痛', '腰痛', '頭痛', '喉嚨痛', '四肢疼痛'],
108
- question: '喝咖啡,吃甜食,胃食道逆流'
109
- }).then(e => {
110
- console.log('輸出結果:', e.indexes)
111
- /*
112
- [
113
- {
114
- name: '胃痛',
115
- score: 1
116
- },
117
- {
118
- name: '喉嚨痛',
119
- score: 0.7
120
- },
121
- ...
122
- ]
123
- */
124
- }).catch(error => {
125
- console.error('Error:', error)
126
- })
127
-
128
- ```
129
-
130
- ## Plugin
131
-
132
- 雖然 Broker 本身已經能夠處理大部分的事務,但透過 Plugin 可以協助改善複雜的流程,幫助專案工程化。
133
-
134
- 每次發送請求時,Broker 會觸發一系列的生命週期,你可以從[原始碼](./lib/broker/openai.ts)中了解每個生命週期的參數與行為,並對其行為進行加工。
135
-
136
- 現在,假設我們想要設計一個插件,它會在每次對話結束時將訊息備份到伺服器上:
137
-
138
- ```ts
139
- import axios from 'axios'
140
- import { CtoDPlugin } from 'ctod'
141
- const backupPlugin = new CtoDPlugin({
142
- name: 'backup-plugin',
143
- // 定義參數為 sendUrl
144
- params: yup => {
145
- return {
146
- sendUrl: yup.string().required()
147
- }
148
- },
149
- // 現階段你可以在執行過程中接收到資訊,資訊結構由這裡定義。
150
- receiveData: yup => {
151
- return {
152
- character: yup.string().required()
153
- }
154
- },
155
- onInstall({ params, attach, receive }) {
156
- const store = new Map()
157
- // 假設我們有更多的自訂義資訊需要被傳遞進來,可以在 start 階段透過 plugins[key].send({ ... }) 傳遞
158
- // 可以從 Applications 分類中的 請機器人角色扮演 觀看案例
159
- receive(({ id, context }) => {
160
- store.get(id).context = context
161
- })
162
- // 第一次對話的時候初始化資料
163
- attach('start', async({ id }) => {
164
- store.set(id, {
165
- messages: [],
166
- context: null
167
- })
168
- })
169
- // 每次對話完畢後把對話存入狀態
170
- attach('talkAfter', async({ id, lastUserMessage }) => {
171
- store.get(id).messages.push(lastUserMessage)
172
- })
173
- // 結束對話後備份資料
174
- attach('done', async({ id }) => {
175
- await axios.post(params.sendUrl, store.get(id))
176
- store.delete(id)
177
- })
178
- }
179
- })
180
-
181
- const ctod = new CtoD({
182
- // ...
183
- plugins: () => {
184
- return {
185
- backup: backupPlugin.use({
186
- sendUrl: 'https://api/backup'
187
- })
188
- }
189
- }
190
- })
191
- ```
192
-
193
- ## Examples
194
-
195
- [基礎用法 - 藥物查詢功能](./examples/openai.ts)
196
-
197
- [進階用法 - 請 AI COSPLAY](./examples/plugin.ts)
198
-
199
- ## Other
200
-
201
- [計算 token 的方案: tiktoken](https://www.npmjs.com/package/tiktoken)
202
-
203
- ## Version History
204
-
205
- ### 0.9.x
206
-
207
- 1. OpenAI 的 API 更新,現在可以透過 `setBaseUrl` 方法來設定 baseUrl。
208
- 2. 新增 X Ai Service 的支援
209
-
210
- ### 0.8.x
211
-
212
- 1. 正規化 Service 的命名
213
- 2. 新增 Google Service 的支援
214
-
215
- ### 0.7.x
216
-
217
- 感謝當今的模型對於json schema的支援,我們不再需要繁瑣的宣告,因此新增了透過註冊 CtoD 的方式來簡化流程。
218
-
219
- ### 0.6.x
220
-
221
- `bindYupToJsonSchemaToYup` 有一些依賴問題已經被移除,改用以下方案取代:
222
-
223
- ```ts
224
- yup.array(item).required().meta({
225
- jsonSchema: {
226
- description: '由高到低排序的索引'
227
- }
228
- })
229
- ```
230
-
231
- 1. 新增了 defineYupSchema 讓建立複雜的 Output 更加容易。
232
-
233
- ### 0.5.x
234
-
235
- 移除了 JSON Schema Info 的支援,而是透過 [yup-to-json-schema](https://github.com/sodaru/yup-to-json-schema) 進行生成資料格式。
236
-
237
- 由於 `yup-to-json-schema` 的延伸套件要使用 `yup.string().description()` 方法需要進行全域註冊,在此我們提供了 `bindYupToJsonSchemaToYup` 這個方法,讓使用者可以自行決定是否要進行註冊。
238
-
239
- 1. 可以在 question 中回應 array,會透過 join 進行合併。
240
- 2. 可以省略 install 參數了。
241
-
242
- ### 0.4.x
243
-
244
- 主要是支援 llama3.cpp 或者是其他自建服務上流程的調整。
245
-
246
- 1. 支援 llama3.cpp server service
247
- 2. 新增 yup to json scheme。
248
-
249
- ### 0.3.x
250
-
251
- 為了支援更多平台與自建服務,我們捨棄了完全為了 ChatGPT 客制化的接口,這樣也能完整保持 Broker 與 Plugin 的一致性。
1
+ <br>
2
+ <p align="center"><img style="max-width: 300px" src="./logo.png"></p>
3
+ <h1 align="center">CtoD</h1>
4
+ <h3 align="center">Chat To Data</h3>
5
+
6
+ <h6 align="center">
7
+ <a href="https://www.npmjs.com/package/ctod">
8
+ <img src="https://img.shields.io/npm/v/ctod.svg">
9
+ </a>
10
+ <a href="https://github.com/KHC-ZhiHao/ctod">
11
+ <img src="https://img.shields.io/github/stars/KHC-ZhiHao/ctod.svg?style=social">
12
+ </a>
13
+ <br>
14
+ </h6>
15
+
16
+ <br>
17
+
18
+ ## 摘要
19
+
20
+ 現在我們頻繁的有透過口語化的方式交付任務 LLM 處理並要求回應 JSON 的需求,透過 CtoD 你可以讓這個模式有架構化的進行。
21
+
22
+ 在對話過程中,CtoD 採用 [yup](https://github.com/jquense/yup) 來驗證請求與回復資料是否符合預期,以確保一致性,只要保持這個互動模式,就可以利用在 API 串接或是自動化系統上。
23
+
24
+ 我們還附帶支援 `OpenAI`, `Google`, `Llama3` 等相關 LLM 服務。
25
+
26
+ ## 安裝
27
+
28
+ npm:
29
+
30
+ ```bash
31
+ npm install ctod
32
+ ```
33
+
34
+ yarn:
35
+
36
+ ```bash
37
+ yarn add ctod
38
+ ```
39
+
40
+ ## 快速開始
41
+
42
+ 這個例子示範如何將藥物索引與客戶需求傳遞給聊天機器人,並返回最適合的結果,開發人員可以利用索引結果去資料庫搜尋最適合的藥物給消費者:
43
+
44
+ ```ts
45
+ import { CtoD, OpenAICtodService } from 'ctod'
46
+
47
+ const ctod = new CtoD({
48
+ request: OpenAICtodService.createChatRequestWithJsonSchema({
49
+ apiKey: 'YOUR_API_KEY',
50
+ config: {
51
+ model: 'gpt-4o'
52
+ }
53
+ })
54
+ })
55
+
56
+ const brokerBuilder = ctod.createBrokerBuilder<{
57
+ indexes: string[]
58
+ question: string
59
+ }>({
60
+ install: ({ attach }) => {
61
+ attach('start', async({ setPreMessages }) => {
62
+ setPreMessages([
63
+ {
64
+ role: 'system',
65
+ content: '你現在是一位擅長分類索引的藥師'
66
+ }
67
+ ])
68
+ })
69
+ }
70
+ })
71
+
72
+ const broker = brokerBuilder.create(async({ yup, data, setMessages }) => {
73
+ const { indexes, question } = data
74
+ setMessages([
75
+ {
76
+ role: 'user',
77
+ content: [
78
+ '我有以下索引',
79
+ `${JSON.stringify(indexes)}`,
80
+ `請幫我解析"${question}"可能是哪個索引`,
81
+ '且相關性由高到低排序並給予分數,分數由 0 ~ 1'
82
+ ]
83
+ }
84
+ ])
85
+ const item = yup.object({
86
+ name: yup.string().required().meta({
87
+ jsonSchema: {
88
+ description: '索引名稱'
89
+ }
90
+ }),
91
+ score: yup.number().required().meta({
92
+ jsonSchema: {
93
+ description: '評比分數'
94
+ }
95
+ })
96
+ }).required()
97
+ return {
98
+ indexes: yup.array(item).required().meta({
99
+ jsonSchema: {
100
+ description: '由高到低排序的索引'
101
+ }
102
+ })
103
+ }
104
+ })
105
+
106
+ broker.request({
107
+ indexes: ['胃痛', '腰痛', '頭痛', '喉嚨痛', '四肢疼痛'],
108
+ question: '喝咖啡,吃甜食,胃食道逆流'
109
+ }).then(e => {
110
+ console.log('輸出結果:', e.indexes)
111
+ /*
112
+ [
113
+ {
114
+ name: '胃痛',
115
+ score: 1
116
+ },
117
+ {
118
+ name: '喉嚨痛',
119
+ score: 0.7
120
+ },
121
+ ...
122
+ ]
123
+ */
124
+ }).catch(error => {
125
+ console.error('Error:', error)
126
+ })
127
+
128
+ ```
129
+
130
+ ## Plugin
131
+
132
+ 雖然 Broker 本身已經能夠處理大部分的事務,但透過 Plugin 可以協助改善複雜的流程,幫助專案工程化。
133
+
134
+ 每次發送請求時,Broker 會觸發一系列的生命週期,你可以從[原始碼](./lib/broker/openai.ts)中了解每個生命週期的參數與行為,並對其行為進行加工。
135
+
136
+ 現在,假設我們想要設計一個插件,它會在每次對話結束時將訊息備份到伺服器上:
137
+
138
+ ```ts
139
+ import axios from 'axios'
140
+ import { CtoDPlugin } from 'ctod'
141
+ const backupPlugin = new CtoDPlugin({
142
+ name: 'backup-plugin',
143
+ // 定義參數為 sendUrl
144
+ params: yup => {
145
+ return {
146
+ sendUrl: yup.string().required()
147
+ }
148
+ },
149
+ // 現階段你可以在執行過程中接收到資訊,資訊結構由這裡定義。
150
+ receiveData: yup => {
151
+ return {
152
+ character: yup.string().required()
153
+ }
154
+ },
155
+ onInstall({ params, attach, receive }) {
156
+ const store = new Map()
157
+ // 假設我們有更多的自訂義資訊需要被傳遞進來,可以在 start 階段透過 plugins[key].send({ ... }) 傳遞
158
+ // 可以從 Applications 分類中的 請機器人角色扮演 觀看案例
159
+ receive(({ id, context }) => {
160
+ store.get(id).context = context
161
+ })
162
+ // 第一次對話的時候初始化資料
163
+ attach('start', async({ id }) => {
164
+ store.set(id, {
165
+ messages: [],
166
+ context: null
167
+ })
168
+ })
169
+ // 每次對話完畢後把對話存入狀態
170
+ attach('talkAfter', async({ id, lastUserMessage }) => {
171
+ store.get(id).messages.push(lastUserMessage)
172
+ })
173
+ // 結束對話後備份資料
174
+ attach('done', async({ id }) => {
175
+ await axios.post(params.sendUrl, store.get(id))
176
+ store.delete(id)
177
+ })
178
+ }
179
+ })
180
+
181
+ const ctod = new CtoD({
182
+ // ...
183
+ plugins: () => {
184
+ return {
185
+ backup: backupPlugin.use({
186
+ sendUrl: 'https://api/backup'
187
+ })
188
+ }
189
+ }
190
+ })
191
+ ```
192
+
193
+ ## Examples
194
+
195
+ [基礎用法 - 藥物查詢功能](./examples/openai.ts)
196
+
197
+ [進階用法 - 請 AI COSPLAY](./examples/plugin.ts)
198
+
199
+ ## Other
200
+
201
+ [計算 token 的方案: tiktoken](https://www.npmjs.com/package/tiktoken)
202
+
203
+ ## Version History
204
+
205
+ ### 0.9.x
206
+
207
+ 1. OpenAI 的 API 更新,現在可以透過 `setBaseUrl` 方法來設定 baseUrl。
208
+ 2. 新增 X Ai Service 的支援
209
+
210
+ ### 0.8.x
211
+
212
+ 1. 正規化 Service 的命名
213
+ 2. 新增 Google Service 的支援
214
+
215
+ ### 0.7.x
216
+
217
+ 感謝當今的模型對於json schema的支援,我們不再需要繁瑣的宣告,因此新增了透過註冊 CtoD 的方式來簡化流程。
218
+
219
+ ### 0.6.x
220
+
221
+ `bindYupToJsonSchemaToYup` 有一些依賴問題已經被移除,改用以下方案取代:
222
+
223
+ ```ts
224
+ yup.array(item).required().meta({
225
+ jsonSchema: {
226
+ description: '由高到低排序的索引'
227
+ }
228
+ })
229
+ ```
230
+
231
+ 1. 新增了 defineYupSchema 讓建立複雜的 Output 更加容易。
232
+
233
+ ### 0.5.x
234
+
235
+ 移除了 JSON Schema Info 的支援,而是透過 [yup-to-json-schema](https://github.com/sodaru/yup-to-json-schema) 進行生成資料格式。
236
+
237
+ 由於 `yup-to-json-schema` 的延伸套件要使用 `yup.string().description()` 方法需要進行全域註冊,在此我們提供了 `bindYupToJsonSchemaToYup` 這個方法,讓使用者可以自行決定是否要進行註冊。
238
+
239
+ 1. 可以在 question 中回應 array,會透過 join 進行合併。
240
+ 2. 可以省略 install 參數了。
241
+
242
+ ### 0.4.x
243
+
244
+ 主要是支援 llama3.cpp 或者是其他自建服務上流程的調整。
245
+
246
+ 1. 支援 llama3.cpp server service
247
+ 2. 新增 yup to json scheme。
248
+
249
+ ### 0.3.x
250
+
251
+ 為了支援更多平台與自建服務,我們捨棄了完全為了 ChatGPT 客制化的接口,這樣也能完整保持 Broker 與 Plugin 的一致性。