qiqiWav commited on
Commit
e870413
1 Parent(s): 0131ea5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -0
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gradio_huggingfacehub_search import HuggingfaceHubSearch
3
+ import requests
4
+
5
+ processed_inputs = {}
6
+
7
+ def process_inputs(model_id, q_method, email, oauth_token: gr.OAuthToken | None):
8
+ print(f"model_iddddddd: {model_id}")
9
+ print(f"q_methodddddd: {q_method}")
10
+ print(f"emailllllll: {email}")
11
+ print(f"oauth_tokennnnn: {oauth_token}")
12
+ if oauth_token is None or oauth_token.token is None:
13
+ raise ValueError("You must be logged in to use this service.")
14
+
15
+ if not model_id or not q_method or not email:
16
+ return "All fields are required!"
17
+
18
+ input_hash = hash((model_id, q_method, email, oauth_token.token))
19
+
20
+ if input_hash in processed_inputs and processed_inputs[input_hash] == 200:
21
+ return "This request has already been submitted successfully. Please do not submit the same request multiple times."
22
+
23
+ url = "https://sdk.nexa4ai.com/task"
24
+
25
+ data = {
26
+ "model_id": model_id,
27
+ "q_method": q_method,
28
+ "email": email,
29
+ "oauth_token": oauth_token.token
30
+ }
31
+ print(f"dataaaaa: {data}")
32
+
33
+ response = requests.post(url, json=data)
34
+
35
+ if response.status_code == 200:
36
+ processed_inputs[input_hash] = 200
37
+ 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."
38
+ else:
39
+ processed_inputs[input_hash] = response.status_code
40
+ return f"Failed to submit request: {response.text}"
41
+
42
+ iface = gr.Interface(
43
+ fn=process_inputs,
44
+ inputs=[
45
+ HuggingfaceHubSearch(
46
+ label="Hub Model ID",
47
+ placeholder="Search for model id on Huggingface",
48
+ search_type="model",
49
+ ),
50
+ gr.Dropdown(
51
+ ["Q2_K", "Q3_K_S", "Q3_K_M", "Q3_K_L", "Q4_0", "Q4_K_S", "Q4_K_M", "Q5_0", "Q5_K_S", "Q5_K_M", "Q6_K", "Q8_0"],
52
+ label="Quantization Method",
53
+ info="GGML quantisation type",
54
+ value="Q4_K_M",
55
+ filterable=False
56
+ ),
57
+ gr.Textbox(label="Email", placeholder="Enter your email here")
58
+ ],
59
+ outputs=gr.Markdown(label="output", value="Please enter the model URL, select a quantization method, and provide your email address.",),
60
+ title="Create your own GGUF Quants, blazingly fast ⚡!",
61
+ allow_flagging="never"
62
+ )
63
+
64
+ theme = gr.themes.Base()
65
+ with gr.Blocks(theme=theme) as demo:
66
+ gr.Markdown("You must be logged in to use this service.")
67
+ gr.LoginButton(min_width=250)
68
+ iface.render()
69
+
70
+ demo.launch(share=True)
71
+