Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use #2

Open
ZhinanCai opened this issue May 13, 2024 · 4 comments
Open

how to use #2

ZhinanCai opened this issue May 13, 2024 · 4 comments

Comments

@ZhinanCai
Copy link

Hi its a great work!
I Would Like To Ask If There Is A Document Or Tutorial Explaining How To Use It 。The Project Displays An Empty Page When It Is Started。

@wzmroot
Copy link

wzmroot commented Sep 26, 2024

Indeed, I am also not sure how this project works with DB-GPT.

@Luooojunnn
Copy link

文档写依赖gpt-vis包,我去npm仓库看了,那个包是空包,这个项目的文档是不是有问题?只有一个markdown的运行展示

@lvisei
Copy link
Member

lvisei commented Nov 14, 2024

文档写依赖gpt-vis包,我去npm仓库看了,那个包是空包,这个项目的文档是不是有问题?只有一个markdown的运行展示

关注 #4,这两天发布新版本。

@lvisei
Copy link
Member

lvisei commented Nov 15, 2024

  • Installation
$ npm i @antv/gpt-vis --save
  • Usage
import { GPTVis } from '@antv/gpt-vis';

const markdownContent = `
# GPT-VIS \n\nComponents for GPTs, generative AI, and LLM projects. Not only UI Components.

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.

\`\`\`vis-chart
{"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}]}
\`\`\`
`;

export default () => {
  return <GPTVis>{markdownContent}</GPTVis>;
};
  • Custom renderer
import { GPTVis, withDefaultChartCode } from '@antv/gpt-vis';

const markdownContent = `
\`\`\`my-ui
my data
\`\`\`
`;

const customRenderers = { 'my-ui': ({ children }) => <div>{children}</div> };
const components = {
  code: withDefaultChartCode({ languageRenderers: customRenderers }),
};

export default () => {
  return <GPTVis components={components}>{markdownContent}</GPTVis>;
};
  • With streamlit
import streamlit as st
from streamlit_gpt_vis import set_gpt_vis

content = '''
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.

\`\`\`vis-chart
{"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}]}
\`\`\`
'''

set_gpt_vis(content)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants