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

Add Data Explorer Tab #3632

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
31 changes: 31 additions & 0 deletions .gradio/certificate.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5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-----END CERTIFICATE-----
57 changes: 49 additions & 8 deletions fastchat/serve/gradio_web_server_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"""

import argparse
import pickle
import time
from typing import List

import gradio as gr

from fastchat.serve.gradio_block_arena_anony import (
Expand Down Expand Up @@ -54,6 +50,41 @@
logger = build_logger("gradio_web_server_multi", "gradio_web_server_multi.log")


def build_visualizer():
visualizer_markdown = """
# 🔍 Arena Visualizer
Data explorer provides interactive tools to explore and draw insights from our leaderboard data.
"""
gr.Markdown(visualizer_markdown, elem_id="visualizer_markdown")

with gr.Tabs():
with gr.Tab("Topic Explorer", id=0):
topic_markdown = """
## *Welcome to the Topic Explorer*
This tool lets you dive into user-submitted prompts, organized into general
categories and detailed subcategories. Using the sunburst chart, you can easily
explore the data and understand how different topics are distributed.

### How to Use:
- Hover Over Segments: View the category name, the number of prompts, and their percentage.
- Click to Explore:
- Click on a main category to see its subcategories.
- Click on subcategories to see example prompts in the sidebar.
- Undo and Reset: Click the center of the chart to return to the top level.

Start exploring and discover interesting trends in the data!

"""
gr.Markdown(topic_markdown)

frame = """
<iframe width="100%" scrolling="no" style="height: 1400px; border: 1px solid lightgrey; border-radius: 10px;"
src="https://storage.googleapis.com/public-arena-no-cors/index.html">
</iframe>
"""
gr.HTML(frame)


def load_demo(context: Context, request: gr.Request):
ip = get_ip(request)
logger.info(f"load_demo. ip: {ip}. params: {request.query_params}")
Expand Down Expand Up @@ -199,12 +230,14 @@ def build_demo(
arena_hard_table,
show_plot=True,
)
if args.show_visualizer:
with gr.Tab("🔍 Arena Visualizer", id=5):
build_visualizer()

with gr.Tab("ℹ️ About Us", id=4):
about = build_about()
build_about()

context_state = gr.State(context)
url_params = gr.JSON(visible=False)

if args.model_list_mode not in ["once", "reload"]:
raise ValueError(f"Unknown model list mode: {args.model_list_mode}")
Expand Down Expand Up @@ -271,7 +304,8 @@ def build_demo(
parser.add_argument(
"--gradio-auth-path",
type=str,
help='Set the gradio authentication file path. The file should contain one or more user:password pairs in this format: "u1:p1,u2:p2,u3:p3"',
help='Set the gradio authentication file path. The file should contain one or \
more user:password pairs in this format: "u1:p1,u2:p2,u3:p3"',
default=None,
)
parser.add_argument(
Expand All @@ -286,7 +320,8 @@ def build_demo(
parser.add_argument(
"--gradio-root-path",
type=str,
help="Sets the gradio root path, eg /abc/def. Useful when running behind a reverse-proxy or at a custom URL path prefix",
help="Sets the gradio root path, eg /abc/def. Useful when running behind a \
reverse-proxy or at a custom URL path prefix",
)
parser.add_argument(
"--ga-id",
Expand All @@ -305,6 +340,12 @@ def build_demo(
type=str,
help="Set the password for the gradio web server",
)
parser.add_argument(
"--show-visualizer",
action="store_true",
default=False,
help="Show the Data Visualizer tab",
)
args = parser.parse_args()
logger.info(f"args: {args}")

Expand Down
Loading