Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +52 -194
src/streamlit_app.py
CHANGED
|
@@ -21,197 +21,57 @@ st.set_page_config(
|
|
| 21 |
initial_sidebar_state="expanded"
|
| 22 |
)
|
| 23 |
|
| 24 |
-
#
|
| 25 |
st.markdown("""
|
| 26 |
<style>
|
| 27 |
-
.main {
|
| 28 |
-
padding-top: 2rem;
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
.stApp {
|
| 32 |
-
background: linear-gradient(135deg, #000000 0%, #1a1a1a 50%, #2d2d2d 100%);
|
| 33 |
-
background-attachment: fixed;
|
| 34 |
-
color: white;
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
.main .block-container {
|
| 38 |
-
background: rgba(255, 255, 255, 0.98);
|
| 39 |
-
color: #1a1a1a;
|
| 40 |
-
padding: 2rem;
|
| 41 |
-
border-radius: 20px;
|
| 42 |
-
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
| 43 |
-
backdrop-filter: blur(10px);
|
| 44 |
-
margin-top: 2rem;
|
| 45 |
-
border: 2px solid #e5e5e5;
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
.stTabs > div > div > div > div {
|
| 49 |
-
background: linear-gradient(135deg, #f8f8f8 0%, #e8e8e8 100%);
|
| 50 |
-
border: 1px solid #d1d5db;
|
| 51 |
-
border-radius: 10px;
|
| 52 |
-
padding: 1rem;
|
| 53 |
-
margin: 0.5rem 0;
|
| 54 |
-
color: #1a1a1a;
|
| 55 |
-
}
|
| 56 |
-
|
| 57 |
.metric-card {
|
| 58 |
-
background:
|
| 59 |
-
border:
|
| 60 |
-
border-radius:
|
| 61 |
padding: 1rem;
|
| 62 |
margin: 0.5rem 0;
|
| 63 |
-
color: #1a1a1a;
|
| 64 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 65 |
}
|
| 66 |
|
| 67 |
.success-card {
|
| 68 |
-
background:
|
| 69 |
-
border:
|
| 70 |
-
border-radius:
|
| 71 |
-
padding: 1rem;
|
| 72 |
-
margin: 0.5rem 0;
|
| 73 |
-
color: #1a1a1a;
|
| 74 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
.warning-card {
|
| 78 |
-
background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
|
| 79 |
-
border: 2px solid #9ca3af;
|
| 80 |
-
border-radius: 12px;
|
| 81 |
-
padding: 1rem;
|
| 82 |
-
margin: 0.5rem 0;
|
| 83 |
-
color: #1a1a1a;
|
| 84 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
.error-card {
|
| 88 |
-
background: linear-gradient(135deg, #f1f1f1 0%, #dddddd 100%);
|
| 89 |
-
border: 2px solid #6b7280;
|
| 90 |
-
border-radius: 12px;
|
| 91 |
padding: 1rem;
|
| 92 |
margin: 0.5rem 0;
|
| 93 |
-
color: #1a1a1a;
|
| 94 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
-
.stButton > button {
|
| 98 |
-
background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
|
| 99 |
-
color: white;
|
| 100 |
-
border-radius: 25px;
|
| 101 |
-
border: 2px solid #4a4a4a;
|
| 102 |
-
padding: 0.5rem 2rem;
|
| 103 |
-
font-weight: 600;
|
| 104 |
-
transition: all 0.3s ease;
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
.stButton > button:hover {
|
| 108 |
-
transform: translateY(-2px);
|
| 109 |
-
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
|
| 110 |
-
background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
|
| 111 |
-
border-color: #6b7280;
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
.sidebar .stSelectbox > div > div {
|
| 115 |
-
background: white;
|
| 116 |
-
color: #1a1a1a;
|
| 117 |
-
border: 1px solid #d1d5db;
|
| 118 |
-
border-radius: 10px;
|
| 119 |
-
}
|
| 120 |
-
|
| 121 |
-
h1 {
|
| 122 |
-
background: linear-gradient(135deg, #000000 0%, #4a4a4a 100%);
|
| 123 |
-
-webkit-background-clip: text;
|
| 124 |
-
-webkit-text-fill-color: transparent;
|
| 125 |
-
text-align: center;
|
| 126 |
-
font-size: 3rem !important;
|
| 127 |
-
margin-bottom: 2rem !important;
|
| 128 |
-
font-weight: 800;
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
.stProgress > div > div > div > div {
|
| 132 |
-
background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
|
| 133 |
}
|
| 134 |
|
| 135 |
.keyword-chip {
|
| 136 |
-
background:
|
| 137 |
color: white;
|
| 138 |
-
padding: 0.
|
| 139 |
-
border-radius:
|
| 140 |
-
font-size: 0.
|
| 141 |
-
font-weight: 500;
|
| 142 |
-
margin: 0.2rem;
|
| 143 |
display: inline-block;
|
| 144 |
-
|
| 145 |
}
|
| 146 |
|
| 147 |
.seo-score-excellent {
|
| 148 |
-
background:
|
| 149 |
color: white;
|
| 150 |
-
padding: 0.5rem
|
| 151 |
-
border-radius:
|
| 152 |
-
font-weight: 600;
|
| 153 |
text-align: center;
|
| 154 |
-
border: 2px solid #4a4a4a;
|
| 155 |
}
|
| 156 |
|
| 157 |
.seo-score-good {
|
| 158 |
-
background:
|
| 159 |
color: white;
|
| 160 |
-
padding: 0.5rem
|
| 161 |
-
border-radius:
|
| 162 |
-
font-weight: 600;
|
| 163 |
text-align: center;
|
| 164 |
-
border: 2px solid #6b7280;
|
| 165 |
}
|
| 166 |
|
| 167 |
.seo-score-poor {
|
| 168 |
-
background:
|
| 169 |
color: white;
|
| 170 |
-
padding: 0.5rem
|
| 171 |
-
border-radius:
|
| 172 |
-
font-weight: 600;
|
| 173 |
text-align: center;
|
| 174 |
-
border: 2px solid #9ca3af;
|
| 175 |
-
}
|
| 176 |
-
|
| 177 |
-
/* Sidebar styling */
|
| 178 |
-
.css-1d391kg {
|
| 179 |
-
background: linear-gradient(135deg, #f8f8f8 0%, #e8e8e8 100%);
|
| 180 |
-
color: #1a1a1a;
|
| 181 |
-
}
|
| 182 |
-
|
| 183 |
-
/* Text inputs and textareas */
|
| 184 |
-
.stTextInput > div > div > input {
|
| 185 |
-
background: white;
|
| 186 |
-
color: #1a1a1a;
|
| 187 |
-
border: 2px solid #d1d5db;
|
| 188 |
-
border-radius: 8px;
|
| 189 |
-
}
|
| 190 |
-
|
| 191 |
-
.stTextArea > div > div > textarea {
|
| 192 |
-
background: white;
|
| 193 |
-
color: #1a1a1a;
|
| 194 |
-
border: 2px solid #d1d5db;
|
| 195 |
-
border-radius: 8px;
|
| 196 |
-
}
|
| 197 |
-
|
| 198 |
-
/* Select boxes */
|
| 199 |
-
.stSelectbox > div > div > select {
|
| 200 |
-
background: white;
|
| 201 |
-
color: #1a1a1a;
|
| 202 |
-
border: 2px solid #d1d5db;
|
| 203 |
-
}
|
| 204 |
-
|
| 205 |
-
/* Markdown text in containers */
|
| 206 |
-
.stMarkdown p {
|
| 207 |
-
color: #1a1a1a;
|
| 208 |
-
}
|
| 209 |
-
|
| 210 |
-
/* Code blocks */
|
| 211 |
-
.stCode {
|
| 212 |
-
background: #f8f8f8;
|
| 213 |
-
border: 1px solid #d1d5db;
|
| 214 |
-
color: #1a1a1a;
|
| 215 |
}
|
| 216 |
</style>
|
| 217 |
""", unsafe_allow_html=True)
|
|
@@ -427,35 +287,33 @@ def main():
|
|
| 427 |
st.session_state.generated_content = ""
|
| 428 |
if 'seo_analysis' not in st.session_state:
|
| 429 |
st.session_state.seo_analysis = {}
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
st.
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
# Sidebar with workflow progress
|
| 436 |
with st.sidebar:
|
| 437 |
-
st.
|
| 438 |
|
| 439 |
steps = [
|
| 440 |
-
"
|
| 441 |
-
"
|
| 442 |
-
"
|
| 443 |
-
"
|
| 444 |
]
|
| 445 |
|
| 446 |
for i, step in enumerate(steps):
|
| 447 |
if i < st.session_state.current_step:
|
| 448 |
-
st.
|
| 449 |
elif i == st.session_state.current_step:
|
| 450 |
-
st.
|
| 451 |
else:
|
| 452 |
-
st.
|
| 453 |
-
|
| 454 |
-
progress = (st.session_state.current_step + 1) / len(steps)
|
| 455 |
st.progress(progress)
|
| 456 |
-
st.
|
| 457 |
-
|
| 458 |
-
|
|
|
|
| 459 |
for key in ['current_step', 'seed_keyword', 'keywords', 'selected_keyword',
|
| 460 |
'titles', 'selected_title', 'topics', 'selected_topic',
|
| 461 |
'generated_content', 'seo_analysis']:
|
|
@@ -472,20 +330,20 @@ def main():
|
|
| 472 |
st.session_state[key] = ""
|
| 473 |
st.rerun()
|
| 474 |
|
| 475 |
-
#
|
| 476 |
st.markdown("---")
|
| 477 |
-
st.
|
| 478 |
-
st.
|
| 479 |
-
st.
|
| 480 |
-
st.
|
| 481 |
|
| 482 |
# Main content area with tabs
|
| 483 |
-
tab1, tab2, tab3, tab4, tab5 = st.tabs(["
|
| 484 |
|
| 485 |
# Tab 1: Keyword Research
|
| 486 |
with tab1:
|
| 487 |
-
st.
|
| 488 |
-
st.
|
| 489 |
|
| 490 |
col1, col2 = st.columns([2, 1])
|
| 491 |
|
|
@@ -497,7 +355,7 @@ def main():
|
|
| 497 |
)
|
| 498 |
|
| 499 |
with col2:
|
| 500 |
-
research_button = st.button("
|
| 501 |
|
| 502 |
if research_button and seed_keyword:
|
| 503 |
with st.spinner("Analyzing your keyword and finding related suggestions..."):
|
|
@@ -508,23 +366,23 @@ def main():
|
|
| 508 |
st.session_state.current_step = max(st.session_state.current_step, 1)
|
| 509 |
|
| 510 |
if st.session_state.keywords:
|
| 511 |
-
st.
|
| 512 |
st.markdown(f'<div class="keyword-chip">Based on: "{st.session_state.seed_keyword}"</div>', unsafe_allow_html=True)
|
| 513 |
|
| 514 |
cols = st.columns(2)
|
| 515 |
for i, keyword in enumerate(st.session_state.keywords):
|
| 516 |
with cols[i % 2]:
|
| 517 |
-
if st.button(f"
|
| 518 |
st.session_state.selected_keyword = keyword
|
| 519 |
st.session_state.current_step = max(st.session_state.current_step, 1)
|
| 520 |
-
st.success(f"
|
| 521 |
time.sleep(1)
|
| 522 |
st.rerun()
|
| 523 |
|
| 524 |
if st.session_state.selected_keyword:
|
| 525 |
st.markdown('<div class="success-card">', unsafe_allow_html=True)
|
| 526 |
-
st.
|
| 527 |
-
st.
|
| 528 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 529 |
|
| 530 |
# Tab 2: Title Generation
|
|
|
|
| 21 |
initial_sidebar_state="expanded"
|
| 22 |
)
|
| 23 |
|
| 24 |
+
# Simple CSS styling
|
| 25 |
st.markdown("""
|
| 26 |
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
.metric-card {
|
| 28 |
+
background: #f8f9fa;
|
| 29 |
+
border: 1px solid #dee2e6;
|
| 30 |
+
border-radius: 5px;
|
| 31 |
padding: 1rem;
|
| 32 |
margin: 0.5rem 0;
|
|
|
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
.success-card {
|
| 36 |
+
background: #f8f9fa;
|
| 37 |
+
border: 1px solid #28a745;
|
| 38 |
+
border-radius: 5px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
padding: 1rem;
|
| 40 |
margin: 0.5rem 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
.keyword-chip {
|
| 44 |
+
background: #333;
|
| 45 |
color: white;
|
| 46 |
+
padding: 0.25rem 0.5rem;
|
| 47 |
+
border-radius: 15px;
|
| 48 |
+
font-size: 0.875rem;
|
|
|
|
|
|
|
| 49 |
display: inline-block;
|
| 50 |
+
margin: 0.25rem;
|
| 51 |
}
|
| 52 |
|
| 53 |
.seo-score-excellent {
|
| 54 |
+
background: #333;
|
| 55 |
color: white;
|
| 56 |
+
padding: 0.5rem;
|
| 57 |
+
border-radius: 5px;
|
|
|
|
| 58 |
text-align: center;
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
.seo-score-good {
|
| 62 |
+
background: #666;
|
| 63 |
color: white;
|
| 64 |
+
padding: 0.5rem;
|
| 65 |
+
border-radius: 5px;
|
|
|
|
| 66 |
text-align: center;
|
|
|
|
| 67 |
}
|
| 68 |
|
| 69 |
.seo-score-poor {
|
| 70 |
+
background: #999;
|
| 71 |
color: white;
|
| 72 |
+
padding: 0.5rem;
|
| 73 |
+
border-radius: 5px;
|
|
|
|
| 74 |
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
}
|
| 76 |
</style>
|
| 77 |
""", unsafe_allow_html=True)
|
|
|
|
| 287 |
st.session_state.generated_content = ""
|
| 288 |
if 'seo_analysis' not in st.session_state:
|
| 289 |
st.session_state.seo_analysis = {}
|
| 290 |
+
# Header
|
| 291 |
+
st.title("SEO Content Writer")
|
| 292 |
+
st.write("AI-powered content creation with real-time SEO optimization")
|
| 293 |
+
# Sidebar with workflow progress
|
|
|
|
|
|
|
| 294 |
with st.sidebar:
|
| 295 |
+
st.subheader("Workflow Progress")
|
| 296 |
|
| 297 |
steps = [
|
| 298 |
+
"Keyword Research",
|
| 299 |
+
"Title Generation",
|
| 300 |
+
"Topic Selection",
|
| 301 |
+
"Content Creation"
|
| 302 |
]
|
| 303 |
|
| 304 |
for i, step in enumerate(steps):
|
| 305 |
if i < st.session_state.current_step:
|
| 306 |
+
st.write(f"✓ {step}")
|
| 307 |
elif i == st.session_state.current_step:
|
| 308 |
+
st.write(f"→ **{step}**")
|
| 309 |
else:
|
| 310 |
+
st.write(f"○ {step}")
|
| 311 |
+
progress = (st.session_state.current_step + 1) / len(steps)
|
|
|
|
| 312 |
st.progress(progress)
|
| 313 |
+
st.write(f"**{int(progress * 100)}% Complete**")
|
| 314 |
+
|
| 315 |
+
# Reset workflow button
|
| 316 |
+
if st.button("Start New Project"):
|
| 317 |
for key in ['current_step', 'seed_keyword', 'keywords', 'selected_keyword',
|
| 318 |
'titles', 'selected_title', 'topics', 'selected_topic',
|
| 319 |
'generated_content', 'seo_analysis']:
|
|
|
|
| 330 |
st.session_state[key] = ""
|
| 331 |
st.rerun()
|
| 332 |
|
| 333 |
+
# Project info
|
| 334 |
st.markdown("---")
|
| 335 |
+
st.write("**Project Info**")
|
| 336 |
+
st.write("[Full Project Repository](https://github.com/akshayram1/AI_Content_Writer_Prototype)")
|
| 337 |
+
st.caption("Originally attempted deployment on Vercel and Railway, but free tier limitations prevented deploying the full LLM service stack.")
|
| 338 |
+
st.caption("Built with Streamlit and OpenAI")
|
| 339 |
|
| 340 |
# Main content area with tabs
|
| 341 |
+
tab1, tab2, tab3, tab4, tab5 = st.tabs(["Keywords", "Titles", "Topics", "Content", "SEO Test"])
|
| 342 |
|
| 343 |
# Tab 1: Keyword Research
|
| 344 |
with tab1:
|
| 345 |
+
st.subheader("Keyword Research")
|
| 346 |
+
st.write("Discover high-impact keywords to boost your content's SEO potential")
|
| 347 |
|
| 348 |
col1, col2 = st.columns([2, 1])
|
| 349 |
|
|
|
|
| 355 |
)
|
| 356 |
|
| 357 |
with col2:
|
| 358 |
+
research_button = st.button("Research Keywords", type="primary")
|
| 359 |
|
| 360 |
if research_button and seed_keyword:
|
| 361 |
with st.spinner("Analyzing your keyword and finding related suggestions..."):
|
|
|
|
| 366 |
st.session_state.current_step = max(st.session_state.current_step, 1)
|
| 367 |
|
| 368 |
if st.session_state.keywords:
|
| 369 |
+
st.write("**Suggested Keywords**")
|
| 370 |
st.markdown(f'<div class="keyword-chip">Based on: "{st.session_state.seed_keyword}"</div>', unsafe_allow_html=True)
|
| 371 |
|
| 372 |
cols = st.columns(2)
|
| 373 |
for i, keyword in enumerate(st.session_state.keywords):
|
| 374 |
with cols[i % 2]:
|
| 375 |
+
if st.button(f"{keyword}", key=f"keyword_{i}", use_container_width=True):
|
| 376 |
st.session_state.selected_keyword = keyword
|
| 377 |
st.session_state.current_step = max(st.session_state.current_step, 1)
|
| 378 |
+
st.success(f"Selected keyword: **{keyword}**")
|
| 379 |
time.sleep(1)
|
| 380 |
st.rerun()
|
| 381 |
|
| 382 |
if st.session_state.selected_keyword:
|
| 383 |
st.markdown('<div class="success-card">', unsafe_allow_html=True)
|
| 384 |
+
st.write(f"**Great choice!** Keyword selected: **{st.session_state.selected_keyword}**")
|
| 385 |
+
st.write("Ready to generate titles! The workflow will continue automatically.")
|
| 386 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 387 |
|
| 388 |
# Tab 2: Title Generation
|