Spaces:
Running
Running
File size: 21,575 Bytes
a3b693b 88dbdcc e3d9538 71b8a5a a3b693b 14d4eaf ffbc6a2 71b8a5a ffbc6a2 f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 14d4eaf 71b8a5a 14d4eaf 71b8a5a 14d4eaf f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 14d4eaf 71b8a5a 14d4eaf 71b8a5a 14d4eaf f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 71b8a5a f4f75b1 a3b693b 88dbdcc a3b693b 88dbdcc a3b693b 88dbdcc a3b693b 88dbdcc 71b8a5a 88dbdcc a3b693b 88dbdcc f4f75b1 a3b693b 71b8a5a 88dbdcc f4f75b1 55b1299 71b8a5a 88dbdcc a3b693b 88dbdcc a3b693b 88dbdcc a3b693b 88dbdcc 71b8a5a 88dbdcc a3b693b 14d4eaf a3b693b 14d4eaf a3b693b 55b1299 a3b693b 71b8a5a a3b693b 88dbdcc 55b1299 71b8a5a f4f75b1 71b8a5a 88dbdcc 55b1299 71b8a5a a3b693b 55b1299 71b8a5a 88dbdcc 55b1299 88dbdcc 71b8a5a 88dbdcc 71b8a5a 88dbdcc 71b8a5a 88dbdcc ffbc6a2 a3b693b 71b8a5a a3b693b 71b8a5a 88dbdcc 71b8a5a 88dbdcc 71b8a5a f4f75b1 88dbdcc 71b8a5a 88dbdcc 71b8a5a 14d4eaf a3b693b 88dbdcc 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b e6c2746 71b8a5a e6c2746 71b8a5a a3b693b ffbc6a2 71b8a5a 88dbdcc 71b8a5a a3b693b 71b8a5a a3b693b ffbc6a2 a3b693b ffbc6a2 71b8a5a 88dbdcc 71b8a5a a3b693b 71b8a5a a3b693b ffbc6a2 a3b693b ffbc6a2 71b8a5a 88dbdcc 71b8a5a a3b693b 71b8a5a a3b693b ffbc6a2 a3b693b ffbc6a2 71b8a5a 88dbdcc 71b8a5a a3b693b 71b8a5a a3b693b ffbc6a2 a3b693b ffbc6a2 71b8a5a 88dbdcc 71b8a5a a3b693b 71b8a5a a3b693b ffbc6a2 a3b693b 71b8a5a 88dbdcc 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a 88dbdcc 71b8a5a e3d9538 71b8a5a e3d9538 71b8a5a e3d9538 88dbdcc 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a a3b693b 71b8a5a e3d9538 88dbdcc f4f75b1 71b8a5a 88dbdcc 71b8a5a 88dbdcc 71b8a5a f4f75b1 71b8a5a 88dbdcc f4f75b1 88dbdcc b672d97 71b8a5a a808da1 b672d97 9f70594 71b8a5a 9f70594 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
import streamlit as st
import os
import json
from datetime import datetime, timedelta
import base64
import pandas as pd
import pydeck as pdk
from paper import (
literature_research_task, outline_task, draft_writing_task,
citation_task, editing_task, chatbot_task,
run_task
)
# st.set_page_config()๋ ๋ค๋ฅธ Streamlit ํจ์๋ณด๋ค ๊ฐ์ฅ ๋จผ์ ์คํ๋์ด์ผ ํฉ๋๋ค.
st.set_page_config(
page_title="Your AI Agent for Academic Research",
page_icon="๐",
layout="wide",
initial_sidebar_state="expanded"
)
# ------------------------------------------
# ๋ค๊ตญ์ด ์ง์ (์์ด/ํ๊ตญ์ด ์์)
# ------------------------------------------
translations = {
"en": {
"page_title": "Your AI Agent for Academic Research",
"header": "Your AI Agent for Academic Research",
"create_itinerary": "Generate Your Research Paper",
"trip_details": "Research Details",
"origin": "Research Topic",
"destination": "Paper Title",
"travel_dates": "Due Date",
"duration": "Paper Length (pages)",
"preferences": "Keywords/Focus",
"special_requirements": "Additional Instructions",
"submit": "๐ Generate My Research Paper",
"request_details": "Your Research Request",
"from": "Topic",
"when": "Due Date",
"budget": "Paper Type",
"travel_style": "Writing Style",
"live_agent_outputs": "Live Agent Outputs",
"full_itinerary": "Full Paper",
"details": "Details",
"download_share": "Download & Share",
"save_itinerary": "Save Your Paper",
"plan_another_trip": "๐ Generate Another Paper",
"about": "About",
"how_it_works": "How it works",
"travel_agents": "Research Agents",
"share_itinerary": "Share Your Paper",
"save_for_mobile": "Save for Mobile",
"built_with": "Built with โค๏ธ for you",
"itinerary_ready": "Your Research Paper is Ready! ๐",
"personalized_experience": "We've created a personalized academic paper based on your inputs. Explore your paper below.",
"agent_activity": "Agent Activity",
"error_origin_destination": "Please enter both the research topic and paper title.",
"your_itinerary_file": "Your Paper File",
"text_format": "Text format - Can be opened in any text editor"
},
"ko": {
"page_title": "๋น์ ์ ํ์ ์ฐ๊ตฌ AI ์์ด์ ํธ",
"header": "๋น์ ์ ํ์ ์ฐ๊ตฌ AI ์์ด์ ํธ",
"create_itinerary": "๋
ผ๋ฌธ ์์ฑ",
"trip_details": "์ฐ๊ตฌ ์ธ๋ถ์ฌํญ",
"origin": "์ฐ๊ตฌ ์ฃผ์ ",
"destination": "๋
ผ๋ฌธ ์ ๋ชฉ",
"travel_dates": "์ ์ถ ๊ธฐํ",
"duration": "๋
ผ๋ฌธ ๋ถ๋ (ํ์ด์ง)",
"preferences": "ํค์๋/์ฃผ์ ์ด์ ",
"special_requirements": "์ถ๊ฐ ์ง์์ฌํญ",
"submit": "๐ ๋์ ๋
ผ๋ฌธ ์์ฑ",
"request_details": "์ฐ๊ตฌ ์์ฒญ ์ ๋ณด",
"from": "์ฃผ์ ",
"when": "์ ์ถ ๊ธฐํ",
"budget": "๋
ผ๋ฌธ ์ข
๋ฅ",
"travel_style": "์์ฑ ์คํ์ผ",
"live_agent_outputs": "์ค์๊ฐ ์์ด์ ํธ ๊ฒฐ๊ณผ",
"full_itinerary": "์ ์ฒด ๋
ผ๋ฌธ",
"details": "์ธ๋ถ์ฌํญ",
"download_share": "๋ค์ด๋ก๋ ๋ฐ ๊ณต์ ",
"save_itinerary": "๋
ผ๋ฌธ ์ ์ฅ",
"plan_another_trip": "๐ ๋ค๋ฅธ ๋
ผ๋ฌธ ์์ฑ",
"about": "์๊ฐ",
"how_it_works": "์๋ ๋ฐฉ์",
"travel_agents": "์ฐ๊ตฌ ์์ด์ ํธ",
"share_itinerary": "๋
ผ๋ฌธ ๊ณต์ ",
"save_for_mobile": "๋ชจ๋ฐ์ผ ์ ์ฅ",
"built_with": "๋น์ ์ ์ํด โค๏ธ ๋ง๋ค์ด์ก์ต๋๋ค",
"itinerary_ready": "๋
ผ๋ฌธ์ด ์ค๋น๋์์ต๋๋ค! ๐",
"personalized_experience": "์
๋ ฅํ์ ์ ๋ณด๋ฅผ ๋ฐํ์ผ๋ก ๋ง์ถคํ ๋
ผ๋ฌธ์ด ์์ฑ๋์์ต๋๋ค. ์๋์์ ๋
ผ๋ฌธ์ ํ์ธํ์ธ์.",
"agent_activity": "์์ด์ ํธ ํ๋",
"error_origin_destination": "์ฐ๊ตฌ ์ฃผ์ ์ ๋
ผ๋ฌธ ์ ๋ชฉ์ ๋ชจ๋ ์
๋ ฅํ์ธ์.",
"your_itinerary_file": "๋
ผ๋ฌธ ํ์ผ",
"text_format": "ํ
์คํธ ํ์ - ๋ชจ๋ ํ
์คํธ ํธ์ง๊ธฐ์์ ์ด ์ ์์ต๋๋ค."
}
}
def t(key):
lang = st.session_state.get("selected_language", "en")
return translations[lang].get(key, key)
# ---------------------------
# ์ธ์
์ด๊ธฐํ
# ---------------------------
if 'selected_language' not in st.session_state:
st.session_state.selected_language = "en"
# ------------------------------------------
# ์ฌ์ด๋๋ฐ์ ์ธ์ด ์ ํ ์์ ฏ ์ถ๊ฐ
# ------------------------------------------
with st.sidebar:
language = st.selectbox(
"Language / ์ธ์ด",
["English", "ํ๊ตญ์ด"]
)
lang_map = {
"English": "en",
"ํ๊ตญ์ด": "ko"
}
st.session_state.selected_language = lang_map.get(language, "en")
# ------------------------------------------
# UI ์์
# ------------------------------------------
st.markdown("""
<style>
:root {
--primary: #3a86ff;
--primary-light: #4895ef;
--primary-dark: #2667ff;
--background: #f8f9fa;
--card-bg: #ffffff;
--text: #212529;
--border: #e9ecef;
}
.main-header {
font-size: 2.5rem;
color: var(--primary-dark);
text-align: center;
margin-bottom: 0.8rem;
font-weight: 700;
}
.modern-card {
background-color: var(--card-bg);
border-radius: 10px;
padding: 1.2rem;
margin-bottom: 1.2rem;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
border: 1px solid var(--border);
}
</style>
""", unsafe_allow_html=True)
def get_download_link(text_content, filename):
b64 = base64.b64encode(text_content.encode()).decode()
href = f'<a class="download-link" href="data:text/plain;base64,{b64}" download="{filename}"><i>๐ฅ</i> {t("save_itinerary")}</a>'
return href
def display_modern_progress(current_step, total_steps=5):
if 'progress_steps' not in st.session_state:
st.session_state.progress_steps = {
0: {'status': 'pending', 'name': t("trip_details")},
1: {'status': 'pending', 'name': t("about")},
2: {'status': 'pending', 'name': t("live_agent_outputs")},
3: {'status': 'pending', 'name': t("download_share")},
4: {'status': 'pending', 'name': t("full_itinerary")}
}
for i in range(total_steps):
if i < current_step:
st.session_state.progress_steps[i]['status'] = 'complete'
elif i == current_step:
st.session_state.progress_steps[i]['status'] = 'active'
else:
st.session_state.progress_steps[i]['status'] = 'pending'
progress_percentage = (current_step / total_steps) * 100
st.progress(progress_percentage / 100)
st.markdown("<div>Progress: " + str(progress_percentage) + "% completed.</div>")
return progress_percentage
def update_step_status(step_index, status):
if 'progress_steps' in st.session_state and step_index in st.session_state.progress_steps:
st.session_state.progress_steps[step_index]['status'] = status
def run_task_with_logs(task, input_text, log_container, output_container, results_key=None):
log_message = f"๐ค Starting {task.agent.role}..."
st.session_state.log_messages.append(log_message)
with log_container:
st.markdown("### " + t("agent_activity"))
for msg in st.session_state.log_messages:
st.markdown(msg)
result = run_task(task, input_text)
if results_key:
st.session_state.results[results_key] = result
log_message = f"โ
{task.agent.role} completed!"
st.session_state.log_messages.append(log_message)
with log_container:
st.markdown("### " + t("agent_activity"))
for msg in st.session_state.log_messages:
st.markdown(msg)
with output_container:
st.markdown(f"### {task.agent.role} Output")
st.markdown("<div class='agent-output'>" + result + "</div>", unsafe_allow_html=True)
return result
if 'generated_itinerary' not in st.session_state:
st.session_state.generated_itinerary = None
if 'generation_complete' not in st.session_state:
st.session_state.generation_complete = False
if 'current_step' not in st.session_state:
st.session_state.current_step = 0
if 'results' not in st.session_state:
st.session_state.results = {
"literature_review": "",
"outline": "",
"draft": "",
"citations": "",
"edited": ""
}
if 'log_messages' not in st.session_state:
st.session_state.log_messages = []
if 'form_submitted' not in st.session_state:
st.session_state.form_submitted = False
st.markdown(f"""
<div style="text-align: center;">
<img src="https://img.icons8.com/fluency/96/book.png" width="90">
<h1 class="main-header">{t("header")}</h1>
<p>Generate your personalized research paper with AI-powered academic agents.</p>
</div>
""", unsafe_allow_html=True)
st.markdown('<hr>', unsafe_allow_html=True)
with st.sidebar:
st.markdown("""
<div style="text-align: center;">
<img src="https://img.icons8.com/fluency/96/book.png" width="80">
<h3>Your AI Academic Research Assistant</h3>
<p>AI-Powered Paper Generation</p>
</div>
""", unsafe_allow_html=True)
st.markdown('<div class="modern-card">', unsafe_allow_html=True)
st.markdown("### " + t("about"))
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!")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('<div class="modern-card">', unsafe_allow_html=True)
st.markdown("### " + t("how_it_works"))
st.markdown("""
<ol>
<li>Enter your research details</li>
<li>AI conducts literature research</li>
<li>Generate a paper outline</li>
<li>Draft and edit your paper</li>
<li>Download your final paper</li>
</ol>
""", unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
if not st.session_state.generation_complete:
st.markdown('<div class="modern-card">', unsafe_allow_html=True)
st.markdown("<h3>" + t("create_itinerary") + "</h3>", unsafe_allow_html=True)
st.markdown("<p>Fill in the details below to generate your research paper.</p>", unsafe_allow_html=True)
with st.form("research_form"):
col1, col2 = st.columns(2)
with col1:
research_topic = st.text_input(t("origin"), placeholder="e.g., Deep Learning in Healthcare")
paper_title = st.text_input(t("destination"), placeholder="e.g., Advances in Deep Learning for Medical Diagnosis")
due_date = st.date_input(t("travel_dates"), min_value=datetime.now())
with col2:
paper_length = st.slider(t("duration"), min_value=5, max_value=50, value=10)
paper_type_options = ["Journal", "Conference", "Thesis", "Review"]
paper_type = st.selectbox(t("budget"), paper_type_options, help="Select the type of paper")
writing_style = st.multiselect(t("travel_style"), options=["Formal", "Technical", "Creative"], default=["Formal"])
additional_instructions = st.text_area(t("special_requirements"), placeholder="Any additional instructions or requirements...")
keywords = st.text_area(t("preferences"), placeholder="Enter keywords or focus areas, separated by commas")
submit_button = st.form_submit_button(t("submit"))
st.markdown('</div>', unsafe_allow_html=True)
if submit_button:
if not research_topic or not paper_title:
st.error(t("error_origin_destination"))
else:
st.session_state.form_submitted = True
st.session_state.research_topic = research_topic
user_input = {
"research_topic": research_topic,
"paper_title": paper_title,
"due_date": due_date.strftime("%Y-%m-%d"),
"paper_length": str(paper_length),
"paper_type": paper_type,
"writing_style": ", ".join(writing_style),
"keywords": keywords,
"additional_instructions": additional_instructions
}
st.session_state.user_input = user_input
input_context = f"""Research Request Details:
Research Topic: {user_input['research_topic']}
Paper Title: {user_input['paper_title']}
Due Date: {user_input['due_date']}
Paper Length: {user_input['paper_length']} pages
Paper Type: {user_input['paper_type']}
Writing Style: {user_input['writing_style']}
Keywords/Focus: {user_input['keywords']}
Additional Instructions: {user_input['additional_instructions']}
"""
llm_language_instructions = {
"en": "Please output the response in English.",
"ko": "ํ๊ตญ์ด๋ก ์ถ๋ ฅํด ์ฃผ์ธ์."
}
selected_lang = st.session_state.get("selected_language", "en")
language_instruction = llm_language_instructions.get(selected_lang, "Please output the response in English.")
modified_input_context = language_instruction + "\n" + input_context
st.markdown("<div>Processing your request...</div>", unsafe_allow_html=True)
st.session_state.current_step = 0
update_step_status(0, 'active')
progress_placeholder = st.empty()
with progress_placeholder.container():
display_modern_progress(st.session_state.current_step)
log_container = st.container()
st.session_state.log_messages = []
output_container = st.container()
st.session_state.results = {}
# Step 1: Literature Research
literature_review = run_task_with_logs(
literature_research_task,
modified_input_context.format(topic=user_input['research_topic'], keywords=user_input['keywords']),
log_container,
output_container,
"literature_review"
)
update_step_status(0, 'complete')
st.session_state.current_step = 1
update_step_status(1, 'active')
with progress_placeholder.container():
display_modern_progress(st.session_state.current_step)
# Step 2: Generate Outline
outline = run_task_with_logs(
outline_task,
modified_input_context.format(topic=user_input['research_topic']),
log_container,
output_container,
"outline"
)
update_step_status(1, 'complete')
st.session_state.current_step = 2
update_step_status(2, 'active')
with progress_placeholder.container():
display_modern_progress(st.session_state.current_step)
# Step 3: Draft Writing
draft = run_task_with_logs(
draft_writing_task,
modified_input_context.format(topic=user_input['research_topic']),
log_container,
output_container,
"draft"
)
update_step_status(2, 'complete')
st.session_state.current_step = 3
update_step_status(3, 'active')
with progress_placeholder.container():
display_modern_progress(st.session_state.current_step)
# Step 4: Citation Generation
citations = run_task_with_logs(
citation_task,
modified_input_context.format(topic=user_input['research_topic']),
log_container,
output_container,
"citations"
)
update_step_status(3, 'complete')
st.session_state.current_step = 4
update_step_status(4, 'active')
with progress_placeholder.container():
display_modern_progress(st.session_state.current_step)
# Step 5: Editing and Polishing
edited = run_task_with_logs(
editing_task,
modified_input_context.format(topic=user_input['research_topic']),
log_container,
output_container,
"edited"
)
update_step_status(4, 'complete')
st.session_state.current_step = 5
with progress_placeholder.container():
display_modern_progress(st.session_state.current_step)
full_paper = f"""Research Paper:
{input_context}
Literature Review:
{literature_review}
Outline:
{outline}
Draft:
{draft}
Citations:
{citations}
Edited Version:
{edited}
"""
st.session_state.generated_itinerary = full_paper
st.session_state.generation_complete = True
date_str = datetime.now().strftime("%Y-%m-%d")
st.session_state.filename = f"{user_input['paper_title'].replace(' ', '_')}_{date_str}_paper.txt"
if st.session_state.generation_complete:
st.markdown(f"""
<div class="modern-card">
<div style="text-align: center;">
<h2>{t("itinerary_ready")}</h2>
<p>{t("personalized_experience")}</p>
</div>
</div>
""", unsafe_allow_html=True)
# ํญ ์์ฑ (์ ์ฒด ๋
ผ๋ฌธ, ์ธ๋ถ ์ ๋ณด, ๋ค์ด๋ก๋/๊ณต์ , ์๊ฐํ, ์ฑ๋ด)
full_paper_tab, details_tab, download_tab, visualization_tab, chatbot_tab = st.tabs([
"๐๏ธ " + t("full_itinerary"),
"๐ผ " + t("details"),
"๐พ " + t("download_share"),
"๐ Visualization",
"๐ค ์ฑ๋ด ์ธํฐํ์ด์ค"
])
with full_paper_tab:
st.text_area("Your Research Paper", st.session_state.generated_itinerary, height=600)
with details_tab:
agent_tabs = st.tabs(["๐ Literature Review", "๐ Outline", "โ๏ธ Draft", "๐ Citations", "๐๏ธ Edited Version"])
with agent_tabs[0]:
st.markdown("### Literature Review")
st.markdown(st.session_state.results.get("literature_review", ""))
with agent_tabs[1]:
st.markdown("### Outline")
st.markdown(st.session_state.results.get("outline", ""))
with agent_tabs[2]:
st.markdown("### Draft")
st.markdown(st.session_state.results.get("draft", ""))
with agent_tabs[3]:
st.markdown("### Citations")
st.markdown(st.session_state.results.get("citations", ""))
with agent_tabs[4]:
st.markdown("### Edited Version")
st.markdown(st.session_state.results.get("edited", ""))
with download_tab:
col1, col2 = st.columns([2, 1])
with col1:
st.markdown("### " + t("save_itinerary"))
st.markdown("Download your research paper to access it offline or share with your colleagues.")
st.markdown(f"""
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 10px; margin-top: 20px;">
<h4>{t("your_itinerary_file")}</h4>
<p style="font-size: 0.9rem; color: #6c757d;">{t("text_format")}</p>
</div>
""", unsafe_allow_html=True)
st.markdown("<div>" + get_download_link(st.session_state.generated_itinerary, st.session_state.filename) + "</div>", unsafe_allow_html=True)
st.markdown("### " + t("share_itinerary"))
st.markdown("*Coming soon: Email your paper or share via social media.*")
with col2:
st.markdown("### " + t("save_for_mobile"))
st.markdown("*Coming soon: QR code for easy access on your phone*")
with visualization_tab:
st.markdown("### Visualization")
st.markdown("A conceptual diagram or visualization related to your research paper can be displayed here. (Feature under development)")
with chatbot_tab:
st.markdown("### AI ์ฑ๋ด ์ธํฐํ์ด์ค")
if "chat_history" not in st.session_state:
st.session_state.chat_history = []
user_message = st.text_input("๋ฉ์์ง๋ฅผ ์
๋ ฅํ์ธ์:", key="chat_input")
if st.button("์ ์ก", key="send_button"):
if user_message:
response = run_task(chatbot_task, user_message)
st.session_state.chat_history.append({
"speaker": "์ฌ์ฉ์",
"message": user_message,
"time": datetime.now()
})
st.session_state.chat_history.append({
"speaker": "AI",
"message": response,
"time": datetime.now()
})
st.markdown("<div style='max-height:400px; overflow-y:auto; padding:10px; border:1px solid #eaeaea; border-radius:6px;'>", unsafe_allow_html=True)
for chat in st.session_state.chat_history:
time_str = chat["time"].strftime("%H:%M:%S")
st.markdown(f"**{chat['speaker']}** ({time_str}): {chat['message']}")
st.markdown("</div>", unsafe_allow_html=True)
st.markdown("""
<div style="text-align: center; padding: 20px; color: #6c757d; font-size: 0.8rem;">
<p>""" + t("built_with") + """</p>
</div>
""", unsafe_allow_html=True)
|