DrishtiSharma commited on
Commit
cfa79bc
Β·
verified Β·
1 Parent(s): 9e516eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -21
app.py CHANGED
@@ -331,11 +331,11 @@ class DocumentRAG:
331
 
332
 
333
  def retrieve_node(self, state: StoryState):
334
- embedding = self._get_embedding_model()
335
- retriever = Chroma(
336
- persist_directory=self.chroma_persist_dir,
337
- embedding_function=embedding
338
- ).as_retriever(search_kwargs={"k": 20})
339
 
340
  topic = state.story_topic
341
  query = f"information about {topic}"
@@ -556,22 +556,26 @@ story_topic = st.text_input("Enter main topic:", value="Machine Learning")
556
  story_context = st.text_input("Enter learning context:", value="Education")
557
 
558
  if st.button("Run Story Graph"):
559
- with st.spinner("Generating subtopics and stories..."):
560
- result = st.session_state.rag_system.run_multiagent_storygraph(topic=story_topic, context=story_context)
561
-
562
- subtopics = result.get("sub_topic_list", [])
563
- st.markdown("### 🧠 Extracted Subtopics")
564
- for sub in subtopics:
565
- st.markdown(f"- {sub}")
566
-
567
- stories = result.get("stories", [])
568
- if stories:
569
- st.markdown("### πŸ“š Generated Stories")
570
- for i, story in enumerate(stories):
571
- st.markdown(f"**Story {i+1}:**")
572
- st.markdown(story.content)
573
- else:
574
- st.warning("No stories were generated.")
 
 
 
 
575
 
576
  # Step 5: Generate Podcast
577
  st.subheader("Step 4: Generate Podcast")
 
331
 
332
 
333
  def retrieve_node(self, state: StoryState):
334
+ if not self.document_store:
335
+ return {"retrieved_docs": [], "question": "No documents processed yet."}
336
+
337
+ retriever = self.document_store.as_retriever(search_kwargs={"k": 20})
338
+
339
 
340
  topic = state.story_topic
341
  query = f"information about {topic}"
 
556
  story_context = st.text_input("Enter learning context:", value="Education")
557
 
558
  if st.button("Run Story Graph"):
559
+ if st.session_state.rag_system.document_store is None:
560
+ st.warning("Please process documents first before running the story graph.")
561
+ else:
562
+ with st.spinner("Generating subtopics and stories..."):
563
+ result = st.session_state.rag_system.run_multiagent_storygraph(topic=story_topic, context=story_context)
564
+
565
+ subtopics = result.get("sub_topic_list", [])
566
+ st.markdown("### 🧠 Extracted Subtopics")
567
+ for sub in subtopics:
568
+ st.markdown(f"- {sub}")
569
+
570
+ stories = result.get("stories", [])
571
+ if stories:
572
+ st.markdown("### πŸ“š Generated Stories")
573
+ for i, story in enumerate(stories):
574
+ st.markdown(f"**Story {i+1}:**")
575
+ st.markdown(story.content)
576
+ else:
577
+ st.warning("No stories were generated.")
578
+
579
 
580
  # Step 5: Generate Podcast
581
  st.subheader("Step 4: Generate Podcast")