parthib07 commited on
Commit
adcd64b
Β·
verified Β·
1 Parent(s): 52513a8

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +78 -18
src/streamlit_app.py CHANGED
@@ -1,27 +1,87 @@
1
  import streamlit as st
2
- import os
3
- import json
4
- import sys
5
- from datetime import datetime, timedelta
6
- import base64
7
- import pandas as pd
8
- import pydeck as pdk
9
- import requests
10
  from paper import (
11
  literature_research_task, outline_task, draft_writing_task,
12
  citation_task, editing_task, chatbot_task,
13
  run_task
14
  )
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- import ast #μΆ”κ°€ μ‚½μž…, requirements: albumentations μΆ”κ°€
18
- script_repr = os.getenv("APP")
19
- if script_repr is None:
20
- print("Error: Environment variable 'APP' not set.")
21
- sys.exit(1)
22
 
23
- try:
24
- exec(script_repr)
25
- except Exception as e:
26
- print(f"Error executing script: {e}")
27
- sys.exit(1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
 
 
 
 
 
 
 
 
2
  from paper import (
3
  literature_research_task, outline_task, draft_writing_task,
4
  citation_task, editing_task, chatbot_task,
5
  run_task
6
  )
7
 
8
+ # Page config
9
+ st.set_page_config(
10
+ page_title="πŸ“˜ Academic Research Assistant",
11
+ layout="wide",
12
+ initial_sidebar_state="expanded"
13
+ )
14
+
15
+ # App title
16
+ st.title("πŸ“˜ Academic Research & Writing Assistant")
17
+ st.markdown(
18
+ """
19
+ Welcome to your AI-powered academic assistant! Choose a task from the sidebar,
20
+ enter your topic and keywords, and let the agents do the rest.
21
+ """
22
+ )
23
+
24
+ # Sidebar task selection
25
+ st.sidebar.header("πŸ”§ Task Selector")
26
+ task_choice = st.sidebar.radio(
27
+ "Select an academic task to perform:",
28
+ [
29
+ "Literature Review",
30
+ "Generate Paper Outline",
31
+ "Write Draft",
32
+ "Generate Citations",
33
+ "Edit Draft",
34
+ "Ask Chatbot"
35
+ ]
36
+ )
37
+
38
+ # Task mapping
39
+ task_map = {
40
+ "Literature Review": literature_research_task,
41
+ "Generate Paper Outline": outline_task,
42
+ "Write Draft": draft_writing_task,
43
+ "Generate Citations": citation_task,
44
+ "Edit Draft": editing_task,
45
+ "Ask Chatbot": chatbot_task,
46
+ }
47
 
48
+ # Inputs
49
+ st.subheader("πŸ” Input Details")
 
 
 
50
 
51
+ topic = st.text_input("Enter your research topic:", placeholder="e.g. Impact of AI in Healthcare")
52
+ keywords = st.text_input("Enter related keywords (comma-separated):", placeholder="e.g. AI, healthcare, diagnosis")
53
+
54
+ # Optional input for chatbot queries
55
+ query = ""
56
+ if task_choice == "Ask Chatbot":
57
+ query = st.text_area("Ask your question:", placeholder="e.g. How to format a research abstract?")
58
+
59
+ # Action button
60
+ if st.button("πŸš€ Run Agent"):
61
+ if not topic and task_choice != "Ask Chatbot":
62
+ st.warning("Please enter a topic for the selected task.")
63
+ elif task_choice == "Ask Chatbot" and not query:
64
+ st.warning("Please enter a chatbot query.")
65
+ else:
66
+ with st.spinner("Agent is working on your task..."):
67
+ # Format input text based on task type
68
+ input_text = (
69
+ query if task_choice == "Ask Chatbot"
70
+ else f"Topic: {topic}\nKeywords: {keywords}"
71
+ )
72
+ result = run_task(task_map[task_choice], input_text)
73
+
74
+ st.success("βœ… Task Completed!")
75
+ st.subheader("πŸ“„ Result")
76
+ st.markdown(result, unsafe_allow_html=True)
77
+
78
+ # Footer
79
+ st.markdown(
80
+ """
81
+ <hr>
82
+ <center>
83
+ <small>Powered by LangChain + Gemini | Built by Academic AI</small>
84
+ </center>
85
+ """,
86
+ unsafe_allow_html=True
87
+ )