Spaces:
Sleeping
Sleeping
import gradio as gr | |
import requests | |
# Set your Hugging Face API key here | |
API_KEY = "your_huggingface_api_key" | |
def generate_text(input_text): | |
added_lines = [] | |
for line in input_text.split('\n'): | |
if line.startswith('+') and not line.startswith('+++'): | |
added_line = line[1:] # Remove the '+' sign | |
if sum(len(l) + 1 for l in added_lines) + len(added_line) <= 2000: | |
added_lines.append(added_line) | |
else: | |
return "Input too long. Please try again." | |
break | |
return '\n'.join(added_lines) | |
def analyze_sentiment(input_text): | |
return input_text | |
def echo_text(input_text): | |
return input_text | |
# Define the Gradio interface | |
interface1 = gr.Interface(fn=generate_text, inputs="text", outputs="text") | |
interface2 = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text") | |
interface3 = gr.Interface(fn=echo_text, inputs="text", outputs="text") | |
tabbed_interface = gr.TabbedInterface([interface1, interface2, interface3], ["Text Generation", "Sentiment Analysis", "Echo Text"]) | |
if __name__ == "__main__": | |
tabbed_interface.launch() |