Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,12 @@ def fetch_response(query):
|
|
| 9 |
return response
|
| 10 |
|
| 11 |
def display_sources(sources):
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 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
|
| 28 |
-
st.
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
# Display sources with clickable links in a collapsible section
|
| 32 |
-
if 'sources' in response:
|
| 33 |
-
display_sources(response['sources'])
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
|
| 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()
|