darsoarafa commited on
Commit
cd2e3c9
Β·
verified Β·
1 Parent(s): 4ebb4a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -74
app.py CHANGED
@@ -11,21 +11,57 @@ from paper import (
11
  run_task
12
  )
13
 
14
- # st.set_page_config()λŠ” λ‹€λ₯Έ Streamlit ν•¨μˆ˜λ³΄λ‹€ κ°€μž₯ λ¨Όμ € μ‹€ν–‰λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.
15
  st.set_page_config(
16
- page_title="Your AI Agent for Academic Research",
17
  page_icon="πŸ“š",
18
  layout="wide",
19
  initial_sidebar_state="expanded"
20
  )
21
 
22
  # ------------------------------------------
23
- # λ‹€κ΅­μ–΄ 지원 (μ˜μ–΄/ν•œκ΅­μ–΄ μ˜ˆμ‹œ)
24
  # ------------------------------------------
25
  translations = {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  "en": {
27
- "page_title": "Your AI Agent for Academic Research",
28
- "header": "Your AI Agent for Academic Research",
29
  "create_itinerary": "Generate Your Research Paper",
30
  "trip_details": "Research Details",
31
  "origin": "Research Topic",
@@ -58,71 +94,35 @@ translations = {
58
  "error_origin_destination": "Please enter both the research topic and paper title.",
59
  "your_itinerary_file": "Your Paper File",
60
  "text_format": "Text format - Can be opened in any text editor"
61
- },
62
- "ko": {
63
- "page_title": "λ‹Ήμ‹ μ˜ ν•™μˆ  연ꡬ AI μ—μ΄μ „νŠΈ",
64
- "header": "λ‹Ήμ‹ μ˜ ν•™μˆ  연ꡬ AI μ—μ΄μ „νŠΈ",
65
- "create_itinerary": "λ…Όλ¬Έ 생성",
66
- "trip_details": "연ꡬ 세뢀사항",
67
- "origin": "연ꡬ 주제",
68
- "destination": "λ…Όλ¬Έ 제λͺ©",
69
- "travel_dates": "제좜 κΈ°ν•œ",
70
- "duration": "λ…Όλ¬Έ λΆ„λŸ‰ (νŽ˜μ΄μ§€)",
71
- "preferences": "ν‚€μ›Œλ“œ/μ£Όμš” 초점",
72
- "special_requirements": "μΆ”κ°€ μ§€μ‹œμ‚¬ν•­",
73
- "submit": "πŸš€ λ‚˜μ˜ λ…Όλ¬Έ 생성",
74
- "request_details": "연ꡬ μš”μ²­ 정보",
75
- "from": "주제",
76
- "when": "제좜 κΈ°ν•œ",
77
- "budget": "λ…Όλ¬Έ μ’…λ₯˜",
78
- "travel_style": "μž‘μ„± μŠ€νƒ€μΌ",
79
- "live_agent_outputs": "μ‹€μ‹œκ°„ μ—μ΄μ „νŠΈ κ²°κ³Ό",
80
- "full_itinerary": "전체 λ…Όλ¬Έ",
81
- "details": "세뢀사항",
82
- "download_share": "λ‹€μš΄λ‘œλ“œ 및 곡유",
83
- "save_itinerary": "λ…Όλ¬Έ μ €μž₯",
84
- "plan_another_trip": "πŸ”„ λ‹€λ₯Έ λ…Όλ¬Έ 생성",
85
- "about": "μ†Œκ°œ",
86
- "how_it_works": "μž‘λ™ 방식",
87
- "travel_agents": "연ꡬ μ—μ΄μ „νŠΈ",
88
- "share_itinerary": "λ…Όλ¬Έ 곡유",
89
- "save_for_mobile": "λͺ¨λ°”일 μ €μž₯",
90
- "built_with": "당신을 μœ„ν•΄ ❀️ λ§Œλ“€μ–΄μ‘ŒμŠ΅λ‹ˆλ‹€",
91
- "itinerary_ready": "논문이 μ€€λΉ„λ˜μ—ˆμŠ΅λ‹ˆλ‹€! πŸŽ‰",
92
- "personalized_experience": "μž…λ ₯ν•˜μ‹  정보λ₯Ό λ°”νƒ•μœΌλ‘œ λ§žμΆ€ν˜• 논문이 μƒμ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μ•„λž˜μ—μ„œ 논문을 ν™•μΈν•˜μ„Έμš”.",
93
- "agent_activity": "μ—μ΄μ „νŠΈ ν™œλ™",
94
- "error_origin_destination": "연ꡬ μ£Όμ œμ™€ λ…Όλ¬Έ 제λͺ©μ„ λͺ¨λ‘ μž…λ ₯ν•˜μ„Έμš”.",
95
- "your_itinerary_file": "λ…Όλ¬Έ 파일",
96
- "text_format": "ν…μŠ€νŠΈ ν˜•μ‹ - λͺ¨λ“  ν…μŠ€νŠΈ νŽΈμ§‘κΈ°μ—μ„œ μ—΄ 수 μžˆμŠ΅λ‹ˆλ‹€."
97
  }
98
  }
99
 
100
  def t(key):
101
- lang = st.session_state.get("selected_language", "en")
102
  return translations[lang].get(key, key)
103
 
104
  # ---------------------------
105
- # μ„Έμ…˜ μ΄ˆκΈ°ν™”
106
  # ---------------------------
107
  if 'selected_language' not in st.session_state:
108
- st.session_state.selected_language = "en"
109
 
110
  # ------------------------------------------
111
- # μ‚¬μ΄λ“œλ°”μ— μ–Έμ–΄ 선택 μœ„μ ― μΆ”κ°€
112
  # ------------------------------------------
113
  with st.sidebar:
114
  language = st.selectbox(
115
- "Language / μ–Έμ–΄",
116
- ["English", "ν•œκ΅­μ–΄"]
117
  )
118
  lang_map = {
119
- "English": "en",
120
- "ν•œκ΅­μ–΄": "ko"
121
  }
122
- st.session_state.selected_language = lang_map.get(language, "en")
123
 
124
  # ------------------------------------------
125
- # UI μ‹œμž‘
126
  # ------------------------------------------
127
  st.markdown("""
128
  <style>
@@ -227,7 +227,7 @@ st.markdown(f"""
227
  <div style="text-align: center;">
228
  <img src="https://img.icons8.com/fluency/96/book.png" width="90">
229
  <h1 class="main-header">{t("header")}</h1>
230
- <p>Generate your personalized research paper with AI-powered academic agents.</p>
231
  </div>
232
  """, unsafe_allow_html=True)
233
  st.markdown('<hr>', unsafe_allow_html=True)
@@ -236,23 +236,23 @@ with st.sidebar:
236
  st.markdown("""
237
  <div style="text-align: center;">
238
  <img src="https://img.icons8.com/fluency/96/book.png" width="80">
239
- <h3>Your AI Academic Research Assistant</h3>
240
- <p>AI-Powered Paper Generation</p>
241
  </div>
242
  """, unsafe_allow_html=True)
243
  st.markdown('<div class="modern-card">', unsafe_allow_html=True)
244
  st.markdown("### " + t("about"))
245
- st.info("This tool generates a personalized academic research paper based on your inputs. Fill in the form and let our specialized agents craft your paper!")
246
  st.markdown('</div>', unsafe_allow_html=True)
247
  st.markdown('<div class="modern-card">', unsafe_allow_html=True)
248
  st.markdown("### " + t("how_it_works"))
249
  st.markdown("""
250
  <ol>
251
- <li>Enter your research details</li>
252
- <li>AI conducts literature research</li>
253
- <li>Generate a paper outline</li>
254
- <li>Draft and edit your paper</li>
255
- <li>Download your final paper</li>
256
  </ol>
257
  """, unsafe_allow_html=True)
258
  st.markdown('</div>', unsafe_allow_html=True)
@@ -260,21 +260,21 @@ with st.sidebar:
260
  if not st.session_state.generation_complete:
261
  st.markdown('<div class="modern-card">', unsafe_allow_html=True)
262
  st.markdown("<h3>" + t("create_itinerary") + "</h3>", unsafe_allow_html=True)
263
- st.markdown("<p>Fill in the details below to generate your research paper.</p>", unsafe_allow_html=True)
264
 
265
  with st.form("research_form"):
266
  col1, col2 = st.columns(2)
267
  with col1:
268
- research_topic = st.text_input(t("origin"), placeholder="e.g., Deep Learning in Healthcare")
269
- paper_title = st.text_input(t("destination"), placeholder="e.g., Advances in Deep Learning for Medical Diagnosis")
270
  due_date = st.date_input(t("travel_dates"), min_value=datetime.now())
271
  with col2:
272
  paper_length = st.slider(t("duration"), min_value=5, max_value=50, value=10)
273
  paper_type_options = ["Journal", "Conference", "Thesis", "Review"]
274
  paper_type = st.selectbox(t("budget"), paper_type_options, help="Select the type of paper")
275
  writing_style = st.multiselect(t("travel_style"), options=["Formal", "Technical", "Creative"], default=["Formal"])
276
- additional_instructions = st.text_area(t("special_requirements"), placeholder="Any additional instructions or requirements...")
277
- keywords = st.text_area(t("preferences"), placeholder="Enter keywords or focus areas, separated by commas")
278
  submit_button = st.form_submit_button(t("submit"))
279
  st.markdown('</div>', unsafe_allow_html=True)
280
 
@@ -307,13 +307,13 @@ Additional Instructions: {user_input['additional_instructions']}
307
  """
308
  llm_language_instructions = {
309
  "en": "Please output the response in English.",
310
- "ko": "ν•œκ΅­μ–΄λ‘œ 좜λ ₯ν•΄ μ£Όμ„Έμš”."
311
  }
312
- selected_lang = st.session_state.get("selected_language", "en")
313
- language_instruction = llm_language_instructions.get(selected_lang, "Please output the response in English.")
314
  modified_input_context = language_instruction + "\n" + input_context
315
 
316
- st.markdown("<div>Processing your request...</div>", unsafe_allow_html=True)
317
  st.session_state.current_step = 0
318
  update_step_status(0, 'active')
319
  progress_placeholder = st.empty()
@@ -421,13 +421,13 @@ if st.session_state.generation_complete:
421
  </div>
422
  """, unsafe_allow_html=True)
423
 
424
- # νƒ­ 생성 (전체 λ…Όλ¬Έ, μ„ΈλΆ€ 정보, λ‹€μš΄λ‘œλ“œ/곡유, μ‹œκ°ν™”, 챗봇)
425
  full_paper_tab, details_tab, download_tab, visualization_tab, chatbot_tab = st.tabs([
426
  "πŸ—’οΈ " + t("full_itinerary"),
427
  "πŸ’Ό " + t("details"),
428
  "πŸ’Ύ " + t("download_share"),
429
  "πŸ“Š Visualization",
430
- "πŸ€– 챗봇 μΈν„°νŽ˜μ΄μŠ€"
431
  ])
432
 
433
  with full_paper_tab:
@@ -474,11 +474,11 @@ if st.session_state.generation_complete:
474
  st.markdown("A conceptual diagram or visualization related to your research paper can be displayed here. (Feature under development)")
475
 
476
  with chatbot_tab:
477
- st.markdown("### AI 챗봇 μΈν„°νŽ˜μ΄μŠ€")
478
  if "chat_history" not in st.session_state:
479
  st.session_state.chat_history = []
480
- user_message = st.text_input("λ©”μ‹œμ§€λ₯Ό μž…λ ₯ν•˜μ„Έμš”:", key="chat_input")
481
- if st.button("전솑", key="send_button"):
482
  if user_message:
483
  response = run_task(chatbot_task, user_message)
484
  st.session_state.chat_history.append({
 
11
  run_task
12
  )
13
 
14
+ # st.set_page_config()
15
  st.set_page_config(
16
+ page_title="AI Agent for Academic Research",
17
  page_icon="πŸ“š",
18
  layout="wide",
19
  initial_sidebar_state="expanded"
20
  )
21
 
22
  # ------------------------------------------
23
+ #
24
  # ------------------------------------------
25
  translations = {
26
+ "id": {
27
+ "page_title": "Agen AI untuk Penelitian Akademis",
28
+ "header": "Agen AI untuk Penelitian Akademis",
29
+ "create_itinerary": "Membuat Laporan Penelitian",
30
+ "trip_details": "Penelitian rinci",
31
+ "origin": "Research Topic",
32
+ "destination": "Judul penelitian",
33
+ "travel_dates": "Tanggal selesai",
34
+ "duration": "Jumlah halaman (pages)",
35
+ "preferences": "Keywords/Focus",
36
+ "special_requirements": "Additional Instructions",
37
+ "submit": "πŸš€ Buatkan Laporan Penelitian",
38
+ "request_details": "Your Research Request",
39
+ "from": "Topic",
40
+ "when": "Due Date",
41
+ "budget": "Paper Type",
42
+ "travel_style": "Writing Style",
43
+ "live_agent_outputs": "Live Agent Outputs",
44
+ "full_itinerary": "Full Paper",
45
+ "details": "Details",
46
+ "download_share": "Download & Share",
47
+ "save_itinerary": "Save Your Paper",
48
+ "plan_another_trip": "πŸ”„ Generate Another Paper",
49
+ "about": "About",
50
+ "how_it_works": "How it works",
51
+ "travel_agents": "Research Agents",
52
+ "share_itinerary": "Share Your Paper",
53
+ "save_for_mobile": "Save for Mobile",
54
+ "built_with": "Built with ❀️ for you",
55
+ "itinerary_ready": "Your Research Paper is Ready! πŸŽ‰",
56
+ "personalized_experience": "Kami telah membuat makalah akademis yang dipersonalisasi berdasarkan masukan Anda. Lihat makalah Anda di bawah ini.",
57
+ "agent_activity": "Agent Activity",
58
+ "error_origin_destination": "Harap masukkan topik penelitian dan judul makalah",
59
+ "your_itinerary_file": "Your Paper File",
60
+ "text_format": "Text format - Can be opened in any text editor"
61
+ },
62
  "en": {
63
+ "page_title": "AI Agent for Academic Research",
64
+ "header": "AI Agent for Academic Research",
65
  "create_itinerary": "Generate Your Research Paper",
66
  "trip_details": "Research Details",
67
  "origin": "Research Topic",
 
94
  "error_origin_destination": "Please enter both the research topic and paper title.",
95
  "your_itinerary_file": "Your Paper File",
96
  "text_format": "Text format - Can be opened in any text editor"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  }
98
  }
99
 
100
  def t(key):
101
+ lang = st.session_state.get("selected_language", "id")
102
  return translations[lang].get(key, key)
103
 
104
  # ---------------------------
105
+ #
106
  # ---------------------------
107
  if 'selected_language' not in st.session_state:
108
+ st.session_state.selected_language = "id"
109
 
110
  # ------------------------------------------
111
+ #
112
  # ------------------------------------------
113
  with st.sidebar:
114
  language = st.selectbox(
115
+ "Language / Bahasa",
116
+ ["Indonesia","English"]
117
  )
118
  lang_map = {
119
+ "Indonesia": "id",
120
+ "English": "en"
121
  }
122
+ st.session_state.selected_language = lang_map.get(language, "id")
123
 
124
  # ------------------------------------------
125
+ #
126
  # ------------------------------------------
127
  st.markdown("""
128
  <style>
 
227
  <div style="text-align: center;">
228
  <img src="https://img.icons8.com/fluency/96/book.png" width="90">
229
  <h1 class="main-header">{t("header")}</h1>
230
+ <p>Hasilkan makalah penelitian pribadi Anda dengan agen yang berbasis AI.</p>
231
  </div>
232
  """, unsafe_allow_html=True)
233
  st.markdown('<hr>', unsafe_allow_html=True)
 
236
  st.markdown("""
237
  <div style="text-align: center;">
238
  <img src="https://img.icons8.com/fluency/96/book.png" width="80">
239
+ <h3>Asisten AI untuk Penelitian Akademik</h3>
240
+ <p>Pembuatan laporan dibantu AI</p>
241
  </div>
242
  """, unsafe_allow_html=True)
243
  st.markdown('<div class="modern-card">', unsafe_allow_html=True)
244
  st.markdown("### " + t("about"))
245
+ st.info("Alat ini menghasilkan makalah penelitian akademis yang dipersonalisasi berdasarkan masukan Anda. Isi formulir dan biarkan agen spesialis kami menyusun makalah Anda!")
246
  st.markdown('</div>', unsafe_allow_html=True)
247
  st.markdown('<div class="modern-card">', unsafe_allow_html=True)
248
  st.markdown("### " + t("how_it_works"))
249
  st.markdown("""
250
  <ol>
251
+ <li>Masukkan detail penelitian Anda</li>
252
+ <li>AI melakukan penelitian literatur</li>
253
+ <li>Membuat kerangka makalah</li>
254
+ <li>Buat draf dan edit makalah Anda</li>
255
+ <li>Unduh makalah akhir Anda</li>
256
  </ol>
257
  """, unsafe_allow_html=True)
258
  st.markdown('</div>', unsafe_allow_html=True)
 
260
  if not st.session_state.generation_complete:
261
  st.markdown('<div class="modern-card">', unsafe_allow_html=True)
262
  st.markdown("<h3>" + t("create_itinerary") + "</h3>", unsafe_allow_html=True)
263
+ st.markdown("<p>Isi rincian di bawah ini</p>", unsafe_allow_html=True)
264
 
265
  with st.form("research_form"):
266
  col1, col2 = st.columns(2)
267
  with col1:
268
+ research_topic = st.text_input(t("origin"), placeholder="e.g., Manfaat Teh untuk kesehatan manusia")
269
+ paper_title = st.text_input(t("destination"), placeholder="e.g., Hasil penelitian terbaru tentang manfaat teh untuk kesehatan manusia")
270
  due_date = st.date_input(t("travel_dates"), min_value=datetime.now())
271
  with col2:
272
  paper_length = st.slider(t("duration"), min_value=5, max_value=50, value=10)
273
  paper_type_options = ["Journal", "Conference", "Thesis", "Review"]
274
  paper_type = st.selectbox(t("budget"), paper_type_options, help="Select the type of paper")
275
  writing_style = st.multiselect(t("travel_style"), options=["Formal", "Technical", "Creative"], default=["Formal"])
276
+ additional_instructions = st.text_area(t("special_requirements"), placeholder="Instruksi atau persyaratan tambahan apa pun...")
277
+ keywords = st.text_area(t("preferences"), placeholder="Masukkan kata kunci atau area fokus, dipisahkan dengan koma")
278
  submit_button = st.form_submit_button(t("submit"))
279
  st.markdown('</div>', unsafe_allow_html=True)
280
 
 
307
  """
308
  llm_language_instructions = {
309
  "en": "Please output the response in English.",
310
+ "id": "Please output the response in Bahasa Indonesia."
311
  }
312
+ selected_lang = st.session_state.get("selected_language", "id")
313
+ language_instruction = llm_language_instructions.get(selected_lang, "Please output the response in Bahasa Indonesia.")
314
  modified_input_context = language_instruction + "\n" + input_context
315
 
316
+ st.markdown("<div>Sedang memproses...</div>", unsafe_allow_html=True)
317
  st.session_state.current_step = 0
318
  update_step_status(0, 'active')
319
  progress_placeholder = st.empty()
 
421
  </div>
422
  """, unsafe_allow_html=True)
423
 
424
+ #
425
  full_paper_tab, details_tab, download_tab, visualization_tab, chatbot_tab = st.tabs([
426
  "πŸ—’οΈ " + t("full_itinerary"),
427
  "πŸ’Ό " + t("details"),
428
  "πŸ’Ύ " + t("download_share"),
429
  "πŸ“Š Visualization",
430
+ "πŸ€– Chatbot"
431
  ])
432
 
433
  with full_paper_tab:
 
474
  st.markdown("A conceptual diagram or visualization related to your research paper can be displayed here. (Feature under development)")
475
 
476
  with chatbot_tab:
477
+ st.markdown("### AI Chat")
478
  if "chat_history" not in st.session_state:
479
  st.session_state.chat_history = []
480
+ user_message = st.text_input("Input:", key="chat_input")
481
+ if st.button("Kirim", key="send_button"):
482
  if user_message:
483
  response = run_task(chatbot_task, user_message)
484
  st.session_state.chat_history.append({