File size: 3,014 Bytes
f1f9b0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import os
import argparse
# from typing import Literal

import gradio as gr # type: ignore
# from sotopia_space.chat import chat_introduction, chat_tab, get_sotopia_profiles
from sotopia_space import benchmark
from ui_constants import CITATION_TEXT, BANNER


# OPENAI_KEY_FILE="./openai_api.key"
# if os.path.exists(OPENAI_KEY_FILE):
#     with open(OPENAI_KEY_FILE, "r") as f:
#         os.environ["OPENAI_API_KEY"] = f.read().strip()

# with open("./sotopia_space/_header.md", "r") as f:
#     HEADER_MD = f.read()

def navigation_bar():
    with gr.Column(scale=2):
        toggle_dark = gr.Button(value="Toggle Dark") 
    toggle_dark.click(
        None,
        js="""
        () => {
            if (document.body.classList.contains('dark')) {
            document.body.classList.remove('dark');
            document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary-light)';
            } else {
            document.body.classList.add('dark');
            document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary-dark)';
            }
        }
        """,
    )

with gr.Blocks(
    css="""#chat_container {height: 820px; width: 1000px; margin-left: auto; margin-right: auto;}
            #chatbot {height: 600px; overflow: auto;}
            #create_container {height: 750px; margin-left: 0px; margin-right: 0px;}
            #tokenizer_renderer span {white-space: pre-wrap}
            """,
    theme="gradio/monochrome",
) as demo:
    # with gr.Row():
    #     navigation_bar()
    # gr.Image(
    #         "images/banner.jpg", elem_id="banner-image", show_label=False
    #     )
    # gr.Markdown(HEADER_MD, elem_classes="markdown-text")
    with gr.Tabs(elem_classes="tab-buttons") as tabs:
        with gr.TabItem("πŸ… Leaderboard", elem_id="benchmark-tab-table", id=0):
            benchmark.benchmark_table()
        # with gr.TabItem("πŸ’¬ Chat", elem_id="chat-tab-interface", id=1): 
        #     with gr.Row():
        #         chat_introduction()
        #     with gr.Row():
        #         chat_tab()
    with gr.Row():
        with gr.Accordion("πŸ“™ Citation", open=False, elem_classes="accordion-label"):
            gr.Textbox(
                value=CITATION_TEXT, 
                lines=7,
                label="Copy the BibTeX snippet to cite this source",
                elem_id="citation-button",
                show_copy_button=True)

# def start_demo():
#     demo = main()
#     if DEPLOYED:
#         demo.queue(api_open=False).launch(show_api=False)
#     else:
#         demo.queue()
#         demo.launch(share=False, server_name="0.0.0.0")


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--result_file", help="Path to results table", default="data_dir\\bartscore_100_results.jsonl")
    #benchmark.original_df = pd.read_json(args.result_file, lines=True)
    # get_sotopia_profiles()
    # prepare_model(DEFAULT_MODEL_SELECTION)
    demo.launch()