Spaces:
Sleeping
Sleeping
File size: 1,156 Bytes
964d3aa 84e65f7 964d3aa 84e65f7 964d3aa 0c7d341 964d3aa 4701079 |
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 |
import gradio as gr
import requests
# Set your Hugging Face API key here
API_KEY = "your_huggingface_api_key"
def unified_function(operation, input_text):
if operation == "Text Generation":
return "gen" + input_text
elif operation == "Sentiment Analysis":
return "sent" + input_text
elif operation == "Echo Text":
return "echo" + input_text
def huggingface_login(api_key):
API_KEY = api_key
return "success!"
# Create the Gradio interface
interface = gr.Interface(
fn=unified_function,
inputs=[
gr.Dropdown(["Text Generation", "Sentiment Analysis", "Echo Text"], label="Select Operation"),
gr.Textbox(label="Input Text")
],
outputs="text",
title="Unified Interface for Multiple Functions",
description="Select an operation from the dropdown and input text to see the result."
)
huggingface_interface = gr.Interface(
fn=huggingface_login,
inputs=gr.Textbox(lines=1, label="API Key"),
outputs = "text"
)
tabbed_interface = gr.TabbedInterface([huggingface_interface, interface], ["Login", "Main"])
if __name__ == "__main__":
tabbed_interface.launch() |