Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -207,8 +207,8 @@ class GEOSEOApp:
|
|
| 207 |
options=[
|
| 208 |
"standard",
|
| 209 |
"seo",
|
| 210 |
-
"competitive",
|
| 211 |
-
"voice_search",
|
| 212 |
# "batch_optimize",
|
| 213 |
# "content_variations",
|
| 214 |
"readability_analysis",
|
|
@@ -217,8 +217,8 @@ class GEOSEOApp:
|
|
| 217 |
format_func=lambda x: {
|
| 218 |
"standard": "π§ Standard Enhancement",
|
| 219 |
"seo": "π SEO-Focused Optimization",
|
| 220 |
-
"competitive": "π Competitive Analysis",
|
| 221 |
-
"voice_search": "π€ Voice Search Optimization",
|
| 222 |
# "batch_optimize": "π¦ Batch Optimization",
|
| 223 |
# "content_variations": "π Content Variations",
|
| 224 |
"readability_analysis": "π Readability Analysis",
|
|
@@ -230,24 +230,24 @@ class GEOSEOApp:
|
|
| 230 |
|
| 231 |
with col2:
|
| 232 |
# Additional options based on optimization type
|
| 233 |
-
if optimization_type in ["standard", "seo", "competitive", "
|
| 234 |
analyze_only = st.checkbox("Analysis only (no rewriting)", value=False)
|
| 235 |
-
include_keywords = st.checkbox("Include keyword suggestions", value=True)
|
| 236 |
# elif optimization_type == "batch_optimize":
|
| 237 |
# st.info("For batch optimization, separate multiple content pieces with '---' in the text area above")
|
| 238 |
# elif optimization_type == "content_variations":
|
| 239 |
# num_variations = st.slider("Number of variations", min_value=1, max_value=5, value=3)
|
| 240 |
else:
|
| 241 |
analyze_only = False
|
| 242 |
-
include_keywords = True
|
| 243 |
# num_variations = 3
|
| 244 |
|
| 245 |
# Show description based on optimization type
|
| 246 |
optimization_descriptions = {
|
| 247 |
"standard": "General content enhancement focusing on clarity, structure, and AI answerability.",
|
| 248 |
"seo": "SEO-focused optimization for AI search engines with semantic keyword analysis.",
|
| 249 |
-
"competitive": "Competitive analysis against AI search best practices with gap identification.",
|
| 250 |
-
"voice_search": "Optimization for voice search and conversational AI systems.",
|
| 251 |
# "batch_optimize": "Process multiple content pieces simultaneously.",
|
| 252 |
# "content_variations": "Generate multiple optimized variations of the same content.",
|
| 253 |
"readability_analysis": "Detailed readability analysis specifically for AI systems.",
|
|
@@ -269,7 +269,8 @@ class GEOSEOApp:
|
|
| 269 |
result = self.content_optimizer.optimize_content(
|
| 270 |
input_text,
|
| 271 |
analyze_only=analyze_only,
|
| 272 |
-
include_keywords=
|
|
|
|
| 273 |
optimization_type="standard"
|
| 274 |
)
|
| 275 |
|
|
@@ -277,18 +278,19 @@ class GEOSEOApp:
|
|
| 277 |
result = self.content_optimizer.optimize_content(
|
| 278 |
input_text,
|
| 279 |
analyze_only=analyze_only,
|
| 280 |
-
include_keywords=
|
|
|
|
| 281 |
optimization_type="seo"
|
| 282 |
)
|
| 283 |
|
| 284 |
-
elif optimization_type == "competitive":
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
|
| 290 |
-
elif optimization_type == "voice_search":
|
| 291 |
-
|
| 292 |
|
| 293 |
# elif optimization_type == "batch_optimize":
|
| 294 |
# # Split content by '---' separator
|
|
@@ -333,8 +335,8 @@ class GEOSEOApp:
|
|
| 333 |
self.display_readability_results(result)
|
| 334 |
# elif optimization_type == "entity_extraction":
|
| 335 |
# self.display_entity_results(result)
|
| 336 |
-
elif optimization_type == "voice_search":
|
| 337 |
-
|
| 338 |
else:
|
| 339 |
self.display_standard_results(result, optimization_type)
|
| 340 |
|
|
@@ -555,57 +557,60 @@ class GEOSEOApp:
|
|
| 555 |
for q in questions:
|
| 556 |
st.write(f"β’ {q}")
|
| 557 |
|
| 558 |
-
def display_voice_search_results(self, result):
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
|
| 589 |
def display_export_options(self, result, optimization_type, original_text):
|
| 590 |
"""Display export options for results"""
|
| 591 |
st.markdown("### π₯ Export Results")
|
| 592 |
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
|
|
|
|
|
|
|
|
|
| 609 |
|
| 610 |
def render_website_analysis_tab(self):
|
| 611 |
"""Render Website GEO Analysis tab"""
|
|
|
|
| 207 |
options=[
|
| 208 |
"standard",
|
| 209 |
"seo",
|
| 210 |
+
# "competitive",
|
| 211 |
+
# "voice_search",
|
| 212 |
# "batch_optimize",
|
| 213 |
# "content_variations",
|
| 214 |
"readability_analysis",
|
|
|
|
| 217 |
format_func=lambda x: {
|
| 218 |
"standard": "π§ Standard Enhancement",
|
| 219 |
"seo": "π SEO-Focused Optimization",
|
| 220 |
+
# "competitive": "π Competitive Analysis",
|
| 221 |
+
# "voice_search": "π€ Voice Search Optimization",
|
| 222 |
# "batch_optimize": "π¦ Batch Optimization",
|
| 223 |
# "content_variations": "π Content Variations",
|
| 224 |
"readability_analysis": "π Readability Analysis",
|
|
|
|
| 230 |
|
| 231 |
with col2:
|
| 232 |
# Additional options based on optimization type
|
| 233 |
+
if optimization_type in ["standard", "seo", "competitive", "readability_analysis"]:
|
| 234 |
analyze_only = st.checkbox("Analysis only (no rewriting)", value=False)
|
| 235 |
+
# include_keywords = st.checkbox("Include keyword suggestions", value=True)
|
| 236 |
# elif optimization_type == "batch_optimize":
|
| 237 |
# st.info("For batch optimization, separate multiple content pieces with '---' in the text area above")
|
| 238 |
# elif optimization_type == "content_variations":
|
| 239 |
# num_variations = st.slider("Number of variations", min_value=1, max_value=5, value=3)
|
| 240 |
else:
|
| 241 |
analyze_only = False
|
| 242 |
+
# include_keywords = True
|
| 243 |
# num_variations = 3
|
| 244 |
|
| 245 |
# Show description based on optimization type
|
| 246 |
optimization_descriptions = {
|
| 247 |
"standard": "General content enhancement focusing on clarity, structure, and AI answerability.",
|
| 248 |
"seo": "SEO-focused optimization for AI search engines with semantic keyword analysis.",
|
| 249 |
+
# "competitive": "Competitive analysis against AI search best practices with gap identification.",
|
| 250 |
+
# "voice_search": "Optimization for voice search and conversational AI systems.",
|
| 251 |
# "batch_optimize": "Process multiple content pieces simultaneously.",
|
| 252 |
# "content_variations": "Generate multiple optimized variations of the same content.",
|
| 253 |
"readability_analysis": "Detailed readability analysis specifically for AI systems.",
|
|
|
|
| 269 |
result = self.content_optimizer.optimize_content(
|
| 270 |
input_text,
|
| 271 |
analyze_only=analyze_only,
|
| 272 |
+
include_keywords=True,
|
| 273 |
+
# include_keywords=include_keywords,
|
| 274 |
optimization_type="standard"
|
| 275 |
)
|
| 276 |
|
|
|
|
| 278 |
result = self.content_optimizer.optimize_content(
|
| 279 |
input_text,
|
| 280 |
analyze_only=analyze_only,
|
| 281 |
+
include_keywords=True,
|
| 282 |
+
# include_keywords=include_keywords,
|
| 283 |
optimization_type="seo"
|
| 284 |
)
|
| 285 |
|
| 286 |
+
# elif optimization_type == "competitive":
|
| 287 |
+
# result = self.content_optimizer.optimize_content(
|
| 288 |
+
# input_text,
|
| 289 |
+
# optimization_type="competitive"
|
| 290 |
+
# )
|
| 291 |
|
| 292 |
+
# elif optimization_type == "voice_search":
|
| 293 |
+
# result = self.content_optimizer.optimize_for_voice_search(input_text)
|
| 294 |
|
| 295 |
# elif optimization_type == "batch_optimize":
|
| 296 |
# # Split content by '---' separator
|
|
|
|
| 335 |
self.display_readability_results(result)
|
| 336 |
# elif optimization_type == "entity_extraction":
|
| 337 |
# self.display_entity_results(result)
|
| 338 |
+
# elif optimization_type == "voice_search":
|
| 339 |
+
# self.display_voice_search_results(result)
|
| 340 |
else:
|
| 341 |
self.display_standard_results(result, optimization_type)
|
| 342 |
|
|
|
|
| 557 |
for q in questions:
|
| 558 |
st.write(f"β’ {q}")
|
| 559 |
|
| 560 |
+
# def display_voice_search_results(self, result):
|
| 561 |
+
# """Display voice search optimization results"""
|
| 562 |
+
# st.markdown("### π€ Voice Search Optimization")
|
| 563 |
+
|
| 564 |
+
# # Conversational score
|
| 565 |
+
# conv_score = result.get('conversational_score', 0)
|
| 566 |
+
# if conv_score:
|
| 567 |
+
# st.metric("Conversational Score", f"{conv_score}/10")
|
| 568 |
+
|
| 569 |
+
# # Question-answer pairs
|
| 570 |
+
# qa_pairs = result.get('question_answer_pairs', [])
|
| 571 |
+
# if qa_pairs:
|
| 572 |
+
# st.markdown("#### β Question-Answer Pairs")
|
| 573 |
+
# for qa in qa_pairs:
|
| 574 |
+
# st.write(f"**Q:** {qa.get('question', '')}")
|
| 575 |
+
# st.write(f"**A:** {qa.get('answer', '')}")
|
| 576 |
+
# st.write("---")
|
| 577 |
+
|
| 578 |
+
# # Featured snippet candidates
|
| 579 |
+
# snippets = result.get('featured_snippet_candidates', [])
|
| 580 |
+
# if snippets:
|
| 581 |
+
# st.markdown("#### π Featured Snippet Candidates")
|
| 582 |
+
# for i, snippet in enumerate(snippets, 1):
|
| 583 |
+
# st.write(f"**{i}.** {snippet}")
|
| 584 |
+
|
| 585 |
+
# # Voice optimized content
|
| 586 |
+
# voice_content = result.get('voice_optimized_content', '')
|
| 587 |
+
# if voice_content:
|
| 588 |
+
# st.markdown("#### π€ Voice-Optimized Content")
|
| 589 |
+
# st.text_area("Conversational version:", value=voice_content, height=200, key="voice_output")
|
| 590 |
|
| 591 |
def display_export_options(self, result, optimization_type, original_text):
|
| 592 |
"""Display export options for results"""
|
| 593 |
st.markdown("### π₯ Export Results")
|
| 594 |
|
| 595 |
+
# Prepare export data
|
| 596 |
+
export_data = {
|
| 597 |
+
'timestamp': time.time(),
|
| 598 |
+
'optimization_type': optimization_type,
|
| 599 |
+
'original_text': original_text,
|
| 600 |
+
'original_word_count': len(original_text.split()),
|
| 601 |
+
'results': result
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
# Serialize data to JSON
|
| 605 |
+
export_json = json.dumps(export_data, indent=2)
|
| 606 |
+
|
| 607 |
+
# Add download button for direct download
|
| 608 |
+
st.download_button(
|
| 609 |
+
label="π₯ Download Analysis Report",
|
| 610 |
+
data=export_json,
|
| 611 |
+
file_name=f"{optimization_type}_analysis_{int(time.time())}.json",
|
| 612 |
+
mime="application/json"
|
| 613 |
+
)
|
| 614 |
|
| 615 |
def render_website_analysis_tab(self):
|
| 616 |
"""Render Website GEO Analysis tab"""
|