Update app.py
Browse files
app.py
CHANGED
|
@@ -15,11 +15,14 @@ from utils.scorer import GEOScorer
|
|
| 15 |
from utils.optimizer import ContentOptimizer
|
| 16 |
from utils.chunker import VectorChunker
|
| 17 |
from utils.export import ResultExporter
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Import LangChain components
|
| 20 |
from langchain_groq import ChatGroq
|
| 21 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 22 |
|
|
|
|
| 23 |
class GEOSEOApp:
|
| 24 |
"""Main application class that orchestrates all components"""
|
| 25 |
|
|
@@ -82,6 +85,7 @@ class GEOSEOApp:
|
|
| 82 |
"π Website GEO Analysis",
|
| 83 |
"π§ Content Enhancement",
|
| 84 |
"π Document Q&A",
|
|
|
|
| 85 |
])
|
| 86 |
|
| 87 |
with tab1:
|
|
@@ -92,6 +96,8 @@ class GEOSEOApp:
|
|
| 92 |
|
| 93 |
with tab3:
|
| 94 |
self.render_document_qa_tab()
|
|
|
|
|
|
|
| 95 |
|
| 96 |
def render_sidebar(self):
|
| 97 |
"""Render sidebar with information and controls"""
|
|
@@ -364,6 +370,22 @@ class GEOSEOApp:
|
|
| 364 |
|
| 365 |
except Exception as e:
|
| 366 |
st.error(f"An error occurred during website analysis: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
|
| 368 |
def display_geo_results(self, geo_results: List[Dict], website_url: str):
|
| 369 |
"""Display GEO analysis results"""
|
|
@@ -439,6 +461,7 @@ class GEOSEOApp:
|
|
| 439 |
|
| 440 |
st.write("---")
|
| 441 |
|
|
|
|
| 442 |
def display_recommendations(self, geo_results: List[Dict]):
|
| 443 |
"""Display optimization recommendations"""
|
| 444 |
st.markdown("### π‘ Optimization Recommendations")
|
|
|
|
| 15 |
from utils.optimizer import ContentOptimizer
|
| 16 |
from utils.chunker import VectorChunker
|
| 17 |
from utils.export import ResultExporter
|
| 18 |
+
from utils.lang_utils import detect_language, translate_text
|
| 19 |
+
|
| 20 |
|
| 21 |
# Import LangChain components
|
| 22 |
from langchain_groq import ChatGroq
|
| 23 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 24 |
|
| 25 |
+
|
| 26 |
class GEOSEOApp:
|
| 27 |
"""Main application class that orchestrates all components"""
|
| 28 |
|
|
|
|
| 85 |
"π Website GEO Analysis",
|
| 86 |
"π§ Content Enhancement",
|
| 87 |
"π Document Q&A",
|
| 88 |
+
"π Translation"
|
| 89 |
])
|
| 90 |
|
| 91 |
with tab1:
|
|
|
|
| 96 |
|
| 97 |
with tab3:
|
| 98 |
self.render_document_qa_tab()
|
| 99 |
+
with tab4:
|
| 100 |
+
self.render_multilingual_tab()
|
| 101 |
|
| 102 |
def render_sidebar(self):
|
| 103 |
"""Render sidebar with information and controls"""
|
|
|
|
| 370 |
|
| 371 |
except Exception as e:
|
| 372 |
st.error(f"An error occurred during website analysis: {str(e)}")
|
| 373 |
+
|
| 374 |
+
def render_multilingual_tab(self):
|
| 375 |
+
st.markdown("### π Multilingual Translator")
|
| 376 |
+
st.write("Detect language and translate text into a target language.")
|
| 377 |
+
|
| 378 |
+
text = st.text_area("Enter text:")
|
| 379 |
+
if text:
|
| 380 |
+
detected_lang = detect_language(text)
|
| 381 |
+
st.write(f"Detected Language: **{detected_lang}**")
|
| 382 |
+
|
| 383 |
+
target = st.selectbox("Select target language", ["en", "fr", "es", "de", "ur", "hi", "zh", "ar", "ru"])
|
| 384 |
+
if st.button("Translate"):
|
| 385 |
+
result = translate_text(text, target)
|
| 386 |
+
st.success("Translation:")
|
| 387 |
+
st.write(result)
|
| 388 |
+
|
| 389 |
|
| 390 |
def display_geo_results(self, geo_results: List[Dict], website_url: str):
|
| 391 |
"""Display GEO analysis results"""
|
|
|
|
| 461 |
|
| 462 |
st.write("---")
|
| 463 |
|
| 464 |
+
|
| 465 |
def display_recommendations(self, geo_results: List[Dict]):
|
| 466 |
"""Display optimization recommendations"""
|
| 467 |
st.markdown("### π‘ Optimization Recommendations")
|