qiqiWav commited on
Commit
2dcf85f
β€’
1 Parent(s): 70606a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -26
app.py CHANGED
@@ -2,31 +2,19 @@ import gradio as gr
2
  from gradio_huggingfacehub_search import HuggingfaceHubSearch
3
  import requests
4
 
5
- """
6
- # OAuth Token Information:
7
- # - This is an OAuth token, not a user's password.
8
- # - We need the OAuth token to clone the related repository and access its contents.
9
- # - As mentioned in the README.md, only read permission is requested, which includes:
10
- # - Read access to your public profile
11
- # - Read access to the content of all your public repos
12
- # - The token expires after 60 minutes.
13
- # - For more information about OAuth, please refer to the official documentation:
14
- # https://huggingface.co/docs/hub/en/spaces-oauth
15
- """
16
-
17
 
18
  processed_inputs = {}
19
  def process_inputs(model_id, q_method, email, oauth_token: gr.OAuthToken | None, profile: gr.OAuthProfile | None):
20
  if oauth_token is None or oauth_token.token is None or profile.username is None:
21
- return "#### You must be logged in to use this service."
22
 
23
  if not model_id or not q_method or not email:
24
- return "#### All fields are required!"
25
 
26
  input_hash = hash((model_id, q_method, oauth_token.token, profile.username))
27
 
28
  if input_hash in processed_inputs and processed_inputs[input_hash] == 200:
29
- return "#### This request has already been submitted successfully. Please do not submit the same request multiple times."
30
 
31
  url = "https://sdk.nexa4ai.com/task"
32
 
@@ -37,15 +25,25 @@ def process_inputs(model_id, q_method, email, oauth_token: gr.OAuthToken | None,
37
  "email": email,
38
  "quantization_option": q_method,
39
  }
40
-
 
 
 
 
 
 
 
 
 
 
41
  response = requests.post(url, json=data)
42
 
43
  if response.status_code == 200:
44
  processed_inputs[input_hash] = 200
45
- return "#### Your request has been submitted successfully. We will notify you by email once processing is complete. There is no need to submit the same request multiple times."
46
  else:
47
  processed_inputs[input_hash] = response.status_code
48
- return f"#### Failed to submit request: {response.text}"
49
 
50
  iface = gr.Interface(
51
  fn=process_inputs,
@@ -66,19 +64,20 @@ iface = gr.Interface(
66
  ],
67
  outputs = gr.Markdown(
68
  label="output",
69
- value="#### Please enter the model URL, select a quantization method, and provide your email address."
70
  ),
71
  allow_flagging="never"
72
  )
73
 
74
- theme = gr.themes.Base(text_size="lg")
75
  with gr.Blocks(theme=theme) as demo:
76
- gr.Markdown(value="# πŸš€ Unleash the Power of Custom GGML Quantized Models! ⚑")
77
- gr.LoginButton(min_width=300)
78
- gr.Markdown(value="### πŸ”” You must be logged in to use this service.")
79
- gr.Markdown(value="### 🚨 IMPORTANT: You must grant access to the model repository before use.")
 
 
80
  iface.render()
81
  gr.Markdown(value="We sincerely thank our community members, [Perry](https://huggingface.co/PerryCheng614), [Brian](https://huggingface.co/JoyboyBrian), [Qi](https://huggingface.co/qiqiWav), [David](https://huggingface.co/Davidqian123), for their extraordinary contributions to this GGUF converter project.")
82
 
83
- demo.launch(share=True)
84
-
 
2
  from gradio_huggingfacehub_search import HuggingfaceHubSearch
3
  import requests
4
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  processed_inputs = {}
7
  def process_inputs(model_id, q_method, email, oauth_token: gr.OAuthToken | None, profile: gr.OAuthProfile | None):
8
  if oauth_token is None or oauth_token.token is None or profile.username is None:
9
+ return " You must be logged in to use this service."
10
 
11
  if not model_id or not q_method or not email:
12
+ return " All fields are required!"
13
 
14
  input_hash = hash((model_id, q_method, oauth_token.token, profile.username))
15
 
16
  if input_hash in processed_inputs and processed_inputs[input_hash] == 200:
17
+ return " This request has already been submitted successfully. Please do not submit the same request multiple times."
18
 
19
  url = "https://sdk.nexa4ai.com/task"
20
 
 
25
  "email": email,
26
  "quantization_option": q_method,
27
  }
28
+ """
29
+ # OAuth Token Information:
30
+ # - This is an OAuth token, not a user's password.
31
+ # - We need the OAuth token to clone the related repository and access its contents.
32
+ # - As mentioned in the README.md, only read permission is requested, which includes:
33
+ # - Read access to your public profile
34
+ # - Read access to the content of all your public repos
35
+ # - The token expires after 60 minutes.
36
+ # - For more information about OAuth, please refer to the official documentation:
37
+ # https://huggingface.co/docs/hub/en/spaces-oauth
38
+ """
39
  response = requests.post(url, json=data)
40
 
41
  if response.status_code == 200:
42
  processed_inputs[input_hash] = 200
43
+ return " Your request has been submitted successfully. We will notify you by email once processing is complete. There is no need to submit the same request multiple times."
44
  else:
45
  processed_inputs[input_hash] = response.status_code
46
+ return f" Failed to submit request: {response.text}"
47
 
48
  iface = gr.Interface(
49
  fn=process_inputs,
 
64
  ],
65
  outputs = gr.Markdown(
66
  label="output",
67
+ value=" Please enter the model URL, select a quantization method, and provide your email address."
68
  ),
69
  allow_flagging="never"
70
  )
71
 
72
+ theme = gr.themes.Soft(text_size="lg")
73
  with gr.Blocks(theme=theme) as demo:
74
+ with gr.Row(variant="panel'"):
75
+ gr.Markdown(value="## πŸš€ Unleash the Power of Custom GGML Quantized Models! ⚑"),
76
+ gr.LoginButton(min_width=350)
77
+
78
+ gr.Markdown(value="🚨 **IMPORTANT:** You **MUST** grant access to the model repository before use.")
79
+ gr.Markdown(value="πŸ”” You **MUST** be logged in to use this service.")
80
  iface.render()
81
  gr.Markdown(value="We sincerely thank our community members, [Perry](https://huggingface.co/PerryCheng614), [Brian](https://huggingface.co/JoyboyBrian), [Qi](https://huggingface.co/qiqiWav), [David](https://huggingface.co/Davidqian123), for their extraordinary contributions to this GGUF converter project.")
82
 
83
+ demo.launch(share=True)