Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -331,11 +331,11 @@ class DocumentRAG:
|
|
| 331 |
|
| 332 |
|
| 333 |
def retrieve_node(self, state: StoryState):
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 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 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
st.markdown(
|
| 573 |
-
|
| 574 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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")
|