File size: 1,806 Bytes
57e3831
 
9f4b1c6
 
 
 
 
 
 
 
57e3831
 
 
9f4b1c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57e3831
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
import gradio as gr

# Function to handle model inference with config
def generate_text(prompt, temperature, max_tokens):
    # Simulate model inference with config (replace with actual model call)
    response = f"Response to '{prompt}' with temperature={temperature} and max_tokens={max_tokens}"
    return response

# Gradio interface
with gr.Blocks() as demo:
    with gr.Sidebar():
        gr.Markdown("# Inference Provider")
        gr.Markdown("This Space showcases the deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct model, served by the nebius API. Sign in with your Hugging Face account to use this API.")
        token_input = gr.Textbox(label="Hugging Face Token", type="password")
        login_button = gr.Button("Sign in")
        login_status = gr.Markdown("")

        # Model configuration
        gr.Markdown("### Model Configuration")
        temperature = gr.Slider(0.1, 1.0, value=0.7, label="Temperature")
        max_tokens = gr.Slider(10, 500, value=100, label="Max Tokens")

    # Input and output components
    with gr.Column():
        prompt = gr.Textbox(label="Your Prompt")
        output = gr.Textbox(label="Model Response")
        generate_button = gr.Button("Generate")

    # Load the model
    model_interface = gr.load("models/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", provider="nebius")

    # Handle login (example logic)
    def handle_login(token):
        if token:  # Replace with actual authentication logic
            return "Logged in successfully!"
        else:
            return "Please enter a valid token."

    # Handle text generation
    generate_button.click(generate_text, [prompt, temperature, max_tokens], output)

    # Handle login
    login_button.click(handle_login, inputs=token_input, outputs=login_status)

# Launch the app
demo.launch()