Spaces:
Sleeping
Sleeping
import gradio as gr | |
import markdown | |
from main import run | |
# def run(field,since): | |
# result = f"hey {field},{since}" | |
# return result | |
# Create Gradio interface | |
def create_interface(): | |
with gr.Blocks(title="Tech News Agent", theme=gr.themes.Soft()) as app: | |
with gr.Column(scale=1): | |
gr.Markdown( | |
""" | |
# π Tech News Agent | |
This Agent will search, scrap and give comprehensive output about current Tech Update. | |
""" | |
) | |
# Input for Field/Topic | |
field = gr.Textbox( | |
label="Field", | |
placeholder="Your desired Field/Topic", | |
value="AI Agents" | |
) | |
# Note for Field | |
field_note = gr.Accordion("Note for Field", open=False) | |
with field_note: | |
gr.Markdown( | |
""" | |
Choose a specific area you're interested in. Must relate to Tech, like AI, Software Dev, Hardware, etc. | |
""" | |
) | |
# Input for Since | |
since = gr.Textbox( | |
label="Since", | |
placeholder="Number of days since the update (e.g., 5)", | |
value="10" | |
) | |
# Note for Since | |
since_note = gr.Accordion("Note for Since", open=False) | |
with since_note: | |
gr.Markdown( | |
""" | |
Enter the number of days ago you want updates from. | |
- **Example**: If you put "5," the agent will look for updates from the past 5 days. | |
- **Important**: If AI can't find any info from the "since" day, it will look for the most recent news. | |
""" | |
) | |
submit_btn = gr.Button( | |
"Evaluate Responses", | |
variant="primary", | |
size="lg" | |
) | |
# Using Textbox instead of Markdown for better formatting | |
output = gr.TextArea( | |
label="Evaluation Results", | |
show_copy_button=True | |
) | |
# Markdown output area | |
markdown_output = gr.Markdown( | |
label="Parsed Markdown Output", | |
elem_id="markdown_output" # optional: give an ID for styling if needed | |
) | |
# Button to parse the output to Markdown | |
parse_btn = gr.Button( | |
"Parse to Markdown", | |
variant="secondary" | |
) | |
submit_btn.click( | |
fn=run, | |
inputs=[field, since], | |
outputs=output | |
) | |
# Function to convert text area output to Markdown | |
def parse_to_markdown(text): | |
return markdown.markdown(text) | |
parse_btn.click( | |
fn=parse_to_markdown, | |
inputs=output, | |
outputs=markdown_output | |
) | |
return app | |
if __name__ == "__main__": | |
app = create_interface() | |
app.launch(share=True) | |