anushkap01patidar commited on
Commit
099d502
·
1 Parent(s): 1561d5f

revert to last change

Browse files
Files changed (4) hide show
  1. README.md +33 -126
  2. app.py +7 -1
  3. orchestrator/research_orchestrator.py +23 -20
  4. requirements.txt +9 -25
README.md CHANGED
@@ -1,143 +1,50 @@
1
- ---
2
- title: AI Research Paper Generator
3
- emoji: 📚
4
- colorFrom: yellow
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 5.43.1
8
- app_file: app.py
9
- pinned: false
10
- short_description: AI-powered research paper generator for academic writing
11
- ---
12
 
13
- # 📚 AI Research Paper Generator
14
 
15
- An intelligent tool designed to assist researchers, students, and academics in generating comprehensive research paper structures, analyzing paper strength, and creating citations in multiple academic formats.
16
 
17
- ## 🚀 Features
 
 
 
18
 
19
- ### 📝 **Paper Structure Generation**
20
- - **Research Area Selection**: Choose from 10+ research domains including Machine Learning, Computer Vision, NLP, Robotics, and more
21
- - **AI-Powered Topic Generation**: Get intelligent topic suggestions based on your research area and keywords
22
- - **Comprehensive Outlines**: Generate complete paper structures with detailed sections and subsections
23
- - **Abstract Generation**: Create compelling abstracts that summarize your research focus
24
 
25
- ### 🔍 **Paper Strength Analysis**
26
- - **Content Assessment**: Analyze the completeness and strength of your research papers
27
- - **Scoring System**: Get a 1-10 score with detailed feedback
28
- - **Improvement Recommendations**: Receive specific suggestions for enhancing your paper
29
- - **Structure Analysis**: Identify missing sections and content gaps
 
30
 
31
- ### 📖 **Citation Generator**
32
- - **Multiple Formats**: Generate citations in APA, MLA, Chicago, IEEE, and Harvard styles
33
- - **Academic Standards**: Ensure your references meet publication requirements
34
- - **Easy Input**: Simple form-based citation creation
35
 
36
- ### 🎯 **Research Areas Supported**
37
- - Machine Learning & AI
38
- - Computer Vision
39
- - Natural Language Processing
40
- - Robotics & Automation
41
- - Data Science & Analytics
42
- - Cybersecurity
43
- - Quantum Computing
44
- - Bioinformatics
45
- - Climate Science
46
- - Economics & Social Sciences
47
 
48
- ## 🛠️ How to Use
49
 
50
- ### 1. **Generate Paper Structure**
51
- 1. Select your research area from the dropdown
52
- 2. Enter relevant keywords (comma-separated)
53
- 3. Choose your paper type (Research, Review, Survey, etc.)
54
- 4. Click "Generate Paper Structure"
55
- 5. Get a complete outline with abstract, methodology, and next steps
56
 
57
- ### 2. **Analyze Paper Strength**
58
- 1. Paste your existing paper content
59
- 2. Click "Analyze Paper"
60
- 3. Receive detailed feedback and improvement suggestions
61
- 4. Get a comprehensive score and recommendations
62
 
63
- ### 3. **Generate Citations**
64
- 1. Enter paper title, authors, year, and journal
65
- 2. Click "Generate Citations"
66
- 3. Copy citations in your preferred academic format
67
-
68
- ## 🔧 Technical Details
69
-
70
- - **Framework**: Gradio 5.43.1
71
- - **Language**: Python 3.8+
72
- - **Architecture**: Modular design with separate components for each functionality
73
- - **AI Integration**: Ready for integration with actual AI models (currently uses intelligent templates)
74
-
75
- ## 🚀 Getting Started
76
-
77
- ### Local Development
78
  ```bash
79
- # Clone the repository
80
- git clone <your-repo-url>
81
- cd Research_Draft_Generator
82
-
83
- # Install dependencies
84
- pip install -r requirements.txt
85
-
86
- # Run the application
87
- python app.py
88
  ```
89
 
90
- ### Hugging Face Spaces
91
- 1. **Fork this Space** to your Hugging Face account
92
- 2. **Customize** the app.py file as needed
93
- 3. **Deploy** automatically with Hugging Face's infrastructure
94
- 4. **Share** your Space with the research community
95
-
96
- ## 📊 Use Cases
97
-
98
- - **Students**: Generate research paper outlines for academic assignments
99
- - **Researchers**: Structure complex research projects and proposals
100
- - **Academics**: Analyze and improve existing papers before submission
101
- - **Writers**: Create citations in multiple formats for publications
102
- - **Educators**: Teach research methodology and paper structure
103
-
104
- ## 🔮 Future Enhancements
105
-
106
- - **Real AI Model Integration**: Connect with GPT, Claude, or other LLMs
107
- - **Multi-Language Support**: Generate papers in different languages
108
- - **Collaborative Features**: Multi-user paper editing and review
109
- - **Export Options**: PDF, LaTeX, and Word document generation
110
- - **Reference Management**: Integration with Zotero, Mendeley, etc.
111
- - **Plagiarism Detection**: Built-in content originality checking
112
-
113
- ## 🤝 Contributing
114
-
115
- We welcome contributions! Here's how you can help:
116
-
117
- 1. **Fork** the repository
118
- 2. **Create** a feature branch
119
- 3. **Make** your changes
120
- 4. **Test** thoroughly
121
- 5. **Submit** a pull request
122
-
123
- ## 📄 License
124
-
125
- This project is open source and available under the [MIT License](LICENSE).
126
-
127
- ## 🙏 Acknowledgments
128
-
129
- - Built with [Gradio](https://gradio.app/) for beautiful web interfaces
130
- - Inspired by the research community's need for better writing tools
131
- - Designed for academic excellence and research productivity
132
-
133
- ## 📞 Support
134
-
135
- - **Issues**: Report bugs and request features on GitHub
136
- - **Discussions**: Join community discussions about research writing
137
- - **Documentation**: Check our comprehensive guides and tutorials
138
 
139
- ---
140
 
141
- **Ready to revolutionize your research paper writing? Try the AI Research Paper Generator today! 🚀**
142
 
143
- *Built with ❤️ for the research community*
 
1
+ # Research Draft Generator
 
 
 
 
 
 
 
 
 
 
2
 
3
+ An AI-powered research paper generator that uses a multi-agent workflow to create comprehensive academic papers.
4
 
5
+ ## Features
6
 
7
+ - **Multi-Agent AI System**: Specialized agents for topic analysis, research retrieval, outline building, draft writing, and citation formatting
8
+ - **Human-in-the-Loop**: Interactive feedback system for outline review and approval
9
+ - **Automated Workflow**: Streamlined process from topic to final draft
10
+ - **PDF Export**: Generate downloadable PDFs of completed research papers
11
 
12
+ ## How It Works
 
 
 
 
13
 
14
+ 1. **Topic Input**: Enter your research topic
15
+ 2. **AI Analysis**: The system analyzes and refines your topic
16
+ 3. **Outline Generation**: Creates a structured research paper outline
17
+ 4. **Human Review**: You review and approve/revise the outline
18
+ 5. **Draft Generation**: AI generates the full research paper
19
+ 6. **PDF Export**: Download your completed paper
20
 
21
+ ## Technology Stack
 
 
 
22
 
23
+ - **AI Models**: OpenAI GPT-4 for natural language generation
24
+ - **Workflow Engine**: LangGraph for orchestrating multi-agent workflows
25
+ - **User Interface**: Gradio for web-based interaction
26
+ - **Document Generation**: ReportLab for PDF creation
 
 
 
 
 
 
 
27
 
28
+ ## Usage
29
 
30
+ 1. Enter your research topic in the input field
31
+ 2. Click "Generate Outline" to start the process
32
+ 3. Review the generated outline
33
+ 4. Approve, request revisions, or reject the outline
34
+ 5. Once approved, the system will generate the full draft
35
+ 6. Download your research paper as a PDF
36
 
37
+ ## Environment Variables
 
 
 
 
38
 
39
+ Set your OpenAI API key in the environment:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  ```bash
41
+ OPENAI_API_KEY=your_api_key_here
 
 
 
 
 
 
 
 
42
  ```
43
 
44
+ ## License
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ This project is for research and educational purposes.
47
 
48
+ ## Author
49
 
50
+ Anushka0007
app.py CHANGED
@@ -315,5 +315,11 @@ with gr.Blocks(css=css, title="Research Draft Generator") as demo:
315
 
316
 
317
  if __name__ == "__main__":
 
318
  port = int(os.getenv("PORT", 7860))
319
- demo.queue().launch(server_name="0.0.0.0", server_port=port)
 
 
 
 
 
 
315
 
316
 
317
  if __name__ == "__main__":
318
+ # Hugging Face Spaces provides PORT; bind to 0.0.0.0
319
  port = int(os.getenv("PORT", 7860))
320
+ demo.queue().launch(
321
+ server_name="0.0.0.0",
322
+ server_port=port,
323
+ share=False,
324
+ reload=False # Disable reload for production deployment
325
+ )
orchestrator/research_orchestrator.py CHANGED
@@ -545,20 +545,17 @@ class AStreamCallbackHandler(BaseCallbackHandler):
545
 
546
  def human_feedback_node(state: ResearchState) -> ResearchState:
547
  """
548
- Human feedback node using proper LangGraph interrupt mechanism
549
  """
550
- # Check if we have an outline to review
551
- if not state.get("outline"):
552
- state["outline_approved"] = False
553
- state["revision_feedback"] = "No outline available for review"
554
- return state
555
-
556
- # Set the state to indicate we're waiting for human feedback
557
- state["waiting_for_feedback"] = True
558
- state["workflow_status"] = "paused_for_feedback"
559
 
560
- # Return the state to trigger the interrupt in the workflow
561
- return state
562
 
563
 
564
  def process_human_feedback_inline(state: ResearchState, human_input: str) -> ResearchState:
@@ -569,8 +566,7 @@ def process_human_feedback_inline(state: ResearchState, human_input: str) -> Res
569
  feedback_text = str(human_input).strip()
570
  feedback_lower = feedback_text.lower()
571
 
572
- # Reset the waiting state
573
- state["waiting_for_feedback"] = False
574
 
575
  # Check for topic change requests
576
  topic_change_keywords = [
@@ -589,6 +585,7 @@ def process_human_feedback_inline(state: ResearchState, human_input: str) -> Res
589
  # Extract new topic from feedback
590
  new_topic = extract_new_topic_from_feedback(feedback_text)
591
  if new_topic:
 
592
  state["topic"] = new_topic
593
  state["refined_topic"] = None # Reset refined topic
594
  state["research_notes"] = None # Reset research notes
@@ -599,6 +596,7 @@ def process_human_feedback_inline(state: ResearchState, human_input: str) -> Res
599
  state["workflow_status"] = "topic_change"
600
  return state
601
  else:
 
602
  state["outline_approved"] = False
603
  state["revision_feedback"] = "Please specify the new topic you want to research"
604
  return state
@@ -607,11 +605,12 @@ def process_human_feedback_inline(state: ResearchState, human_input: str) -> Res
607
  if feedback_lower.startswith("approve") or feedback_lower in ["a"]:
608
  state["outline_approved"] = True
609
  state["feedback"] = ""
610
- state["workflow_status"] = "approved"
611
 
612
  elif feedback_lower.startswith("reject") or feedback_lower in ["r", "no", "n", "abort"]:
613
  state["outline_approved"] = False
614
  state["workflow_status"] = "aborted"
 
615
 
616
  elif feedback_lower.startswith("revise") or feedback_lower.startswith("v"):
617
  # Extract feedback from the input
@@ -630,6 +629,7 @@ def process_human_feedback_inline(state: ResearchState, human_input: str) -> Res
630
  # Extract new topic from the revision feedback
631
  new_topic = extract_new_topic_from_feedback(feedback)
632
  if new_topic:
 
633
  state["topic"] = new_topic
634
  state["refined_topic"] = None # Reset refined topic
635
  state["research_notes"] = None # Reset research notes
@@ -640,21 +640,24 @@ def process_human_feedback_inline(state: ResearchState, human_input: str) -> Res
640
  state["workflow_status"] = "topic_change"
641
  return state
642
  else:
 
643
  state["outline_approved"] = False
644
  state["revision_feedback"] = "Please specify the new topic you want to research"
645
  return state
646
  else:
647
- # Regular revision request
648
  state["outline_approved"] = False
649
  state["revision_feedback"] = feedback
650
- state["workflow_status"] = "revision_requested"
651
-
652
  else:
653
- # Unrecognized input
654
  state["outline_approved"] = False
655
- state["revision_feedback"] = f"Unrecognized input: '{feedback_text}'. Please use: approve, reject, or revise [feedback]"
656
 
657
  return state
 
 
658
  def extract_new_topic_from_feedback(feedback_text: str) -> str:
659
  """
660
  Extract new topic from feedback text using various patterns
 
545
 
546
  def human_feedback_node(state: ResearchState) -> ResearchState:
547
  """
548
+ Human feedback node using current LangGraph interrupt() function
549
  """
550
+ # Use the current LangGraph interrupt() function
551
+ # This will pause execution and wait for human input
552
+ human_input = interrupt(
553
+ "Please review the outline and provide your feedback. "
554
+ "Options: 'approve', 'revise [feedback]', or 'reject'"
555
+ )
 
 
 
556
 
557
+ # Process the human input directly in this node
558
+ return process_human_feedback_inline(state, human_input)
559
 
560
 
561
  def process_human_feedback_inline(state: ResearchState, human_input: str) -> ResearchState:
 
566
  feedback_text = str(human_input).strip()
567
  feedback_lower = feedback_text.lower()
568
 
569
+ # print(f"\n Processing human feedback: '{feedback_text}'")
 
570
 
571
  # Check for topic change requests
572
  topic_change_keywords = [
 
585
  # Extract new topic from feedback
586
  new_topic = extract_new_topic_from_feedback(feedback_text)
587
  if new_topic:
588
+ # print(f"🔄 Topic change detected! New topic: '{new_topic}'")
589
  state["topic"] = new_topic
590
  state["refined_topic"] = None # Reset refined topic
591
  state["research_notes"] = None # Reset research notes
 
596
  state["workflow_status"] = "topic_change"
597
  return state
598
  else:
599
+ # print("❌ Topic change requested but no new topic found. Please specify the new topic.")
600
  state["outline_approved"] = False
601
  state["revision_feedback"] = "Please specify the new topic you want to research"
602
  return state
 
605
  if feedback_lower.startswith("approve") or feedback_lower in ["a"]:
606
  state["outline_approved"] = True
607
  state["feedback"] = ""
608
+ # print(" Outline approved! Proceeding to draft writing...")
609
 
610
  elif feedback_lower.startswith("reject") or feedback_lower in ["r", "no", "n", "abort"]:
611
  state["outline_approved"] = False
612
  state["workflow_status"] = "aborted"
613
+ # print("Workflow aborted by user.")
614
 
615
  elif feedback_lower.startswith("revise") or feedback_lower.startswith("v"):
616
  # Extract feedback from the input
 
629
  # Extract new topic from the revision feedback
630
  new_topic = extract_new_topic_from_feedback(feedback)
631
  if new_topic:
632
+ # print(f"🔄 Topic change detected in revision feedback! New topic: '{new_topic}'")
633
  state["topic"] = new_topic
634
  state["refined_topic"] = None # Reset refined topic
635
  state["research_notes"] = None # Reset research notes
 
640
  state["workflow_status"] = "topic_change"
641
  return state
642
  else:
643
+ # print("❌ Topic change requested in revision but no new topic found.")
644
  state["outline_approved"] = False
645
  state["revision_feedback"] = "Please specify the new topic you want to research"
646
  return state
647
  else:
648
+ # Regular revision feedback
649
  state["outline_approved"] = False
650
  state["revision_feedback"] = feedback
651
+ # print(f" Revision requested with feedback: {feedback}")
652
+
653
  else:
654
+ # print(f" Invalid response: '{feedback_text}'. Defaulting to revision request.")
655
  state["outline_approved"] = False
656
+ state["revision_feedback"] = "Please improve the outline structure and content"
657
 
658
  return state
659
+
660
+
661
  def extract_new_topic_from_feedback(feedback_text: str) -> str:
662
  """
663
  Extract new topic from feedback text using various patterns
requirements.txt CHANGED
@@ -1,25 +1,9 @@
1
- gradio==5.43.1
2
- transformers
3
- torch
4
- numpy
5
- pandas
6
- scikit-learn
7
- matplotlib
8
- seaborn
9
- plotly
10
- streamlit
11
- langchain
12
- openai
13
- langchain-community
14
- langchain-openai
15
- anthropic
16
- tiktoken
17
- python-dotenv
18
- requests
19
- beautifulsoup4
20
- markdown
21
- fastapi
22
- uvicorn
23
- pydantic>=2
24
- langgraph>=0.2.30
25
- reportlab
 
1
+ gradio>=4.0.0
2
+ langgraph>=0.2.0
3
+ langchain>=0.2.0
4
+ langchain-openai>=0.2.0
5
+ openai>=1.0.0
6
+ python-dotenv>=1.0.0
7
+ reportlab>=4.0.0
8
+ asyncio
9
+ typing