Spaces:
Sleeping
Sleeping
Add markdown test tab to verify Gradio works without HF API
Browse files12345653 unmodified lines60616263646566676869707172import gradio as grimport requestsimport jsondef classify_text_api(text, labels_str):"""Call the DeBERTa classifier API from the other space"""53 unmodified lines"""# π― Text Classification Test AppTest the DeBERTa-v3-large-mnli classifier API.This app connects to the DeBERTa classifier space to perform zero-shot text classification.""")with gr.Row():with gr.Column():classify_text_input = gr.Textbox(label="Text to Classify",1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575853 unmodified lines112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176import gradio as grimport requestsimport jsonfrom datetime import datetimedef format_markdown(text):"""Convert plain text to markdown formatted output for testing"""if not text:return "β Please enter some text to format"# Create a markdown formatted responseoutput = f"""# Markdown Test Output**Input received at:** {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}---## Original Text{text}---## Text Analysis- **Character count:** {len(text)}- **Word count:** {len(text.split())}- **Lines:** {len(text.splitlines())}---## Formatted Versions### Uppercase```{text.upper()}```### Lowercase```{text.lower()}```### Reversed```{text[::-1]}```---β **Status:** Gradio is working correctly without HF API!_This response was generated locally to test markdown formatting._"""return outputdef classify_text_api(text, labels_str):"""Call the DeBERTa classifier API from the other space"""53 unmodified lines"""# π― Text Classification Test AppTest the DeBERTa-v3-large-mnli classifier API and markdown formatting.**Features:**- π Markdown Formatter (local testing - no API required)- π€ AI Text Classification (calls DeBERTa API)""")with gr.Tab("π Markdown Test"):gr.Markdown("""### Markdown Formatter TestThis tab tests Gradio's markdown rendering **without** requiring the HF API.Enter any text to see it formatted in various ways.""")with gr.Row():with gr.Column():markdown_input = gr.Textbox(label="Input Text",placeholder="Enter any text to format...",lines=5,value="Hello! This is a test of markdown formatting in Gradio.")markdown_btn = gr.Button("Format as Markdown", variant="primary")with gr.Column():markdown_output = gr.Markdown(label="Formatted Output")markdown_btn.click(fn=format_markdown,inputs=markdown_input,outputs=markdown_output)gr.Examples(examples=[["The quick brown fox jumps over the lazy dog."],["Testing Gradio without HF API inference!"],["Line 1\nLine 2\nLine 3"],],inputs=markdown_input,outputs=markdown_output,fn=format_markdown,cache_examples=False)with gr.Tab("π€ AI Classification"):gr.Markdown("""### AI Text ClassificationThis tab calls the DeBERTa classifier API for zero-shot text classification.""")with gr.Row():with gr.Column():classify_text_input = gr.Textbox(label="Text to Classify",
app.py+107-3