smfaiz commited on
Commit
9205504
·
verified ·
1 Parent(s): 903a89c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -25
app.py CHANGED
@@ -1,13 +1,8 @@
1
  # -*- coding: utf-8 -*-
2
  """AI-Powered Research Assistant for Scholars and Researchers.ipynb
3
-
4
- Automatically generated by Colab.
5
-
6
- Original file is located at
7
- https://colab.research.google.com/drive/1u8Qvn2TOmOr1hZ_BovZPUA3KCku31OXb
8
  """
9
 
10
- #pip install gradio requests transformers beautifulsoup4 python-docx torch
11
 
12
  """**Set Up the Environment:** Install the required libraries
13
 
@@ -140,7 +135,7 @@ def create_thesis_document(title, summary, citations):
140
  doc.add_paragraph(title, style='Title').alignment = 1 # Center alignment
141
  doc.add_paragraph() # Add empty line
142
 
143
- # Adding more title page details
144
  doc.add_paragraph('Thesis', style='Heading 1').alignment = 1
145
  doc.add_paragraph('Author Name', style='Normal').alignment = 1
146
  doc.add_paragraph('University Name', style='Normal').alignment = 1
@@ -160,32 +155,18 @@ def create_thesis_document(title, summary, citations):
160
  for citation in citations:
161
  doc.add_paragraph(citation, style='Normal')
162
 
163
- # Save Document
164
- # doc.save(f"Research_Document.docx")
165
-
166
  file_path = "Research_Document.docx"
167
  doc.save(file_path)
168
  return file_path
169
 
170
- # Example Usage
171
- # title = "Federated Learning\nA Comprehensive Study"
172
- # summary = "This thesis explores federated learning techniques including quantum natural gradient descent and their applications in various domains. Detailed analysis and results are provided."
173
- # citations = [
174
- # "Federated quantum natural gradient descent for quantum federated learning. DOI: https://doi.org/10.1016/b978-0-44-319037-7.00028-4",
175
- # "Federated Machine Learning for Systems Medicine. DOI: https://doi.org/10.14293/gof.23.06",
176
- # "Adversarial robustness in federated learning. DOI: https://doi.org/10.1016/b978-0-44-319037-7.00013-2"
177
- # ]
178
-
179
- # create_thesis_document(title, summary, citations)
180
-
181
  def research_assistant(research_topic, citation_style):
182
  """Main function to search, summarize, and generate citations."""
183
  if not research_topic:
184
  return "Please enter a research topic.", ["No summaries generated."], ["No citations generated."]
185
 
186
  # Character limit check
187
- if len(research_topic) > 75:
188
- return "Error: Research topic exceeds 75 characters.", [], []
189
 
190
  # Search for related articles using CrossRef
191
  articles, error = search_related_articles_crossref(research_topic)
@@ -225,7 +206,7 @@ def research_assistant(research_topic, citation_style):
225
  gr_interface = gr.Interface(
226
  fn=research_assistant,
227
  inputs=[
228
- gr.Textbox(label="Enter your research topic or question:", placeholder="Enter your research topic (max 75 characters)", lines=2),
229
  gr.Dropdown(choices=["APA", "MLA", "Chicago"], label="Choose a citation style:")
230
  ],
231
  outputs=[
@@ -238,4 +219,4 @@ gr_interface = gr.Interface(
238
  allow_flagging="never"
239
  )
240
 
241
- gr_interface.launch(debug=True)
 
1
  # -*- coding: utf-8 -*-
2
  """AI-Powered Research Assistant for Scholars and Researchers.ipynb
 
 
 
 
 
3
  """
4
 
5
+ #!pip install gradio requests transformers beautifulsoup4 python-docx torch
6
 
7
  """**Set Up the Environment:** Install the required libraries
8
 
 
135
  doc.add_paragraph(title, style='Title').alignment = 1 # Center alignment
136
  doc.add_paragraph() # Add empty line
137
 
138
+ # Adding title page details
139
  doc.add_paragraph('Thesis', style='Heading 1').alignment = 1
140
  doc.add_paragraph('Author Name', style='Normal').alignment = 1
141
  doc.add_paragraph('University Name', style='Normal').alignment = 1
 
155
  for citation in citations:
156
  doc.add_paragraph(citation, style='Normal')
157
 
 
 
 
158
  file_path = "Research_Document.docx"
159
  doc.save(file_path)
160
  return file_path
161
 
 
 
 
 
 
 
 
 
 
 
 
162
  def research_assistant(research_topic, citation_style):
163
  """Main function to search, summarize, and generate citations."""
164
  if not research_topic:
165
  return "Please enter a research topic.", ["No summaries generated."], ["No citations generated."]
166
 
167
  # Character limit check
168
+ if len(research_topic) > 150:
169
+ return "Error: Research topic exceeds 150 characters.", [], []
170
 
171
  # Search for related articles using CrossRef
172
  articles, error = search_related_articles_crossref(research_topic)
 
206
  gr_interface = gr.Interface(
207
  fn=research_assistant,
208
  inputs=[
209
+ gr.Textbox(label="Enter your research topic or question:", placeholder="Enter your research topic (max 150 characters)"),
210
  gr.Dropdown(choices=["APA", "MLA", "Chicago"], label="Choose a citation style:")
211
  ],
212
  outputs=[
 
219
  allow_flagging="never"
220
  )
221
 
222
+ gr_interface.launch()