Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ from dataset_uploader import ParquetScheduler
|
|
| 7 |
# Setup #
|
| 8 |
##########
|
| 9 |
|
| 10 |
-
|
| 11 |
|
| 12 |
# only show an info the first time uploading to the hub
|
| 13 |
show_info = True
|
|
@@ -105,11 +105,11 @@ def setup_submission(system_prompt="", history=[], chat_format="sharegpt"):
|
|
| 105 |
return history
|
| 106 |
|
| 107 |
|
| 108 |
-
def save_sft_data(system_prompt="", history=[], sft_chat_format="sharegpt"):
|
| 109 |
"""
|
| 110 |
A function that pushes the data to the hub.
|
| 111 |
"""
|
| 112 |
-
|
| 113 |
# setup the info message to only show once
|
| 114 |
global show_info
|
| 115 |
scheduler = schedulers[f"sft-{sft_chat_format}"]
|
|
@@ -142,12 +142,12 @@ def save_sft_data(system_prompt="", history=[], sft_chat_format="sharegpt"):
|
|
| 142 |
|
| 143 |
|
| 144 |
def save_dpo_data(
|
| 145 |
-
system_prompt="", history=[], chosen="", rejected="", dpo_chat_format="sharegpt"
|
| 146 |
):
|
| 147 |
"""
|
| 148 |
A function that pushes the data to the hub.
|
| 149 |
"""
|
| 150 |
-
|
| 151 |
# setup the info message to only show once
|
| 152 |
global show_info
|
| 153 |
scheduler = schedulers[f"dpo-{dpo_chat_format}"]
|
|
@@ -201,7 +201,7 @@ def undo_chat(history):
|
|
| 201 |
# Interface #
|
| 202 |
##############
|
| 203 |
|
| 204 |
-
with gr.Blocks() as
|
| 205 |
gr.Markdown("<h1 style='text-align: center'>ShareGPT-Builder</h1>")
|
| 206 |
|
| 207 |
#### SFT ####
|
|
@@ -287,5 +287,19 @@ with gr.Blocks() as demo:
|
|
| 287 |
height="560px"
|
| 288 |
></iframe>""")
|
| 289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
if __name__ == "__main__":
|
| 291 |
demo.launch(debug=True, show_error=True)
|
|
|
|
| 7 |
# Setup #
|
| 8 |
##########
|
| 9 |
|
| 10 |
+
|
| 11 |
|
| 12 |
# only show an info the first time uploading to the hub
|
| 13 |
show_info = True
|
|
|
|
| 105 |
return history
|
| 106 |
|
| 107 |
|
| 108 |
+
def save_sft_data(system_prompt="", history=[], sft_chat_format="sharegpt", oauth_token: gr.OAuthToken | None):
|
| 109 |
"""
|
| 110 |
A function that pushes the data to the hub.
|
| 111 |
"""
|
| 112 |
+
contributor_username = whoami(oauth_token.token)["name"]
|
| 113 |
# setup the info message to only show once
|
| 114 |
global show_info
|
| 115 |
scheduler = schedulers[f"sft-{sft_chat_format}"]
|
|
|
|
| 142 |
|
| 143 |
|
| 144 |
def save_dpo_data(
|
| 145 |
+
system_prompt="", history=[], chosen="", rejected="", dpo_chat_format="sharegpt", oauth_token: gr.OAuthToken | None
|
| 146 |
):
|
| 147 |
"""
|
| 148 |
A function that pushes the data to the hub.
|
| 149 |
"""
|
| 150 |
+
contributor_username = whoami(oauth_token.token)["name"]
|
| 151 |
# setup the info message to only show once
|
| 152 |
global show_info
|
| 153 |
scheduler = schedulers[f"dpo-{dpo_chat_format}"]
|
|
|
|
| 201 |
# Interface #
|
| 202 |
##############
|
| 203 |
|
| 204 |
+
with gr.Blocks() as interface:
|
| 205 |
gr.Markdown("<h1 style='text-align: center'>ShareGPT-Builder</h1>")
|
| 206 |
|
| 207 |
#### SFT ####
|
|
|
|
| 287 |
height="560px"
|
| 288 |
></iframe>""")
|
| 289 |
|
| 290 |
+
|
| 291 |
+
def swap_visibilty(profile: gr.OAuthProfile | None):
|
| 292 |
+
return gr.update(elem_classes=["main_ui_logged_in"]) if profile else gr.update(elem_classes=["main_ui_logged_out"])
|
| 293 |
+
|
| 294 |
+
css = '''
|
| 295 |
+
.main_ui_logged_out{opacity: 0.3; pointer-events: none}
|
| 296 |
+
'''
|
| 297 |
+
|
| 298 |
+
with gr.Blocks(css=css) as demo:
|
| 299 |
+
gr.LoginButton()
|
| 300 |
+
with gr.Column(elem_classes="main_ui_logged_out") as main_ui:
|
| 301 |
+
interface.render()
|
| 302 |
+
demo.load(fn=swap_visibilty, outputs=main_ui)
|
| 303 |
+
|
| 304 |
if __name__ == "__main__":
|
| 305 |
demo.launch(debug=True, show_error=True)
|