Spaces:
Sleeping
Sleeping
File size: 3,145 Bytes
465335c 576bacb 465335c 576bacb 465335c 2d5509f 576bacb 465335c 576bacb 465335c 2d5509f 576bacb 465335c 576bacb 465335c 576bacb 465335c 576bacb 465335c 576bacb |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
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)
|