GeminiAi commited on
Commit
4efd16c
·
verified ·
1 Parent(s): 963e790

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -17
app.py CHANGED
@@ -1,26 +1,36 @@
1
- # app.py
2
  import gradio as gr
3
  from crew import LatestAiDevelopmentCrew
4
 
5
- def generate_report(topic):
6
- # Pass the input topic to the crew
7
  inputs = {'topic': topic}
8
  crew = LatestAiDevelopmentCrew()
9
- crew_output = crew.crew().kickoff(inputs=inputs)
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- # Assuming the crew generates a report saved as 'report.md'
12
- with open('report.md', 'r') as file:
13
- report = file.read()
 
14
 
15
- return report
 
 
16
 
17
- # Gradio Interface
18
- iface = gr.Interface(
19
- fn=generate_report,
20
- inputs="text", # Topic input as text box
21
- outputs="markdown", # Display the report as markdown
22
- live=True
23
- )
24
 
25
- # Launch the Gradio app
26
- iface.launch()
 
 
1
  import gradio as gr
2
  from crew import LatestAiDevelopmentCrew
3
 
4
+ def run_research(topic: str):
5
+ # Run the crew process with the given topic
6
  inputs = {'topic': topic}
7
  crew = LatestAiDevelopmentCrew()
8
+ result = crew.crew().kickoff(inputs=inputs) # Assuming it returns a result
9
+ return result
10
+
11
+ def clear_input():
12
+ return "", "" # Clear the inputs and output
13
+
14
+ # Gradio UI layout
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown("## Latest AI Development Research")
17
+
18
+ # Topic Input Section
19
+ with gr.Row():
20
+ topic_input = gr.Textbox(label="Enter Topic", placeholder="Enter a topic for AI research...", lines=1)
21
 
22
+ # Submit and Clear Buttons Section
23
+ with gr.Row():
24
+ submit_button = gr.Button("Submit")
25
+ clear_button = gr.Button("Clear")
26
 
27
+ # Output Section to show research results
28
+ with gr.Row():
29
+ output = gr.Textbox(label="Research Result", placeholder="Research results will appear here.", interactive=False, lines=5)
30
 
31
+ # Connect functions to the interface
32
+ submit_button.click(run_research, inputs=topic_input, outputs=output)
33
+ clear_button.click(clear_input, inputs=[], outputs=[topic_input, output])
 
 
 
 
34
 
35
+ # Launch the interface
36
+ demo.launch()