cyberandy commited on
Commit
e958e6a
1 Parent(s): 62435e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -9,9 +9,12 @@ def fetch_response(query):
9
  return response
10
 
11
  def display_sources(sources):
12
- with st.expander("Show Sources"):
13
- for source in sources:
14
- st.markdown(f"[{source['title']}]({source['link']})", unsafe_allow_html=True)
 
 
 
15
 
16
  def main():
17
  st.title("AI Response Analytics Tool")
@@ -24,16 +27,12 @@ def main():
24
  # Fetching response from Meta AI
25
  response = fetch_response(user_query)
26
 
27
- # Display the AI response directly
28
- st.write("### AI Response")
29
- st.write(response['message'])
30
-
31
- # Display sources with clickable links in a collapsible section
32
- if 'sources' in response:
33
- display_sources(response['sources'])
34
 
35
- # Additional features such as sentiment analysis, keyword extraction, and response analysis can be added here.
36
- # Optionally, consider saving queries and responses for historical analysis or comparison.
37
 
38
  if __name__ == "__main__":
39
  main()
 
9
  return response
10
 
11
  def display_sources(sources):
12
+ if sources:
13
+ with st.expander("Show Sources"):
14
+ for source in sources:
15
+ st.markdown(f"[{source['title']}]({source['link']})", unsafe_allow_html=True)
16
+ else:
17
+ st.write("No sources available.")
18
 
19
  def main():
20
  st.title("AI Response Analytics Tool")
 
27
  # Fetching response from Meta AI
28
  response = fetch_response(user_query)
29
 
30
+ # Display the AI response in a collapsible section
31
+ with st.expander("Show Full Response"):
32
+ st.write(response.get('message', 'No response message.'))
 
 
 
 
33
 
34
+ # Display sources with clickable links in a collapsible section
35
+ display_sources(response.get('sources', []))
36
 
37
  if __name__ == "__main__":
38
  main()