Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -644,7 +644,11 @@ if st.button("Run Story Graph"):
|
|
| 644 |
st.warning("Please process documents first before running the story graph.")
|
| 645 |
else:
|
| 646 |
with st.spinner("Generating subtopics and stories..."):
|
| 647 |
-
result = st.session_state.rag_system.run_multiagent_storygraph(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 648 |
|
| 649 |
subtopics = result.get("sub_topic_list", [])
|
| 650 |
st.markdown("### π§ Extracted Subtopics")
|
|
@@ -655,16 +659,40 @@ if st.button("Run Story Graph"):
|
|
| 655 |
if stories:
|
| 656 |
st.markdown("### π Generated Stories")
|
| 657 |
|
| 658 |
-
# Present stories in tabs
|
| 659 |
tabs = st.tabs([f"Story {i+1}" for i in range(len(stories))])
|
| 660 |
-
for tab, story in zip(tabs, stories):
|
| 661 |
with tab:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 662 |
st.markdown(story.content)
|
| 663 |
else:
|
| 664 |
st.warning("No stories were generated.")
|
| 665 |
|
| 666 |
|
| 667 |
|
|
|
|
| 668 |
# Step 5: Generate Podcast
|
| 669 |
st.subheader("Step 4: Generate Podcast")
|
| 670 |
st.write("Select Podcast Language:")
|
|
|
|
| 644 |
st.warning("Please process documents first before running the story graph.")
|
| 645 |
else:
|
| 646 |
with st.spinner("Generating subtopics and stories..."):
|
| 647 |
+
result = st.session_state.rag_system.run_multiagent_storygraph(
|
| 648 |
+
topic=story_topic,
|
| 649 |
+
context=story_context,
|
| 650 |
+
language=story_language # Pass selected language to story generator
|
| 651 |
+
)
|
| 652 |
|
| 653 |
subtopics = result.get("sub_topic_list", [])
|
| 654 |
st.markdown("### π§ Extracted Subtopics")
|
|
|
|
| 659 |
if stories:
|
| 660 |
st.markdown("### π Generated Stories")
|
| 661 |
|
|
|
|
| 662 |
tabs = st.tabs([f"Story {i+1}" for i in range(len(stories))])
|
| 663 |
+
for i, (tab, story) in enumerate(zip(tabs, stories)):
|
| 664 |
with tab:
|
| 665 |
+
st.markdown("#### π¨ Concept Visual")
|
| 666 |
+
|
| 667 |
+
# Prompt for the diagram using story language
|
| 668 |
+
visual_prompt = f"""
|
| 669 |
+
A colorful hand-drawn educational illustration in {story_language}, labeled and clear.
|
| 670 |
+
Topic: {story_topic}
|
| 671 |
+
Subtopic: {subtopics[i] if i < len(subtopics) else 'Concept'}
|
| 672 |
+
Style: for middle school students, simple icons, visually intuitive.
|
| 673 |
+
"""
|
| 674 |
+
|
| 675 |
+
try:
|
| 676 |
+
image, _ = infer(
|
| 677 |
+
prompt=visual_prompt,
|
| 678 |
+
seed=42,
|
| 679 |
+
randomize_seed=True,
|
| 680 |
+
width=1024,
|
| 681 |
+
height=1024,
|
| 682 |
+
num_inference_steps=4
|
| 683 |
+
)
|
| 684 |
+
st.image(image, caption="Concept Visual", use_column_width=True)
|
| 685 |
+
except Exception as e:
|
| 686 |
+
st.error(f"Diagram generation failed: {e}")
|
| 687 |
+
|
| 688 |
+
st.markdown("#### βοΈ Story")
|
| 689 |
st.markdown(story.content)
|
| 690 |
else:
|
| 691 |
st.warning("No stories were generated.")
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
+
|
| 696 |
# Step 5: Generate Podcast
|
| 697 |
st.subheader("Step 4: Generate Podcast")
|
| 698 |
st.write("Select Podcast Language:")
|