Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from meta_ai_api import MetaAI
|
|
|
|
| 3 |
|
| 4 |
# Initialize Meta AI API
|
| 5 |
ai = MetaAI()
|
|
@@ -26,8 +27,12 @@ def fetch_response(query):
|
|
| 26 |
|
| 27 |
def display_sources(sources):
|
| 28 |
if sources:
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
else:
|
| 32 |
st.write("No sources available.")
|
| 33 |
|
|
@@ -41,11 +46,11 @@ def main():
|
|
| 41 |
image_path = 'img/meta-ai-logo.webp' # Replace with your image's filename and extension
|
| 42 |
|
| 43 |
# Create two columns
|
| 44 |
-
col1, col2 = st.columns([1,
|
| 45 |
|
| 46 |
# Use the first column to display the image
|
| 47 |
with col1:
|
| 48 |
-
st.image(image_path, width=
|
| 49 |
|
| 50 |
# Use the second column to display the title and other content
|
| 51 |
with col2:
|
|
@@ -62,7 +67,7 @@ def main():
|
|
| 62 |
st.write(response.get('message', 'No response message.'))
|
| 63 |
|
| 64 |
# Display the AI response in a collapsible section
|
| 65 |
-
with st.expander("Show
|
| 66 |
# Display sources with clickable links in a collapsible section
|
| 67 |
display_sources(response.get('sources', []))
|
| 68 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from meta_ai_api import MetaAI
|
| 3 |
+
from urllib.parse import urlparse
|
| 4 |
|
| 5 |
# Initialize Meta AI API
|
| 6 |
ai = MetaAI()
|
|
|
|
| 27 |
|
| 28 |
def display_sources(sources):
|
| 29 |
if sources:
|
| 30 |
+
with st.expander("Show Sources"):
|
| 31 |
+
for source in sources:
|
| 32 |
+
# Parse the domain from the URL
|
| 33 |
+
domain = urlparse(source['link']).netloc
|
| 34 |
+
# Format and display the domain and title
|
| 35 |
+
st.markdown(f"- **{domain}**: [{source['title']}]({source['link']})", unsafe_allow_html=True)
|
| 36 |
else:
|
| 37 |
st.write("No sources available.")
|
| 38 |
|
|
|
|
| 46 |
image_path = 'img/meta-ai-logo.webp' # Replace with your image's filename and extension
|
| 47 |
|
| 48 |
# Create two columns
|
| 49 |
+
col1, col2 = st.columns([1, 2]) # Adjust the ratio as needed for your layout
|
| 50 |
|
| 51 |
# Use the first column to display the image
|
| 52 |
with col1:
|
| 53 |
+
st.image(image_path, width=60)
|
| 54 |
|
| 55 |
# Use the second column to display the title and other content
|
| 56 |
with col2:
|
|
|
|
| 67 |
st.write(response.get('message', 'No response message.'))
|
| 68 |
|
| 69 |
# Display the AI response in a collapsible section
|
| 70 |
+
with st.expander("Show Sources"):
|
| 71 |
# Display sources with clickable links in a collapsible section
|
| 72 |
display_sources(response.get('sources', []))
|
| 73 |
|