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()