genaitiwari commited on
Commit
143db94
·
1 Parent(s): 473bf1f

correct ui key and spinner added

Browse files
src/langgraphagenticai/ui/streamlitui/display_result.py CHANGED
@@ -90,34 +90,35 @@ class DisplayResultStreamlit:
90
 
91
  elif usecase == "AI News":
92
  frequency = self.user_message
93
- result = graph.invoke({"messages": frequency})
94
- try:
95
- # Read the markdown file
96
- AI_NEWS_PATH = f"./AINews/{frequency.lower()}_summary.md"
97
- with open(AI_NEWS_PATH, "r") as file:
98
- markdown_content = file.read()
 
99
 
100
- # Display the markdown content in Streamlit
101
- st.markdown(markdown_content, unsafe_allow_html=True)
102
- except FileNotFoundError:
103
- st.error(f"News Not Generated or File not found: {AI_NEWS_PATH}")
104
- except Exception as e:
105
- st.error(f"An error occurred: {str(e)}")
 
106
 
107
-
108
- with open(AI_NEWS_PATH, 'r') as f:
109
- st.download_button(
110
- "💾 Download Summary",
111
- f.read(),
112
- file_name=AI_NEWS_PATH,
113
- mime="text/markdown"
114
- )
115
- st.success(f"✅ Summary saved to {AI_NEWS_PATH}")
116
-
117
- # display graph
118
- if graph:
119
- st.write('state graph - workflow')
120
- st.image(graph.get_graph(xray=True).draw_mermaid_png())
121
 
122
  def _display_travel_planner_results(self):
123
  # Extract travel parameters from message
 
90
 
91
  elif usecase == "AI News":
92
  frequency = self.user_message
93
+ with st.spinner("Fetching and summarizing news... ⏳"):
94
+ result = graph.invoke({"messages": frequency})
95
+ try:
96
+ # Read the markdown file
97
+ AI_NEWS_PATH = f"./AINews/{frequency.lower()}_summary.md"
98
+ with open(AI_NEWS_PATH, "r") as file:
99
+ markdown_content = file.read()
100
 
101
+ # Display the markdown content in Streamlit
102
+ st.markdown(markdown_content, unsafe_allow_html=True)
103
+ except FileNotFoundError:
104
+ st.error(f"News Not Generated or File not found: {AI_NEWS_PATH}")
105
+ except Exception as e:
106
+ st.error(f"An error occurred: {str(e)}")
107
+
108
 
109
+ with open(AI_NEWS_PATH, 'r') as f:
110
+ st.download_button(
111
+ "💾 Download Summary",
112
+ f.read(),
113
+ file_name=AI_NEWS_PATH,
114
+ mime="text/markdown"
115
+ )
116
+ st.success(f"✅ Summary saved to {AI_NEWS_PATH}")
117
+
118
+ # display graph
119
+ if graph:
120
+ st.write('state graph - workflow')
121
+ st.image(graph.get_graph(xray=True).draw_mermaid_png())
 
122
 
123
  def _display_travel_planner_results(self):
124
  # Extract travel parameters from message
src/langgraphagenticai/ui/streamlitui/loadui.py CHANGED
@@ -37,7 +37,7 @@ class LoadStreamlitUI:
37
  type="password")
38
  # Validate API key
39
  if not self.user_controls["GROQ_API_KEY"]:
40
- st.warning("⚠️ Please enter your GROQ API key to proceed.")
41
 
42
 
43
  # Use case selection
@@ -47,7 +47,9 @@ class LoadStreamlitUI:
47
  # API key input
48
  os.environ["TAVILY_API_KEY"] = self.user_controls["TAVILY_API_KEY"] = st.session_state["TAVILY_API_KEY"] = st.text_input("TAVILY API KEY",
49
  type="password")
50
-
 
 
51
  if self.user_controls['selected_usecase'] == "Appointment Receptionist":
52
  col1, col2 = st.columns(2)
53
  with col1:
 
37
  type="password")
38
  # Validate API key
39
  if not self.user_controls["GROQ_API_KEY"]:
40
+ st.warning("⚠️ Please enter your GROQ API key to proceed. Don't have? refer : https://console.groq.com/keys ")
41
 
42
 
43
  # Use case selection
 
47
  # API key input
48
  os.environ["TAVILY_API_KEY"] = self.user_controls["TAVILY_API_KEY"] = st.session_state["TAVILY_API_KEY"] = st.text_input("TAVILY API KEY",
49
  type="password")
50
+ # Validate API key
51
+ if not self.user_controls["TAVILY_API_KEY"]:
52
+ st.warning("⚠️ Please enter your TAVILY_API_KEY key to proceed. Don't have? refer : https://app.tavily.com/home")
53
  if self.user_controls['selected_usecase'] == "Appointment Receptionist":
54
  col1, col2 = st.columns(2)
55
  with col1: