File size: 3,797 Bytes
e870413
 
 
 
 
70606a9
 
c2762f8
d5aff04
e870413
 
d5aff04
e870413
3d32c38
e870413
 
d5aff04
e870413
9138245
e870413
9138245
c20511b
bb3929c
 
e870413
bb3929c
e870413
2dcf85f
 
 
 
 
 
 
 
 
 
 
9138245
e870413
 
 
d5aff04
e870413
 
d5aff04
e870413
 
 
 
 
 
 
 
 
 
3320e1a
 
 
 
e870413
 
 
 
a48cd85
 
2612952
a48cd85
e870413
 
 
2f24e2c
8ae9883
2dcf85f
 
2f24e2c
2dcf85f
 
 
e870413
70606a9
e870413
2dcf85f
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 gradio as gr
from gradio_huggingfacehub_search import HuggingfaceHubSearch
import requests


processed_inputs = {}
def process_inputs(model_id, q_method, email, oauth_token: gr.OAuthToken | None, profile: gr.OAuthProfile | None):
    if oauth_token is None or oauth_token.token is None or profile.username is None:
        return "#### You must be logged in to use this service."

    if not model_id or not q_method or not email:
        return "#### All fields are required!"
    
    input_hash = hash((model_id, q_method, oauth_token.token, profile.username))

    if input_hash in processed_inputs and processed_inputs[input_hash] == 200:
        return "#### Oops! 😲 Looks like you've already submitted this task πŸš€. Please hang tight! We'll send you an email with all the details once it's ready πŸ’Œ. Thanks for your patience! 😊"

    url = "https://sdk.nexa4ai.com/task"

    data = {
        "repository_url": f"https://huggingface.co/{model_id}",
        "username": profile.username,
        "access_token": oauth_token.token,
        "email": email,
        "quantization_option": q_method,
    }
    """
        # OAuth Token Information:
        # - This is an OAuth token, not a user's password.
        # - We need the OAuth token to clone the related repository and access its contents.
        # - As mentioned in the README.md, only read permission is requested, which includes:
        #   - Read access to your public profile
        #   - Read access to the content of all your public repos
        # - The token expires after 60 minutes.
        # - For more information about OAuth, please refer to the official documentation:
        #   https://huggingface.co/docs/hub/en/spaces-oauth
    """  
    response = requests.post(url, json=data)
    
    if response.status_code == 200:
        processed_inputs[input_hash] = 200  
        return "#### Your request has been submitted successfully! 🌟 We'll notify you by email πŸ“§ once everything is processed. 😊"
    else:
        processed_inputs[input_hash] = response.status_code 
        return f"#### Failed to submit request: {response.text}"

iface = gr.Interface(
    fn=process_inputs,
    inputs=[
        HuggingfaceHubSearch(
            label="Hub Model ID",
            placeholder="Search for model id on Huggingface",
            search_type="model",
        ),
        gr.Dropdown(
            ["q2_K", "q3_K", "q3_K_S", "q3_K_M", "q3_K_L", "q4_0", "q4_1", "q4_K", "q4_K_S", "q4_K_M", "q5_0", "q5_1", "q5_K", "q5_K_S", "q5_K_M", "q6_K", "q8_0", "f16"],
            label="Quantization Option",
            info="GGML quantisation options",
            value="q4_0",
            filterable=False
        ),
        gr.Textbox(label="Email", placeholder="Enter your email here")
    ],
    outputs = gr.Markdown(
        label="output", 
        value="#### Please enter the model URL, select a quantization method, and provide your email address."
    ),
    allow_flagging="never"
)

theme = gr.themes.Soft(text_size="lg", spacing_size="lg")
with gr.Blocks(theme=theme) as demo:
    with gr.Row(variant="panel'"):
        gr.Markdown(value="## πŸš€ Unleash the Power of Custom GGML Quantized Models! ⚑"),
        gr.LoginButton(min_width=380)

    gr.Markdown(value="🚨 **IMPORTANT:** You **MUST** grant access to the model repository before use.")
    gr.Markdown(value="πŸ”” You **MUST** be logged in to use this service.")
    iface.render()
    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.")

demo.launch(share=True)