Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,21 +11,57 @@ from paper import (
|
|
| 11 |
run_task
|
| 12 |
)
|
| 13 |
|
| 14 |
-
# st.set_page_config()
|
| 15 |
st.set_page_config(
|
| 16 |
-
page_title="
|
| 17 |
page_icon="π",
|
| 18 |
layout="wide",
|
| 19 |
initial_sidebar_state="expanded"
|
| 20 |
)
|
| 21 |
|
| 22 |
# ------------------------------------------
|
| 23 |
-
#
|
| 24 |
# ------------------------------------------
|
| 25 |
translations = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
"en": {
|
| 27 |
-
"page_title": "
|
| 28 |
-
"header": "
|
| 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", "
|
| 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 = "
|
| 109 |
|
| 110 |
# ------------------------------------------
|
| 111 |
-
#
|
| 112 |
# ------------------------------------------
|
| 113 |
with st.sidebar:
|
| 114 |
language = st.selectbox(
|
| 115 |
-
"Language /
|
| 116 |
-
["
|
| 117 |
)
|
| 118 |
lang_map = {
|
| 119 |
-
"
|
| 120 |
-
"
|
| 121 |
}
|
| 122 |
-
st.session_state.selected_language = lang_map.get(language, "
|
| 123 |
|
| 124 |
# ------------------------------------------
|
| 125 |
-
#
|
| 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>
|
| 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>
|
| 240 |
-
<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("
|
| 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>
|
| 252 |
-
<li>AI
|
| 253 |
-
<li>
|
| 254 |
-
<li>
|
| 255 |
-
<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>
|
| 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.,
|
| 269 |
-
paper_title = st.text_input(t("destination"), placeholder="e.g.,
|
| 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="
|
| 277 |
-
keywords = st.text_area(t("preferences"), placeholder="
|
| 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 |
-
"
|
| 311 |
}
|
| 312 |
-
selected_lang = st.session_state.get("selected_language", "
|
| 313 |
-
language_instruction = llm_language_instructions.get(selected_lang, "Please output the response in
|
| 314 |
modified_input_context = language_instruction + "\n" + input_context
|
| 315 |
|
| 316 |
-
st.markdown("<div>
|
| 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("
|
| 481 |
-
if st.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({
|