MBilal-72 commited on
Commit
80586c1
Β·
verified Β·
1 Parent(s): 23d9570

added tab 4

Browse files
Files changed (1) hide show
  1. app.py +48 -2
app.py CHANGED
@@ -20,6 +20,8 @@ from utils.export import ResultExporter
20
  # Import LangChain components
21
  from langchain_groq import ChatGroq
22
  from langchain_community.embeddings import HuggingFaceEmbeddings
 
 
23
 
24
  class GEOSEOApp:
25
  """Main application class that orchestrates all components"""
@@ -83,10 +85,11 @@ class GEOSEOApp:
83
  self.render_sidebar()
84
 
85
  # Main tabs
86
- tab1, tab2, tab3 = st.tabs([
87
  "🌐 Website GEO Analysis",
88
  "πŸ”§ GEO Content Enhancement",
89
- "πŸ“„ Document Q&A",
 
90
  ])
91
 
92
  with tab1:
@@ -97,6 +100,9 @@ class GEOSEOApp:
97
 
98
  with tab3:
99
  self.render_document_qa_tab()
 
 
 
100
 
101
  def render_sidebar(self):
102
  """Render sidebar with information and controls"""
@@ -923,6 +929,46 @@ class GEOSEOApp:
923
  tmp_file.write(uploaded_file.read())
924
  return tmp_file.name
925
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
926
 
927
  def main():
928
  """Main entry point"""
 
20
  # Import LangChain components
21
  from langchain_groq import ChatGroq
22
  from langchain_community.embeddings import HuggingFaceEmbeddings
23
+ from langchain.prompts import ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate
24
+ from langchain_core.messages import AIMessage, HumanMessage
25
 
26
  class GEOSEOApp:
27
  """Main application class that orchestrates all components"""
 
85
  self.render_sidebar()
86
 
87
  # Main tabs
88
+ tab1, tab2, tab3, tab4 = st.tabs([
89
  "🌐 Website GEO Analysis",
90
  "πŸ”§ GEO Content Enhancement",
91
+ "πŸ“„ Document Q&A",
92
+ "🧠 Generate GEO Content",
93
  ])
94
 
95
  with tab1:
 
100
 
101
  with tab3:
102
  self.render_document_qa_tab()
103
+ with tab4:
104
+ self.render_generate_geo_content_tab()
105
+
106
 
107
  def render_sidebar(self):
108
  """Render sidebar with information and controls"""
 
929
  tmp_file.write(uploaded_file.read())
930
  return tmp_file.name
931
 
932
+ def render_generate_geo_content_tab(self):
933
+ """Tab to generate fresh GEO-optimized content using system prompts"""
934
+ st.header("🧠 Generate GEO Content")
935
+ st.markdown("Use this tool to generate AI-optimized content from scratch based on your topic or query.")
936
+
937
+ # User input
938
+ user_prompt = st.text_area("Describe the content you want (e.g., topic, style, target audience):", height=150)
939
+
940
+ # Continue chat option
941
+ if "chat_history" not in st.session_state:
942
+ st.session_state.chat_history = []
943
+
944
+ if st.button("🧠 Generate Content"):
945
+ if not user_prompt.strip():
946
+ st.warning("Please enter a topic or description.")
947
+ return
948
+
949
+ # Add user message to chat history
950
+ st.session_state.chat_history.append(HumanMessage(content=user_prompt))
951
+
952
+ # Define system prompt for GEO content generation
953
+ system_prompt = (
954
+ "You are a Generative Engine Optimization (GEO) content creation specialist. "
955
+ "Create content that is highly optimized for AI systems, LLMs, and generative search engines. "
956
+ "Ensure the content includes rich semantics, clear structure, relevant keywords, and is suitable for conversational use, citations, and AI summaries."
957
+ )
958
+ st.session_state.chat_history.insert(0, SystemMessagePromptTemplate.from_template(system_prompt).format())
959
+
960
+ with st.spinner("Generating GEO-optimized content..."):
961
+ response = self.llm.invoke(st.session_state.chat_history)
962
+ st.session_state.chat_history.append(AIMessage(content=response.content))
963
+ st.success("βœ… Content generated successfully!")
964
+
965
+ # Display chat history
966
+ for msg in st.session_state.chat_history:
967
+ if isinstance(msg, HumanMessage):
968
+ st.markdown(f"**πŸ§‘ You:** {msg.content}")
969
+ elif isinstance(msg, AIMessage):
970
+ st.markdown(f"**πŸ€– Assistant:** {msg.content}")
971
+
972
 
973
  def main():
974
  """Main entry point"""