saikanov commited on
Commit
576bacb
1 Parent(s): ff24ef9

Update src/tech_news/app.py

Browse files
Files changed (1) hide show
  1. src/tech_news/app.py +38 -13
src/tech_news/app.py CHANGED
@@ -2,6 +2,9 @@ import gradio as gr
2
  import markdown
3
  from main import run
4
 
 
 
 
5
 
6
  # Create Gradio interface
7
  def create_interface():
@@ -14,18 +17,18 @@ def create_interface():
14
  """
15
  )
16
 
17
- # Input for Field/Topic
18
  field = gr.Textbox(
19
  label="Field",
20
  placeholder="Your desired Field/Topic",
21
- value = "AI Agents"
22
  )
23
  # Note for Field
24
  field_note = gr.Accordion("Note for Field", open=False)
25
  with field_note:
26
  gr.Markdown(
27
  """
28
- Choose a specific area you're interested in. Must Related to Tech, like AI,Software Dev,Hardware,ect.
29
  """
30
  )
31
 
@@ -33,7 +36,7 @@ def create_interface():
33
  since = gr.Textbox(
34
  label="Since",
35
  placeholder="Number of days since the update (e.g., 5)",
36
- value = "10"
37
  )
38
  # Note for Since
39
  since_note = gr.Accordion("Note for Since", open=False)
@@ -42,7 +45,7 @@ def create_interface():
42
  """
43
  Enter the number of days ago you want updates from.
44
  - **Example**: If you put "5," the agent will look for updates from the past 5 days.
45
- - **Important**: If AI Can't find any info from the "since" day, it will look for the most recents news.
46
  """
47
  )
48
 
@@ -53,19 +56,41 @@ def create_interface():
53
  )
54
 
55
  # Using Textbox instead of Markdown for better formatting
56
- output = gr.Markdown(
57
  label="Evaluation Results",
58
  show_copy_button=True
59
  )
60
-
61
- submit_btn.click(
62
- fn=run,
63
- inputs=[field,since],
64
- outputs=output
65
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  return app
68
 
69
  if __name__ == "__main__":
70
  app = create_interface()
71
- app.launch(share=True)
 
2
  import markdown
3
  from main import run
4
 
5
+ # def run(field,since):
6
+ # result = f"hey {field},{since}"
7
+ # return result
8
 
9
  # Create Gradio interface
10
  def create_interface():
 
17
  """
18
  )
19
 
20
+ # Input for Field/Topic
21
  field = gr.Textbox(
22
  label="Field",
23
  placeholder="Your desired Field/Topic",
24
+ value="AI Agents"
25
  )
26
  # Note for Field
27
  field_note = gr.Accordion("Note for Field", open=False)
28
  with field_note:
29
  gr.Markdown(
30
  """
31
+ Choose a specific area you're interested in. Must relate to Tech, like AI, Software Dev, Hardware, etc.
32
  """
33
  )
34
 
 
36
  since = gr.Textbox(
37
  label="Since",
38
  placeholder="Number of days since the update (e.g., 5)",
39
+ value="10"
40
  )
41
  # Note for Since
42
  since_note = gr.Accordion("Note for Since", open=False)
 
45
  """
46
  Enter the number of days ago you want updates from.
47
  - **Example**: If you put "5," the agent will look for updates from the past 5 days.
48
+ - **Important**: If AI can't find any info from the "since" day, it will look for the most recent news.
49
  """
50
  )
51
 
 
56
  )
57
 
58
  # Using Textbox instead of Markdown for better formatting
59
+ output = gr.TextArea(
60
  label="Evaluation Results",
61
  show_copy_button=True
62
  )
63
+
64
+ # Markdown output area
65
+ markdown_output = gr.Markdown(
66
+ label="Parsed Markdown Output",
67
+ elem_id="markdown_output" # optional: give an ID for styling if needed
68
+ )
69
+
70
+ # Button to parse the output to Markdown
71
+ parse_btn = gr.Button(
72
+ "Parse to Markdown",
73
+ variant="secondary"
74
+ )
75
+
76
+ submit_btn.click(
77
+ fn=run,
78
+ inputs=[field, since],
79
+ outputs=output
80
+ )
81
+
82
+ # Function to convert text area output to Markdown
83
+ def parse_to_markdown(text):
84
+ return markdown.markdown(text)
85
+
86
+ parse_btn.click(
87
+ fn=parse_to_markdown,
88
+ inputs=output,
89
+ outputs=markdown_output
90
+ )
91
 
92
  return app
93
 
94
  if __name__ == "__main__":
95
  app = create_interface()
96
+ app.launch(share=True)