|
import gradio as gr |
|
|
|
|
|
def generate_text(prompt, temperature, max_tokens): |
|
|
|
response = f"Response to '{prompt}' with temperature={temperature} and max_tokens={max_tokens}" |
|
return response |
|
|
|
|
|
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("") |
|
|
|
|
|
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") |
|
|
|
|
|
with gr.Column(): |
|
prompt = gr.Textbox(label="Your Prompt") |
|
output = gr.Textbox(label="Model Response") |
|
generate_button = gr.Button("Generate") |
|
|
|
|
|
model_interface = gr.load("models/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", provider="nebius") |
|
|
|
|
|
def handle_login(token): |
|
if token: |
|
return "Logged in successfully!" |
|
else: |
|
return "Please enter a valid token." |
|
|
|
|
|
generate_button.click(generate_text, [prompt, temperature, max_tokens], output) |
|
|
|
|
|
login_button.click(handle_login, inputs=token_input, outputs=login_status) |
|
|
|
|
|
demo.launch() |