Update app.py
Browse files
app.py
CHANGED
|
@@ -16,11 +16,12 @@ 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 |
from langdetect import detect
|
| 25 |
from deep_translator import GoogleTranslator
|
| 26 |
def detect_and_translate_to_english(text: str) -> str:
|
|
@@ -37,6 +38,18 @@ def detect_and_translate_to_english(text: str) -> str:
|
|
| 37 |
return text
|
| 38 |
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
class GEOSEOApp:
|
| 41 |
"""Main application class that orchestrates all components"""
|
| 42 |
|
|
|
|
| 16 |
from utils.chunker import VectorChunker
|
| 17 |
from utils.export import ResultExporter
|
| 18 |
from utils.lang_utils import detect_language, translate_text
|
| 19 |
+
from rag_utils import create_vectorstore_from_text, create_rag_chain
|
| 20 |
|
| 21 |
# Import LangChain components
|
| 22 |
from langchain_groq import ChatGroq
|
| 23 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 24 |
+
|
| 25 |
from langdetect import detect
|
| 26 |
from deep_translator import GoogleTranslator
|
| 27 |
def detect_and_translate_to_english(text: str) -> str:
|
|
|
|
| 38 |
return text
|
| 39 |
|
| 40 |
|
| 41 |
+
# Assume `translated_content` is your PDF or webpage content in text format (after translation)
|
| 42 |
+
vectorstore = create_vectorstore_from_text(translated_content)
|
| 43 |
+
rag_chain = create_rag_chain(vectorstore)
|
| 44 |
+
|
| 45 |
+
# User input query
|
| 46 |
+
query = st.text_input("Ask a question related to your uploaded content:")
|
| 47 |
+
if query:
|
| 48 |
+
result = rag_chain.run(query)
|
| 49 |
+
st.success("Answer from the RAG system:")
|
| 50 |
+
st.write(result)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
class GEOSEOApp:
|
| 54 |
"""Main application class that orchestrates all components"""
|
| 55 |
|