Skip to content

Commit

Permalink
refactor: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Nov 15, 2024
1 parent 2794a9d commit 11207f5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions bindings/streamlit-gpt-vis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pip install streamlit-gpt-vis
```python
import streamlit as st

from streamlit_gpt_vis import gpt_vis_renderer
from streamlit_gpt_vis import set_gpt_vis

content = '''
# GPT-VIS \n\nComponents for GPTs, generative AI, and LLM projects. Not only UI Components.
Expand All @@ -27,14 +27,14 @@ Here’s a visualization of Haidilao's food delivery revenue from 2013 to 2022.
\`\`\`
'''

gpt_vis_renderer(content, config=None)
set_gpt_vis(content)
```

## API

### gpt_vis_renderer(content: str, config: dict = None)
### `set_gpt_vis(content: str, config: dict = None)`

- content: Markdown content
- content:Markdown content
- config: GPT-Vis [ConfigProvider](https://github.com/antvis/GPT-Vis/blob/main/src/ConfigProvider/index.md) config

## License
Expand Down
8 changes: 4 additions & 4 deletions bindings/streamlit-gpt-vis/example/basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import streamlit as st
from streamlit_gpt_vis import gpt_vis_renderer
from streamlit_gpt_vis import set_gpt_vis

# Add some test code to play with the component while it's in development.
# During development, we can run this just as we would any other Streamlit
Expand All @@ -9,7 +9,7 @@

# Create an instance of our component with a constant `content` arg, and
# print its output value.
gpt_vis_renderer('''
set_gpt_vis('''
# 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.
Expand All @@ -27,7 +27,7 @@

st.subheader("Component with vis text")

gpt_vis_renderer('''
set_gpt_vis('''
<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>大关。
''')

Expand All @@ -46,4 +46,4 @@
# "content" argument without having it get recreated.
content_input = st.text_input("Enter render content", value="#### GPT-VIS \n\n Components for GPTs, generative AI, and LLM projects. Not only UI Components.")

gpt_vis_renderer(content_input, config={'plot': { 'theme': { 'type': 'academy' }}})
set_gpt_vis(content_input, config={'plot': { 'theme': { 'type': 'academy' }}})
2 changes: 1 addition & 1 deletion bindings/streamlit-gpt-vis/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
here = os.path.abspath(os.path.dirname(__file__))

__title__ = "streamlit-gpt-vis"
__version__ = "0.0.1"
__version__ = "0.0.2"

this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()
Expand Down
6 changes: 3 additions & 3 deletions bindings/streamlit-gpt-vis/streamlit_gpt_vis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# We give the component a simple, descriptive name ("my_component"
# does not fit this bill, so please choose something better for your
# own component :)
"gpt_vis_renderer",
"set_gpt_vis",
# Pass `url` here to tell Streamlit that the component will be served
# by the local dev server that you run via `npm run start`.
# (This is useful while your component is in development.)
Expand All @@ -35,15 +35,15 @@
# build directory:
parent_dir = os.path.dirname(os.path.abspath(__file__))
build_dir = os.path.join(parent_dir, "frontend/dist")
_component_func = components.declare_component("gpt_vis_renderer", path=build_dir)
_component_func = components.declare_component("set_gpt_vis", path=build_dir)


# Create a wrapper function for the component. This is an optional
# best practice - we could simply expose the component function returned by
# `declare_component` and call it done. The wrapper allows us to customize
# our component's API: we can pre-process its input args, post-process its
# output value, and add a docstring for users.
def gpt_vis_renderer(content, config=None, key=None):
def set_gpt_vis(content, config=None, key=None):
"""Create a new instance of "my_component".
Parameters
Expand Down

0 comments on commit 11207f5

Please sign in to comment.