@antv/gpt-vis 0.0.6 → 0.1.0

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 (268) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -60
  3. package/README.zh-CN.md +93 -0
  4. package/dist/cjs/Area/index.d.ts +8 -2
  5. package/dist/cjs/Area/index.js +17 -16
  6. package/dist/cjs/Bar/index.d.ts +11 -0
  7. package/dist/cjs/Bar/index.js +65 -0
  8. package/dist/cjs/ChartCodeRender/Loading.d.ts +3 -0
  9. package/dist/cjs/ChartCodeRender/Loading.js +54 -0
  10. package/dist/cjs/ChartCodeRender/VisChart.d.ts +11 -0
  11. package/dist/cjs/ChartCodeRender/VisChart.js +84 -0
  12. package/dist/cjs/ChartCodeRender/index.d.ts +3 -4
  13. package/dist/cjs/ChartCodeRender/index.js +24 -68
  14. package/dist/cjs/ChartCodeRender/type.d.ts +9 -11
  15. package/dist/cjs/Column/index.d.ts +8 -2
  16. package/dist/cjs/Column/index.js +19 -27
  17. package/dist/cjs/ConfigProvider/context.d.ts +3 -0
  18. package/dist/cjs/ConfigProvider/context.js +41 -0
  19. package/dist/cjs/ConfigProvider/hooks/index.d.ts +1 -0
  20. package/dist/cjs/ConfigProvider/hooks/index.js +23 -0
  21. package/dist/cjs/ConfigProvider/hooks/useConfig.d.ts +13 -0
  22. package/dist/cjs/ConfigProvider/hooks/useConfig.js +107 -0
  23. package/dist/cjs/ConfigProvider/index.d.ts +2 -5
  24. package/dist/cjs/ConfigProvider/index.js +15 -9
  25. package/dist/cjs/DualAxes/index.d.ts +15 -0
  26. package/dist/cjs/DualAxes/index.js +71 -0
  27. package/dist/cjs/DualAxes/util.d.ts +9 -0
  28. package/dist/cjs/DualAxes/util.js +73 -0
  29. package/dist/cjs/FlowDiagram/index.d.ts +6 -0
  30. package/dist/cjs/FlowDiagram/index.js +100 -0
  31. package/dist/cjs/GPTVis/index.d.ts +7 -7
  32. package/dist/cjs/GPTVis/index.js +13 -4
  33. package/dist/cjs/HeatMap/index.d.ts +7 -7
  34. package/dist/cjs/HeatMap/index.js +13 -26
  35. package/dist/cjs/Histogram/index.d.ts +10 -0
  36. package/dist/cjs/Histogram/index.js +51 -0
  37. package/dist/cjs/IndentedTree/index.d.ts +6 -0
  38. package/dist/cjs/IndentedTree/index.js +63 -0
  39. package/dist/cjs/Line/index.d.ts +8 -6
  40. package/dist/cjs/Line/index.js +15 -16
  41. package/dist/cjs/Map/data.json +305 -0
  42. package/dist/cjs/Map/index.d.ts +5 -0
  43. package/dist/cjs/Map/index.js +68 -0
  44. package/dist/cjs/MindMap/index.d.ts +6 -0
  45. package/dist/cjs/MindMap/index.js +64 -0
  46. package/dist/cjs/NetworkGraph/index.d.ts +6 -0
  47. package/dist/cjs/NetworkGraph/index.js +72 -0
  48. package/dist/cjs/OrganizationChart/index.d.ts +6 -0
  49. package/dist/cjs/OrganizationChart/index.js +93 -0
  50. package/dist/cjs/PathMap/index.d.ts +3 -9
  51. package/dist/cjs/PathMap/index.js +19 -109
  52. package/dist/cjs/Pie/index.d.ts +7 -5
  53. package/dist/cjs/Pie/index.js +17 -13
  54. package/dist/cjs/PinMap/index.d.ts +3 -9
  55. package/dist/cjs/PinMap/index.js +6 -85
  56. package/dist/cjs/Radar/index.d.ts +11 -0
  57. package/dist/cjs/Radar/index.js +84 -0
  58. package/dist/cjs/Scatter/index.d.ts +11 -0
  59. package/dist/cjs/Scatter/index.js +57 -0
  60. package/dist/cjs/Text/VisText.d.ts +4 -0
  61. package/dist/cjs/Text/VisText.js +71 -0
  62. package/dist/cjs/Text/config.d.ts +18 -0
  63. package/dist/cjs/Text/config.js +91 -0
  64. package/dist/cjs/Text/constants.d.ts +9 -0
  65. package/dist/cjs/Text/constants.js +37 -0
  66. package/dist/cjs/Text/custom-icons/index.d.ts +3 -0
  67. package/dist/cjs/Text/custom-icons/index.js +66 -0
  68. package/dist/cjs/Text/index.d.ts +3 -0
  69. package/dist/cjs/Text/index.js +42 -0
  70. package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
  71. package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.js +65 -0
  72. package/dist/cjs/Text/mini-charts/hooks/index.d.ts +1 -0
  73. package/dist/cjs/Text/mini-charts/hooks/index.js +29 -0
  74. package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
  75. package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.js +65 -0
  76. package/dist/cjs/Text/mini-charts/index.d.ts +2 -0
  77. package/dist/cjs/Text/mini-charts/index.js +25 -0
  78. package/dist/cjs/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
  79. package/dist/cjs/Text/mini-charts/line/SingleLineChart.js +63 -0
  80. package/dist/cjs/Text/mini-charts/line/index.d.ts +1 -0
  81. package/dist/cjs/Text/mini-charts/line/index.js +29 -0
  82. package/dist/cjs/Text/mini-charts/line/scaleLinear.d.ts +4 -0
  83. package/dist/cjs/Text/mini-charts/line/scaleLinear.js +35 -0
  84. package/dist/cjs/Text/mini-charts/line/useLineCompute.d.ts +6 -0
  85. package/dist/cjs/Text/mini-charts/line/useLineCompute.js +103 -0
  86. package/dist/cjs/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
  87. package/dist/cjs/Text/mini-charts/proportion/getArcPath.js +51 -0
  88. package/dist/cjs/Text/mini-charts/proportion/index.d.ts +3 -0
  89. package/dist/cjs/Text/mini-charts/proportion/index.js +72 -0
  90. package/dist/cjs/Text/types.d.ts +20 -0
  91. package/dist/cjs/Text/types.js +17 -0
  92. package/dist/cjs/Treemap/index.d.ts +11 -0
  93. package/dist/cjs/Treemap/index.js +73 -0
  94. package/dist/cjs/WordCloud/index.d.ts +4 -5
  95. package/dist/cjs/WordCloud/index.js +7 -15
  96. package/dist/cjs/constants/index.d.ts +1 -3
  97. package/dist/cjs/constants/index.js +4 -35
  98. package/dist/cjs/export.d.ts +25 -0
  99. package/dist/cjs/export.js +119 -0
  100. package/dist/cjs/index.d.ts +4 -10
  101. package/dist/cjs/index.js +5 -27
  102. package/dist/cjs/types/chart.d.ts +49 -14
  103. package/dist/cjs/types/chart.js +12 -0
  104. package/dist/cjs/types/config.d.ts +11 -0
  105. package/dist/cjs/types/index.d.ts +1 -1
  106. package/dist/cjs/types/index.js +0 -9
  107. package/dist/cjs/types/map.d.ts +242 -0
  108. package/dist/cjs/types/map.js +17 -0
  109. package/dist/cjs/utils/config.d.ts +5 -5
  110. package/dist/cjs/utils/config.js +41 -24
  111. package/dist/cjs/utils/graph.d.ts +18 -0
  112. package/dist/cjs/utils/graph.js +64 -0
  113. package/dist/cjs/utils/index.d.ts +1 -1
  114. package/dist/cjs/utils/index.js +3 -13
  115. package/dist/cjs/utils/map/context.d.ts +3 -0
  116. package/dist/cjs/utils/map/context.js +42 -0
  117. package/dist/cjs/utils/map/controls.d.ts +0 -0
  118. package/dist/cjs/utils/map/controls.js +0 -0
  119. package/dist/cjs/utils/map/index.d.ts +6 -0
  120. package/dist/cjs/utils/map/index.js +33 -0
  121. package/dist/cjs/utils/map/markers.d.ts +2 -0
  122. package/dist/cjs/utils/map/markers.js +88 -0
  123. package/dist/cjs/utils/map/polyline.d.ts +2 -0
  124. package/dist/cjs/utils/map/polyline.js +52 -0
  125. package/dist/cjs/utils/map/style.d.ts +45 -0
  126. package/dist/cjs/utils/map/style.js +112 -0
  127. package/dist/cjs/utils/map/util.d.ts +1 -0
  128. package/dist/cjs/utils/map/util.js +38 -0
  129. package/dist/cjs/utils/map/view.d.ts +3 -0
  130. package/dist/cjs/utils/map/view.js +93 -0
  131. package/dist/cjs/utils/plot.d.ts +4 -0
  132. package/dist/cjs/utils/plot.js +69 -0
  133. package/dist/cjs/version.d.ts +2 -0
  134. package/dist/cjs/version.js +25 -0
  135. package/dist/esm/Area/index.d.ts +8 -2
  136. package/dist/esm/Area/index.js +21 -27
  137. package/dist/esm/Bar/index.d.ts +11 -0
  138. package/dist/esm/Bar/index.js +35 -0
  139. package/dist/esm/ChartCodeRender/Loading.d.ts +3 -0
  140. package/dist/esm/ChartCodeRender/Loading.js +20 -0
  141. package/dist/esm/ChartCodeRender/VisChart.d.ts +11 -0
  142. package/dist/esm/ChartCodeRender/VisChart.js +65 -0
  143. package/dist/esm/ChartCodeRender/index.d.ts +3 -4
  144. package/dist/esm/ChartCodeRender/index.js +28 -84
  145. package/dist/esm/ChartCodeRender/type.d.ts +9 -11
  146. package/dist/esm/Column/index.d.ts +8 -2
  147. package/dist/esm/Column/index.js +22 -27
  148. package/dist/esm/ConfigProvider/context.d.ts +3 -0
  149. package/dist/esm/ConfigProvider/context.js +3 -0
  150. package/dist/esm/ConfigProvider/hooks/index.d.ts +1 -0
  151. package/dist/esm/ConfigProvider/hooks/index.js +1 -0
  152. package/dist/esm/ConfigProvider/hooks/useConfig.d.ts +13 -0
  153. package/dist/esm/ConfigProvider/hooks/useConfig.js +55 -0
  154. package/dist/esm/ConfigProvider/index.d.ts +2 -5
  155. package/dist/esm/ConfigProvider/index.js +9 -9
  156. package/dist/esm/DualAxes/index.d.ts +15 -0
  157. package/dist/esm/DualAxes/index.js +44 -0
  158. package/dist/esm/DualAxes/util.d.ts +9 -0
  159. package/dist/esm/DualAxes/util.js +61 -0
  160. package/dist/esm/FlowDiagram/index.d.ts +6 -0
  161. package/dist/esm/FlowDiagram/index.js +75 -0
  162. package/dist/esm/GPTVis/index.d.ts +7 -7
  163. package/dist/esm/GPTVis/index.js +9 -5
  164. package/dist/esm/HeatMap/index.d.ts +7 -7
  165. package/dist/esm/HeatMap/index.js +19 -27
  166. package/dist/esm/Histogram/index.d.ts +10 -0
  167. package/dist/esm/Histogram/index.js +25 -0
  168. package/dist/esm/IndentedTree/index.d.ts +6 -0
  169. package/dist/esm/IndentedTree/index.js +47 -0
  170. package/dist/esm/Line/index.d.ts +8 -6
  171. package/dist/esm/Line/index.js +17 -23
  172. package/dist/esm/Map/data.json +305 -0
  173. package/dist/esm/Map/index.d.ts +5 -0
  174. package/dist/esm/Map/index.js +60 -0
  175. package/dist/esm/MindMap/index.d.ts +6 -0
  176. package/dist/esm/MindMap/index.js +48 -0
  177. package/dist/esm/NetworkGraph/index.d.ts +6 -0
  178. package/dist/esm/NetworkGraph/index.js +57 -0
  179. package/dist/esm/OrganizationChart/index.d.ts +6 -0
  180. package/dist/esm/OrganizationChart/index.js +64 -0
  181. package/dist/esm/PathMap/index.d.ts +3 -9
  182. package/dist/esm/PathMap/index.js +32 -129
  183. package/dist/esm/Pie/index.d.ts +7 -5
  184. package/dist/esm/Pie/index.js +24 -20
  185. package/dist/esm/PinMap/index.d.ts +3 -9
  186. package/dist/esm/PinMap/index.js +18 -104
  187. package/dist/esm/Radar/index.d.ts +11 -0
  188. package/dist/esm/Radar/index.js +54 -0
  189. package/dist/esm/Scatter/index.d.ts +11 -0
  190. package/dist/esm/Scatter/index.js +30 -0
  191. package/dist/esm/Text/VisText.d.ts +4 -0
  192. package/dist/esm/Text/VisText.js +34 -0
  193. package/dist/esm/Text/config.d.ts +18 -0
  194. package/dist/esm/Text/config.js +79 -0
  195. package/dist/esm/Text/constants.d.ts +9 -0
  196. package/dist/esm/Text/constants.js +9 -0
  197. package/dist/esm/Text/custom-icons/index.d.ts +3 -0
  198. package/dist/esm/Text/custom-icons/index.js +37 -0
  199. package/dist/esm/Text/index.d.ts +3 -0
  200. package/dist/esm/Text/index.js +2 -0
  201. package/dist/esm/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
  202. package/dist/esm/Text/mini-charts/hooks/getElementFontSize.js +32 -0
  203. package/dist/esm/Text/mini-charts/hooks/index.d.ts +1 -0
  204. package/dist/esm/Text/mini-charts/hooks/index.js +1 -0
  205. package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
  206. package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.js +31 -0
  207. package/dist/esm/Text/mini-charts/index.d.ts +2 -0
  208. package/dist/esm/Text/mini-charts/index.js +2 -0
  209. package/dist/esm/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
  210. package/dist/esm/Text/mini-charts/line/SingleLineChart.js +57 -0
  211. package/dist/esm/Text/mini-charts/line/index.d.ts +1 -0
  212. package/dist/esm/Text/mini-charts/line/index.js +1 -0
  213. package/dist/esm/Text/mini-charts/line/scaleLinear.d.ts +4 -0
  214. package/dist/esm/Text/mini-charts/line/scaleLinear.js +14 -0
  215. package/dist/esm/Text/mini-charts/line/useLineCompute.d.ts +6 -0
  216. package/dist/esm/Text/mini-charts/line/useLineCompute.js +106 -0
  217. package/dist/esm/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
  218. package/dist/esm/Text/mini-charts/proportion/getArcPath.js +19 -0
  219. package/dist/esm/Text/mini-charts/proportion/index.d.ts +3 -0
  220. package/dist/esm/Text/mini-charts/proportion/index.js +60 -0
  221. package/dist/esm/Text/types.d.ts +20 -0
  222. package/dist/esm/Text/types.js +1 -0
  223. package/dist/esm/Treemap/index.d.ts +11 -0
  224. package/dist/esm/Treemap/index.js +52 -0
  225. package/dist/esm/WordCloud/index.d.ts +4 -5
  226. package/dist/esm/WordCloud/index.js +8 -18
  227. package/dist/esm/constants/index.d.ts +1 -3
  228. package/dist/esm/constants/index.js +5 -14
  229. package/dist/esm/export.d.ts +25 -0
  230. package/dist/esm/export.js +27 -0
  231. package/dist/esm/index.d.ts +4 -10
  232. package/dist/esm/index.js +2 -9
  233. package/dist/esm/types/chart.d.ts +49 -14
  234. package/dist/esm/types/chart.js +12 -0
  235. package/dist/esm/types/config.d.ts +11 -0
  236. package/dist/esm/types/index.d.ts +1 -1
  237. package/dist/esm/types/index.js +1 -1
  238. package/dist/esm/types/map.d.ts +242 -0
  239. package/dist/esm/types/map.js +1 -0
  240. package/dist/esm/utils/config.d.ts +5 -5
  241. package/dist/esm/utils/config.js +40 -18
  242. package/dist/esm/utils/graph.d.ts +18 -0
  243. package/dist/esm/utils/graph.js +49 -0
  244. package/dist/esm/utils/index.d.ts +1 -1
  245. package/dist/esm/utils/index.js +1 -1
  246. package/dist/esm/utils/map/context.d.ts +3 -0
  247. package/dist/esm/utils/map/context.js +34 -0
  248. package/dist/esm/utils/map/controls.d.ts +0 -0
  249. package/dist/esm/utils/map/controls.js +0 -0
  250. package/dist/esm/utils/map/index.d.ts +6 -0
  251. package/dist/esm/utils/map/index.js +6 -0
  252. package/dist/esm/utils/map/markers.d.ts +2 -0
  253. package/dist/esm/utils/map/markers.js +64 -0
  254. package/dist/esm/utils/map/polyline.d.ts +2 -0
  255. package/dist/esm/utils/map/polyline.js +26 -0
  256. package/dist/esm/utils/map/style.d.ts +45 -0
  257. package/dist/esm/utils/map/style.js +76 -0
  258. package/dist/esm/utils/map/util.d.ts +1 -0
  259. package/dist/esm/utils/map/util.js +11 -0
  260. package/dist/esm/utils/map/view.d.ts +3 -0
  261. package/dist/esm/utils/map/view.js +81 -0
  262. package/dist/esm/utils/plot.d.ts +4 -0
  263. package/dist/esm/utils/plot.js +65 -0
  264. package/dist/esm/version.d.ts +2 -0
  265. package/dist/esm/version.js +1 -0
  266. package/dist/umd/861.async.js +1 -0
  267. package/dist/umd/index.min.js +1 -0
  268. package/package.json +97 -58
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 AntV
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,58 +1,48 @@
1
- # GPT-Vis
1
+ <img src="https://gw.alipayobjects.com/zos/antfincdn/R8sN%24GNdh6/language.svg" width="18"> English | [简体中文](./README.zh-CN.md)
2
2
 
3
- 为各种 LLM Agent 提供卡片服务的可视化资产和协议。
3
+ <h1 align="center">GPT-Vis</h1>
4
4
 
5
- ## ⏬ 安装
5
+ <div align="center">
6
6
 
7
- ```shell
8
- $ npm install @antv/gpt-vis@0.x --save
9
- ```
7
+ Components for GPTs, generative AI, and LLM projects. Not only UI Components.
10
8
 
11
- ## 🌰 示例
9
+ <p align="center">
10
+ <a href="https://gpt-vis.antv.com" target="_blank">Document</a> •
11
+ <a href="/knowledges" target="_blank">Knowledge</a> •
12
+ <a href="https://huggingface.co/antvis" target="_blank">Huggingface</a> •
13
+ <a href="https://tbox.alipay.com/share/202410APr1n200110168?platform=WebService" target="_blank">Agent Demo</a>
14
+ </p>
12
15
 
13
- ### 📦 组件中使用
16
+ <div align="center">
17
+ <img src="https://github.com/eosphoros-ai/GPT-Vis/assets/17919400/c8804ffb-d3d6-45d3-846f-cf217681ab05" width=500">
18
+ </div>
14
19
 
15
- ```tsx | pure
16
- import React from 'react';
17
- import { Pie } from '@antv/gpt-vis';
20
+ </div>
18
21
 
19
- const data = [
20
- { name: '分类一', value: 27 },
21
- { name: '分类二', value: 25 },
22
- { name: '分类三', value: 18 },
23
- { name: '分类四', value: 15 },
24
- { name: '分类五', value: 10 },
25
- { name: '其他', value: 5 },
26
- ];
22
+ ## Features
27
23
 
28
- export default () => {
29
- return <Pie data={data} />;
30
- };
31
- ```
24
+ - 🤖 **LLM Protocol**: A visual protocol for LLM Agent cards, designed for LLM conversational interaction and service serialized output, to facilitate rapid integration into AI applications.
25
+ - 🍡 **LLM Component**: Developed components for LLM applications, with 20+ commonly used VIS components built-in, providing convenient expansion mechanism and architecture design for customized UI requirements.
26
+ - 📈 **LLM access**: Chart knowledge base and chart recommendation model for seamless access to LLM, directly output visual cards for LLM, and provide knowledge base and recommended model solutions for Agent.
32
27
 
33
- ### 📝 Markdown 中使用
28
+ ## 📦 Installation
34
29
 
35
- #### 方式一:使用 GPTVis 组件
30
+ ```bash
31
+ $ npm i @antv/gpt-vis --save
32
+ ```
36
33
 
37
- ```tsx | pure
38
- import React from 'react';
34
+ ## 🔨 Usage
35
+
36
+ ```jsx
39
37
  import { GPTVis } from '@antv/gpt-vis';
40
38
 
41
39
  const markdownContent = `
42
40
  # GPT-VIS \n\nComponents for GPTs, generative AI, and LLM projects. Not only UI Components.
43
41
 
42
+ Here’s a visualization of Haidilao's food delivery revenue from 2013 to 2022. You can see a steady increase over the years, with notable *growth* particularly in recent years.
43
+
44
44
  \`\`\`vis-chart
45
- {
46
- "type": "pie",
47
- "data": [
48
- { "name": "分类一", "value": 27 },
49
- { "name": "分类二", "value": 25 },
50
- { "name": "分类三", "value": 18 },
51
- { "name": "分类四", "value": 15 },
52
- { "name": "分类五", "value": 10 },
53
- { "name": "其他", "value": 5 }
54
- ]
55
- }
45
+ { "type": "line","data": [{"time":2013,"value":59.3},{"time":2014,"value":64.4},{"time":2015,"value":68.9},{"time":2016,"value":74.4},{"time":2017,"value":82.7},{"time":2018,"value":91.9},{"time":2019,"value":99.1},{"time":2020,"value":101.6},{"time":2021,"value":114.4},{"time":2022,"value":121}] }
56
46
  \`\`\`
57
47
  `;
58
48
 
@@ -61,36 +51,43 @@ export default () => {
61
51
  };
62
52
  ```
63
53
 
64
- #### 方式二:扩展 react-markdown 使用
54
+ ## 🛠 Custom renderer
65
55
 
66
- ```tsx | pure
67
- import React from 'react';
68
- import Markdown from 'react-markdown';
69
- import { withDefaultChartCode } from '@antv/gpt-vis';
56
+ ```jsx
57
+ import { GPTVis, withDefaultChartCode, VisText } from '@antv/gpt-vis';
70
58
 
71
59
  const markdownContent = `
72
- # GPT-VIS \n\nComponents for GPTs, generative AI, and LLM projects. Not only UI Components.
60
+ <vis-text type="time_desc">本月</vis-text>共产生<vis-text type="metric_name">决策数量</vis-text><vis-text type="metric_value">2,783</vis-text>个,环比<vis-text type="trend_desc">增长</vis-text><vis-text type="ratio_value_pos">15.2%</vis-text>。<vis-text type="dim_name">高优先级决策</vis-text>占比<vis-text type="proportion">56.2%</vis-text>,呈现稳定<vis-text type="trend_desc" origin="[1, 2, 6, 18, 24, 48]">上升</vis-text>趋势,预计<vis-text type="time_desc">下月</vis-text>将突破<vis-text type="metric_value">3,000</vis-text>大关。
73
61
 
74
- \`\`\`vis-chart
75
- {
76
- "type": "pie",
77
- "data": [
78
- { "name": "分类一", "value": 27 },
79
- { "name": "分类二", "value": 25 },
80
- { "name": "分类三", "value": 18 },
81
- { "name": "分类四", "value": 15 },
82
- { "name": "分类五", "value": 10 },
83
- { "name": "其他", "value": 5 }
84
- ]
85
- }
62
+ \`\`\`my-ui
63
+ my data
86
64
  \`\`\`
87
65
  `;
88
66
 
89
- const CodeBlock = withDefaultChartCode();
67
+ const customRenderers = { 'my-ui': ({ children }) => <div>{children}</div> };
68
+ const components = {
69
+ 'vis-text': VisText,
70
+ code: withDefaultChartCode({ languageRenderers: customRenderers }),
71
+ };
90
72
 
91
73
  export default () => {
92
- return (
93
- <Markdown components={{ code: CodeBlock }}>{markdownContent}</Markdown>
94
- );
74
+ return <GPTVis components={components}>{markdownContent}</GPTVis>;
95
75
  };
96
76
  ```
77
+
78
+ ## 💻 Development
79
+
80
+ ```bash
81
+ # install dependencies
82
+ $ pnpm install
83
+
84
+ # develop library by docs demo
85
+ $ pnpm dev
86
+
87
+ # build library source code
88
+ $ pnpm build
89
+ ```
90
+
91
+ ## License
92
+
93
+ [MIT](./LICENSE)
@@ -0,0 +1,93 @@
1
+ <img src="https://gw.alipayobjects.com/zos/antfincdn/R8sN%24GNdh6/language.svg" width="18"> [English](./README.md) | 简体中文
2
+
3
+ <h1 align="center">GPT-Vis</h1>
4
+
5
+ <div align="center">
6
+
7
+ Components for GPTs, generative AI, and LLM projects. Not only UI Components.
8
+
9
+ <p align="center">
10
+ <a href="https://gpt-vis.antv.com" target="_blank">文档</a> •
11
+ <a href="/knowledges" target="_blank">知识库</a> •
12
+ <a href="https://huggingface.co/antvis" target="_blank">Huggingface</a> •
13
+ <a href="https://tbox.alipay.com/share/202410APr1n200110168?platform=WebService" target="_blank">体验 Agent</a>
14
+ </p>
15
+
16
+ <div align="center">
17
+ <img src="https://github.com/eosphoros-ai/GPT-Vis/assets/17919400/c8804ffb-d3d6-45d3-846f-cf217681ab05" width=500">
18
+ </div>
19
+
20
+ </div>
21
+
22
+ ## 特性
23
+
24
+ - 🤖 **LLM 协议**:面向 LLM Agent 卡片的可视化协议,针对 LLM 对话式交互,以及服务序列化输出而设计,方便快速集成到 AI 应用中。
25
+ - 🍡 **LLM 组件**:面向 LLM 应用研发组件, 内置有 20+ 常用 VIS 组件,对于定制 UI 需求,提供方便的扩展机制和架构设计。
26
+ - 📈 **LLM 接入**:面向 LLM 无缝接入的图表知识库和图表推荐模型,针对 LLM 直接输出可视化卡片,为 Agent 提供知识库以及推荐模型方案。
27
+
28
+ ## 📦 安装
29
+
30
+ ```bash
31
+ $ npm i @antv/gpt-vis --save
32
+ ```
33
+
34
+ ## 🔨 使用
35
+
36
+ ```jsx
37
+ import { GPTVis } from '@antv/gpt-vis';
38
+
39
+ const markdownContent = `
40
+ # GPT-VIS \n\nComponents for GPTs, generative AI, and LLM projects. Not only UI Components.
41
+
42
+ Here’s a visualization of Haidilao's food delivery revenue from 2013 to 2022. You can see a steady increase over the years, with notable *growth* particularly in recent years.
43
+
44
+ \`\`\`vis-chart
45
+ { "type": "line","data": [{"time":2013,"value":59.3},{"time":2014,"value":64.4},{"time":2015,"value":68.9},{"time":2016,"value":74.4},{"time":2017,"value":82.7},{"time":2018,"value":91.9},{"time":2019,"value":99.1},{"time":2020,"value":101.6},{"time":2021,"value":114.4},{"time":2022,"value":121}] }
46
+ \`\`\`
47
+ `;
48
+
49
+ export default () => {
50
+ return <GPTVis>{markdownContent}</GPTVis>;
51
+ };
52
+ ```
53
+
54
+ ## 🛠 定制渲染器
55
+
56
+ ```jsx
57
+ import { GPTVis, withDefaultChartCode, VisText } from '@antv/gpt-vis';
58
+
59
+ const markdownContent = `
60
+ <vis-text type="time_desc">本月</vis-text>共产生<vis-text type="metric_name">决策数量</vis-text><vis-text type="metric_value">2,783</vis-text>个,环比<vis-text type="trend_desc">增长</vis-text><vis-text type="ratio_value_pos">15.2%</vis-text>。<vis-text type="dim_name">高优先级决策</vis-text>占比<vis-text type="proportion">56.2%</vis-text>,呈现稳定<vis-text type="trend_desc" origin="[1, 2, 6, 18, 24, 48]">上升</vis-text>趋势,预计<vis-text type="time_desc">下月</vis-text>将突破<vis-text type="metric_value">3,000</vis-text>大关。
61
+
62
+ \`\`\`my-ui
63
+ my data
64
+ \`\`\`
65
+ `;
66
+
67
+ const customRenderers = { 'my-ui': ({ children }) => <div>{children}</div> };
68
+ const components = {
69
+ 'vis-text': VisText,
70
+ code: withDefaultChartCode({ languageRenderers: customRenderers }),
71
+ };
72
+
73
+ export default () => {
74
+ return <GPTVis components={components}>{markdownContent}</GPTVis>;
75
+ };
76
+ ```
77
+
78
+ ## 💻 本地开发
79
+
80
+ ```bash
81
+ # install dependencies
82
+ $ pnpm install
83
+
84
+ # develop library by docs demo
85
+ $ pnpm dev
86
+
87
+ # build library source code
88
+ $ pnpm build
89
+ ```
90
+
91
+ ## License
92
+
93
+ [MIT](./LICENSE)
@@ -1,5 +1,11 @@
1
+ import type { AreaConfig } from '@ant-design/plots';
1
2
  import React from 'react';
2
- import { StackableChartProps } from '../types';
3
- export type AreaProps = StackableChartProps;
3
+ import type { BasePlotProps } from '../types';
4
+ type AreaDataItem = {
5
+ time: string | number;
6
+ value: number;
7
+ [key: string]: string | number;
8
+ };
9
+ export type AreaProps = BasePlotProps<AreaDataItem> & Partial<AreaConfig>;
4
10
  declare const Area: (props: AreaProps) => React.JSX.Element;
5
11
  export default Area;
@@ -33,29 +33,30 @@ __export(Area_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(Area_exports);
35
35
  var import_plots = require("@ant-design/plots");
36
+ var import_lodash = require("lodash");
36
37
  var import_react = __toESM(require("react"));
37
- var Area = (props) => {
38
- const {
39
- data = [],
40
- xField = "x",
41
- yField = "y",
42
- stackField,
43
- className,
44
- style
45
- } = props;
46
- const stackConfig = stackField ? { colorField: stackField, isStack: true } : {};
47
- const config = {
48
- data,
38
+ var import_hooks = require("../ConfigProvider/hooks");
39
+ var defaultConfig = (props) => {
40
+ const { data, xField = "time", yField = "value" } = props;
41
+ const hasGroupField = (0, import_lodash.get)(data, "[0].group") !== void 0;
42
+ const axisYTitle = (0, import_lodash.get)(props, "axis.y.title");
43
+ const defalutStyle = hasGroupField ? {} : { opacity: 0.6 };
44
+ return {
49
45
  xField,
50
46
  yField,
47
+ style: defalutStyle,
48
+ colorField: hasGroupField ? "group" : void 0,
51
49
  tooltip: (d) => {
50
+ const tooltipName = axisYTitle || d[xField];
52
51
  return {
53
- name: d[xField],
52
+ name: tooltipName,
54
53
  value: d[yField]
55
54
  };
56
- },
57
- ...stackConfig
55
+ }
58
56
  };
59
- return /* @__PURE__ */ import_react.default.createElement(import_plots.Area, { className, containerStyle: { ...style }, ...config });
57
+ };
58
+ var Area = (props) => {
59
+ const config = (0, import_hooks.usePlotConfig)("Area", defaultConfig, props);
60
+ return /* @__PURE__ */ import_react.default.createElement(import_plots.Area, { ...config });
60
61
  };
61
62
  var Area_default = Area;
@@ -0,0 +1,11 @@
1
+ import type { BarConfig } from '@ant-design/plots';
2
+ import React from 'react';
3
+ import type { BasePlotProps } from '../types';
4
+ type BarDataItem = {
5
+ category: string;
6
+ value: number;
7
+ [key: string]: string | number;
8
+ };
9
+ export type BarProps = BasePlotProps<BarDataItem> & Partial<BarConfig>;
10
+ declare const Bar: (props: BarProps) => React.JSX.Element;
11
+ export default Bar;
@@ -0,0 +1,65 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/Bar/index.tsx
30
+ var Bar_exports = {};
31
+ __export(Bar_exports, {
32
+ default: () => Bar_default
33
+ });
34
+ module.exports = __toCommonJS(Bar_exports);
35
+ var import_plots = require("@ant-design/plots");
36
+ var import_lodash = require("lodash");
37
+ var import_react = __toESM(require("react"));
38
+ var import_hooks = require("../ConfigProvider/hooks");
39
+ var defaultConfig = (props) => {
40
+ const { data, xField = "category", yField = "value" } = props;
41
+ const hasGroupField = (0, import_lodash.get)(data, "[0].group") !== void 0;
42
+ const axisYTitle = (0, import_lodash.get)(props, "axis.y.title");
43
+ return {
44
+ xField,
45
+ yField,
46
+ colorField: hasGroupField ? "group" : void 0,
47
+ tooltip: (d) => {
48
+ const tooltipName = axisYTitle || d[xField];
49
+ return {
50
+ name: tooltipName,
51
+ value: d[yField]
52
+ };
53
+ },
54
+ style: {
55
+ // 圆角样式
56
+ radiusTopLeft: 5,
57
+ radiusTopRight: 5
58
+ }
59
+ };
60
+ };
61
+ var Bar = (props) => {
62
+ const config = (0, import_hooks.usePlotConfig)("Bar", defaultConfig, props);
63
+ return /* @__PURE__ */ import_react.default.createElement(import_plots.Bar, { ...config });
64
+ };
65
+ var Bar_default = Bar;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const Loading: () => React.JSX.Element;
3
+ export default Loading;
@@ -0,0 +1,54 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/ChartCodeRender/Loading.tsx
30
+ var Loading_exports = {};
31
+ __export(Loading_exports, {
32
+ default: () => Loading_default
33
+ });
34
+ module.exports = __toCommonJS(Loading_exports);
35
+ var import_icons = require("@ant-design/icons");
36
+ var import_react = __toESM(require("react"));
37
+ var import_styled_components = __toESM(require("styled-components"));
38
+ var StyledLoading = import_styled_components.default.div`
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ flex-direction: column;
43
+ height: 300px;
44
+ background-image: linear-gradient(135deg, #e3f3ff 0%, #f1eeff 100%);
45
+ color: rgba(0, 0, 0, 88%);
46
+
47
+ &-icon {
48
+ margin-bottom: 6px;
49
+ }
50
+ `;
51
+ var Loading = () => {
52
+ return /* @__PURE__ */ import_react.default.createElement(StyledLoading, { className: "gpt-vis-loading" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "gpt-vis-loading-icon" }, /* @__PURE__ */ import_react.default.createElement(import_icons.LoadingOutlined, { style: { fontSize: "24px", color: "rgb(56, 177, 246)" } })), /* @__PURE__ */ import_react.default.createElement("p", null, "数据生成中"));
53
+ };
54
+ var Loading_default = Loading;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { ChartComponents } from './type';
3
+ type RenderVisChartProps = {
4
+ content: string;
5
+ components: ChartComponents;
6
+ debug?: boolean;
7
+ loadingTimeout: number;
8
+ style?: React.CSSProperties;
9
+ };
10
+ export declare const RenderVisChart: React.FC<RenderVisChartProps>;
11
+ export {};
@@ -0,0 +1,84 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/ChartCodeRender/VisChart.tsx
30
+ var VisChart_exports = {};
31
+ __export(VisChart_exports, {
32
+ RenderVisChart: () => RenderVisChart
33
+ });
34
+ module.exports = __toCommonJS(VisChart_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_styled_components = __toESM(require("styled-components"));
37
+ var import_Loading = __toESM(require("./Loading"));
38
+ var StyledGPTVis = import_styled_components.default.div`
39
+ min-width: 300px;
40
+ height: 300px;
41
+ max-width: 100%;
42
+ `;
43
+ var GlobalStyles = import_styled_components.createGlobalStyle`
44
+ pre:has(.gpt-vis) {
45
+ overflow: hidden;
46
+ }
47
+ `;
48
+ var RenderVisChart = (0, import_react.memo)(
49
+ ({ style, content, components, debug, loadingTimeout }) => {
50
+ const timeoutRef = (0, import_react.useRef)();
51
+ const [loading, setLoading] = (0, import_react.useState)(true);
52
+ let chartJson;
53
+ try {
54
+ chartJson = JSON.parse(content);
55
+ } catch (e) {
56
+ if (timeoutRef.current) {
57
+ clearTimeout(timeoutRef.current);
58
+ if (debug) {
59
+ console.warn("GPT-Vis withChartCode parse content timeout");
60
+ }
61
+ }
62
+ timeoutRef.current = setTimeout(() => {
63
+ setLoading(false);
64
+ }, loadingTimeout);
65
+ if (loading) {
66
+ return /* @__PURE__ */ import_react.default.createElement(StyledGPTVis, { className: "gpt-vis", style }, /* @__PURE__ */ import_react.default.createElement(import_Loading.default, null));
67
+ }
68
+ return /* @__PURE__ */ import_react.default.createElement("p", null, "Chart generation timeout.");
69
+ }
70
+ const { type, ...chartProps } = chartJson;
71
+ const ChartComponent = components[type];
72
+ if (debug) {
73
+ console.log("GPT-Vis withChartCode get chartJson parse from vis-chart code block", chartJson);
74
+ }
75
+ if (!ChartComponent) {
76
+ return /* @__PURE__ */ import_react.default.createElement("p", null, `Chart type "${type}" is not supported.`);
77
+ }
78
+ return /* @__PURE__ */ import_react.default.createElement(StyledGPTVis, { className: "gpt-vis", style }, /* @__PURE__ */ import_react.default.createElement(GlobalStyles, null), /* @__PURE__ */ import_react.default.createElement(ChartComponent, { ...chartProps }));
79
+ }
80
+ );
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ RenderVisChart
84
+ });
@@ -1,9 +1,8 @@
1
- import React from 'react';
2
- import { WithChartCodeOptions } from './type';
3
- export declare const withChartCode: (options: WithChartCodeOptions) => keyof JSX.IntrinsicElements | import("hast-util-to-jsx-runtime/lib/components").Component<React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement> & import("hast-util-to-jsx-runtime/lib/components").ExtraProps> | undefined;
1
+ import type { CodeBlockComponent, WithChartCodeOptions } from './type';
2
+ export declare const withChartCode: (options: WithChartCodeOptions) => CodeBlockComponent;
4
3
  /**
5
4
  * Includes built-in chart components such as line charts, pie charts, etc.
6
5
  * @param componentsArray
7
6
  * @returns
8
7
  */
9
- export declare const withDefaultChartCode: (options?: Partial<WithChartCodeOptions>) => keyof JSX.IntrinsicElements | import("hast-util-to-jsx-runtime/lib/components").Component<React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement> & import("hast-util-to-jsx-runtime/lib/components").ExtraProps> | undefined;
8
+ export declare const withDefaultChartCode: (options?: Partial<WithChartCodeOptions>) => CodeBlockComponent;