Alina Lozovskaya commited on
Commit
816857c
·
1 Parent(s): b975b7b

Add scopes for oauth

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. yourbench_space/app.py +11 -5
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
  title: YourBench Configuration
3
  emoji: 📊
4
- colorFrom: pink
5
- colorTo: indigo
6
  sdk: docker
7
  hf_oauth: true
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
1
  ---
2
  title: YourBench Configuration
3
  emoji: 📊
4
+ colorFrom: yellow
5
+ colorTo: green
6
  sdk: docker
7
  hf_oauth: true
8
+ hf_oauth_scopes:
9
+ - read-repos
10
+ - write-repos
11
+ - manage-repos
12
+ - inference-api
yourbench_space/app.py CHANGED
@@ -136,8 +136,8 @@ def populate_user_info(oauth_profile: gr.OAuthProfile = None, oauth_token: gr.OA
136
 
137
  def hello(profile: gr.OAuthProfile | None) -> str:
138
  if profile is None:
139
- return "I don't know you."
140
- return f"Hello {profile.name}"
141
 
142
  def update_hf_org_dropdown(oauth_token: gr.OAuthToken | None) -> str:
143
  if oauth_token is None:
@@ -146,6 +146,8 @@ def update_hf_org_dropdown(oauth_token: gr.OAuthToken | None) -> str:
146
  org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
147
  return gr.Dropdown(org_names, label="Organization")
148
 
 
 
149
  with gr.Blocks() as app:
150
  gr.Markdown("## YourBench Configuration")
151
  with gr.Row():
@@ -163,15 +165,19 @@ with gr.Blocks() as app:
163
  base_url = gr.Textbox(label="Base URL")
164
  api_key = gr.Textbox(label="API Key")
165
  max_concurrent_requests = gr.Dropdown([8, 16, 32], value=16, label="Max Concurrent Requests")
166
- config_output = gr.Code(label="Generated Config", language="yaml")
167
  preview_button = gr.Button("Generate Config")
168
- save_button = gr.Button("Save Config")
169
-
170
  preview_button.click(
171
  generate_config,
172
  inputs=[hf_org_dropdown, model_name, provider, base_url, api_key, max_concurrent_requests],
173
  outputs=config_output
174
  )
 
 
 
 
 
 
 
175
  save_button.click(save_config, inputs=[config_output], outputs=[gr.Textbox(label="Save Status")])
176
 
177
  with gr.Tab("Files"):
 
136
 
137
  def hello(profile: gr.OAuthProfile | None) -> str:
138
  if profile is None:
139
+ return "Please, login"
140
+ return f"Hi {profile.name}"
141
 
142
  def update_hf_org_dropdown(oauth_token: gr.OAuthToken | None) -> str:
143
  if oauth_token is None:
 
146
  org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
147
  return gr.Dropdown(org_names, label="Organization")
148
 
149
+ config_output = gr.Code(label="Generated Config", language="yaml")
150
+
151
  with gr.Blocks() as app:
152
  gr.Markdown("## YourBench Configuration")
153
  with gr.Row():
 
165
  base_url = gr.Textbox(label="Base URL")
166
  api_key = gr.Textbox(label="API Key")
167
  max_concurrent_requests = gr.Dropdown([8, 16, 32], value=16, label="Max Concurrent Requests")
 
168
  preview_button = gr.Button("Generate Config")
 
 
169
  preview_button.click(
170
  generate_config,
171
  inputs=[hf_org_dropdown, model_name, provider, base_url, api_key, max_concurrent_requests],
172
  outputs=config_output
173
  )
174
+
175
+ save_button = gr.Button("Save Config")
176
+ save_button.click(save_config, inputs=[config_output], outputs=[gr.Textbox(label="Save Status")])
177
+
178
+ with gr.Tab("Raw Configuration"):
179
+ config_output.render()
180
+ save_button = gr.Button("Save Config")
181
  save_button.click(save_config, inputs=[config_output], outputs=[gr.Textbox(label="Save Status")])
182
 
183
  with gr.Tab("Files"):