rdune71 commited on
Commit
7274a1a
ยท
1 Parent(s): 6bd8bb5
Files changed (1) hide show
  1. app.py +111 -1
app.py CHANGED
@@ -741,4 +741,114 @@ def parse_analysis_sections(analysis_text):
741
  elif line.startswith("# Perspectives"):
742
  current_section = "Perspectives"
743
  continue
744
- elif line.startswith
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
741
  elif line.startswith("# Perspectives"):
742
  current_section = "Perspectives"
743
  continue
744
+ elif line.startswith("# Implications"):
745
+ current_section = "Implications"
746
+ continue
747
+ elif line.startswith("# Controversies"):
748
+ current_section = "Controversies"
749
+ continue
750
+
751
+ if current_section:
752
+ sections[current_section] += line + "\n"
753
+
754
+ return sections
755
+
756
+ def research_assistant(query, file, use_ddg, progress=gr.Progress()):
757
+ """Main entry point for the research assistant with streaming"""
758
+ logging.info(f"Research assistant called with query: {query}")
759
+ for step in orchestrator.run(query, file, use_ddg, progress):
760
+ yield step
761
+
762
+ # Create Gradio interface
763
+ with gr.Blocks(
764
+ css=custom_css,
765
+ title="Research Assistant",
766
+ head="""
767
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
768
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
769
+ <script>hljs.highlightAll();</script>
770
+ """
771
+ ) as demo:
772
+ gr.Markdown(f"""
773
+ <div class="header">
774
+ <h1 class="title">๐Ÿง  AI Research Assistant</h1>
775
+ <p class="subtitle">Your intelligent research companion</p>
776
+ <div class="version-info">๐Ÿงฌ Version: {VERSION['version']}</div>
777
+ </div>
778
+ """)
779
+
780
+ with gr.Row():
781
+ with gr.Column(scale=1):
782
+ with gr.Group(elem_classes=["card", "input-section"]):
783
+ gr.Markdown("### ๐Ÿ” Research Input")
784
+ query_input = gr.Textbox(
785
+ label="Research Query",
786
+ placeholder="Enter your research question...",
787
+ lines=3
788
+ )
789
+ file_upload = gr.File(
790
+ label="๐Ÿ“„ Upload Files (PDF, Images)",
791
+ file_types=[".pdf", ".png", ".jpg", ".jpeg"]
792
+ )
793
+ ddg_checkbox = gr.Checkbox(
794
+ label="Use DuckDuckGo Search (Alternative)",
795
+ value=False
796
+ )
797
+ submit_btn = gr.Button("Research", elem_classes=["btn-primary"])
798
+
799
+ with gr.Column(scale=2):
800
+ with gr.Group(elem_classes=["card", "output-section"]):
801
+ gr.Markdown("### ๐Ÿ“Š Analysis Results")
802
+
803
+ # Progress bar
804
+ progress_container = gr.HTML("""
805
+ <div class="progress-container">
806
+ <div class="progress-bar" id="progress-bar"></div>
807
+ </div>
808
+ """)
809
+
810
+ # Collapsible sections
811
+ with gr.Accordion("๐Ÿ” Overview", open=True):
812
+ overview = gr.Markdown()
813
+
814
+ with gr.Accordion("๐Ÿ“Š Key Findings", open=False):
815
+ findings = gr.Markdown()
816
+
817
+ with gr.Accordion("๐Ÿงญ Perspectives", open=False):
818
+ perspectives = gr.Markdown()
819
+
820
+ with gr.Accordion("๐Ÿ”ฎ Implications", open=False):
821
+ implications = gr.Markdown()
822
+
823
+ with gr.Accordion("โš ๏ธ Controversies", open=False):
824
+ controversies = gr.Markdown()
825
+
826
+ status_indicator = gr.HTML("""
827
+ <div class="status-indicator">
828
+ <div class="spinner"></div>
829
+ <span class="progress-text">Ready for your research query</span>
830
+ </div>
831
+ """)
832
+
833
+ submit_btn.click(
834
+ fn=research_assistant,
835
+ inputs=[query_input, file_upload, ddg_checkbox],
836
+ outputs=[overview, findings, perspectives, implications, controversies]
837
+ )
838
+
839
+ query_input.submit(
840
+ fn=research_assistant,
841
+ inputs=[query_input, file_upload, ddg_checkbox],
842
+ outputs=[overview, findings, perspectives, implications, controversies]
843
+ )
844
+
845
+ gr.Markdown("""
846
+ <div class="footer">
847
+ <p>Built with โค๏ธ for researchers worldwide</p>
848
+ <p><span class="highlight">Features:</span> File upload โ€ข Web search โ€ข Real-time analysis</p>
849
+ <p><strong>Note:</strong> The AI model server may take up to 4-5 minutes to start initially.</p>
850
+ </div>
851
+ """)
852
+
853
+ if __name__ == "__main__":
854
+ demo.launch(share=True)