Spaces:
Sleeping
Sleeping
Update pages/Latest.py
Browse files- pages/Latest.py +16 -12
pages/Latest.py
CHANGED
|
@@ -75,20 +75,24 @@ if 'titles' not in st.session_state:
|
|
| 75 |
if 'selected_title' not in st.session_state:
|
| 76 |
st.session_state.selected_title = None
|
| 77 |
|
| 78 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
try:
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
print(result)
|
| 83 |
-
st.session_state.titles = result['blog_topics']
|
| 84 |
except Exception as e:
|
| 85 |
st.error(str(e))
|
| 86 |
|
| 87 |
-
if st.session_state.titles is not None:
|
| 88 |
-
st.session_state.selected_title = st.selectbox("Pick the Title for your Blog", st.session_state.titles)
|
| 89 |
-
|
| 90 |
-
if st.button("Generate Blog") and st.session_state.selected_title is not None:
|
| 91 |
-
content = graph2.invoke({"final_topic": st.session_state.selected_title})
|
| 92 |
-
st.markdown(content['image_formated_blog'])
|
| 93 |
-
|
| 94 |
|
|
|
|
| 75 |
if 'selected_title' not in st.session_state:
|
| 76 |
st.session_state.selected_title = None
|
| 77 |
|
| 78 |
+
if input_data: # Only proceed if input_data is not empty
|
| 79 |
+
if st.button("Generate Titles"):
|
| 80 |
+
try:
|
| 81 |
+
topic = [HumanMessage(content=input_data)]
|
| 82 |
+
result = graph1.invoke({"topic": topic})
|
| 83 |
+
print(result)
|
| 84 |
+
st.session_state.titles = result.get('blog_topics', []) # Avoid KeyError
|
| 85 |
+
except Exception as e:
|
| 86 |
+
st.error(str(e))
|
| 87 |
+
|
| 88 |
+
if st.session_state.titles:
|
| 89 |
+
st.session_state.selected_title = st.selectbox("Pick the Title for your Blog", st.session_state.titles)
|
| 90 |
+
|
| 91 |
+
if st.button("Generate Blog") and st.session_state.selected_title:
|
| 92 |
try:
|
| 93 |
+
content = graph2.invoke({"final_topic": st.session_state.selected_title})
|
| 94 |
+
st.markdown(content.get('image_formated_blog', "No content generated.")) # Avoid KeyError
|
|
|
|
|
|
|
| 95 |
except Exception as e:
|
| 96 |
st.error(str(e))
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|