anushkap01patidar commited on
Commit
a656e6b
·
1 Parent(s): e573987

connecting backend now

Browse files
Files changed (1) hide show
  1. app.py +66 -7
app.py CHANGED
@@ -6,22 +6,81 @@ import gradio as gr
6
  load_dotenv()
7
 
8
  def simple_interface():
9
- """Create the most basic possible Gradio interface"""
10
  with gr.Blocks(title="Research Draft Generator") as demo:
11
  gr.Markdown("# Research Draft Generator")
12
  gr.Markdown("Enter a topic to generate a research paper outline and draft.")
13
 
14
- topic = gr.Textbox(label="Topic", placeholder="e.g., Federated learning for healthcare")
15
- start_btn = gr.Button("Generate Outline", variant="primary")
 
16
 
17
- output = gr.Textbox(label="Output", lines=10, interactive=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  def process_topic(topic_text):
20
  if not topic_text.strip():
21
- return "Please enter a topic."
22
- return f"Processing topic: {topic_text}\n\nThis is a placeholder response. The full functionality will be implemented once the interface is working."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- start_btn.click(process_topic, inputs=[topic], outputs=[output])
 
 
 
 
25
 
26
  return demo
27
 
 
6
  load_dotenv()
7
 
8
  def simple_interface():
9
+ """Create a working Gradio interface with basic workflow functionality"""
10
  with gr.Blocks(title="Research Draft Generator") as demo:
11
  gr.Markdown("# Research Draft Generator")
12
  gr.Markdown("Enter a topic to generate a research paper outline and draft.")
13
 
14
+ with gr.Row():
15
+ topic = gr.Textbox(label="Topic", placeholder="e.g., Federated learning for healthcare")
16
+ start_btn = gr.Button("Generate Outline", variant="primary")
17
 
18
+ status = gr.Textbox(label="Status", interactive=False)
19
+
20
+ with gr.Row():
21
+ with gr.Column():
22
+ gr.Markdown("### Generated Outline")
23
+ outline_display = gr.Textbox(label="Outline", lines=8, interactive=False)
24
+
25
+ with gr.Column():
26
+ gr.Markdown("### Generated Draft")
27
+ draft_display = gr.Textbox(label="Draft", lines=8, interactive=False)
28
+
29
+ with gr.Row():
30
+ feedback = gr.Textbox(label="Revision feedback", placeholder="What should be improved?")
31
+ approve = gr.Button("Approve", variant="primary")
32
+ revise = gr.Button("Request Revision")
33
+ reject = gr.Button("Reject", variant="secondary")
34
 
35
  def process_topic(topic_text):
36
  if not topic_text.strip():
37
+ return "Please enter a topic.", "", ""
38
+
39
+ # Simulate the workflow steps
40
+ status_msg = f"Processing topic: {topic_text}"
41
+ outline = f"""# Research Outline: {topic_text}
42
+
43
+ ## 1. Introduction
44
+ - Background and motivation
45
+ - Problem statement
46
+ - Research objectives
47
+
48
+ ## 2. Literature Review
49
+ - Current state of research
50
+ - Key methodologies
51
+ - Gaps in existing work
52
+
53
+ ## 3. Methodology
54
+ - Research approach
55
+ - Data collection methods
56
+ - Analysis techniques
57
+
58
+ ## 4. Expected Results
59
+ - Anticipated findings
60
+ - Potential contributions
61
+ - Future research directions
62
+
63
+ *This is a generated outline. Click 'Approve' to generate the full draft, or 'Request Revision' to modify.*"""
64
+
65
+ draft = ""
66
+ return status_msg, outline, draft
67
+
68
+ def approve_outline():
69
+ return "Outline approved! Generating full draft...", "", "Full research paper draft will be generated here. This feature will be implemented once the basic interface is fully stable."
70
+
71
+ def request_revision(feedback_text):
72
+ if not feedback_text.strip():
73
+ feedback_text = "general improvements"
74
+ return f"Revision requested: {feedback_text}", "Revised outline will be generated here based on your feedback.", ""
75
+
76
+ def reject_outline():
77
+ return "Outline rejected. Please start over with a new topic.", "", ""
78
 
79
+ # Wire the events
80
+ start_btn.click(process_topic, inputs=[topic], outputs=[status, outline_display, draft_display])
81
+ approve.click(approve_outline, outputs=[status, outline_display, draft_display])
82
+ revise.click(request_revision, inputs=[feedback], outputs=[status, outline_display, draft_display])
83
+ reject.click(reject_outline, outputs=[status, outline_display, draft_display])
84
 
85
  return demo
86