Spaces:
Running
Running
update app.py
Browse files
app.py
CHANGED
@@ -4,20 +4,41 @@ from meta_ai_api import MetaAI
|
|
4 |
# Initialize Meta AI API
|
5 |
ai = MetaAI()
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
def fetch_response(query):
|
8 |
response = ai.prompt(message=query)
|
9 |
return response
|
10 |
|
11 |
def display_sources(sources):
|
12 |
if sources:
|
13 |
-
with st.expander("
|
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
|
21 |
|
22 |
# User input
|
23 |
user_query = st.text_area("Enter your query:", height=150)
|
@@ -26,13 +47,12 @@ def main():
|
|
26 |
if submit_button and user_query:
|
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 |
-
|
33 |
-
|
34 |
-
# Display sources with clickable links in a collapsible section
|
35 |
-
display_sources(response.get('sources', []))
|
36 |
-
|
37 |
if __name__ == "__main__":
|
38 |
main()
|
|
|
4 |
# Initialize Meta AI API
|
5 |
ai = MetaAI()
|
6 |
|
7 |
+
PAGE_CONFIG = {
|
8 |
+
"page_title": "Meta AI Query Analysis - a Free SEO Tool by WordLift",
|
9 |
+
"page_icon": "img/fav-ico.png",
|
10 |
+
"layout": "centered"
|
11 |
+
}
|
12 |
+
|
13 |
+
def local_css(file_name):
|
14 |
+
with open(file_name) as f:
|
15 |
+
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
|
16 |
+
|
17 |
+
|
18 |
+
st.set_page_config(**PAGE_CONFIG)
|
19 |
+
|
20 |
+
local_css("style.css")
|
21 |
+
|
22 |
+
|
23 |
def fetch_response(query):
|
24 |
response = ai.prompt(message=query)
|
25 |
return response
|
26 |
|
27 |
def display_sources(sources):
|
28 |
if sources:
|
29 |
+
with st.expander("INSPECT THE REPORT - SOURCES"):
|
30 |
for source in sources:
|
31 |
st.markdown(f"[{source['title']}]({source['link']})", unsafe_allow_html=True)
|
32 |
else:
|
33 |
st.write("No sources available.")
|
34 |
|
35 |
+
# ---------------------------------------------------------------------------- #
|
36 |
+
# Main Function
|
37 |
+
# ---------------------------------------------------------------------------- #
|
38 |
+
|
39 |
+
|
40 |
def main():
|
41 |
+
st.title("Meta AI SEO Tool")
|
42 |
|
43 |
# User input
|
44 |
user_query = st.text_area("Enter your query:", height=150)
|
|
|
47 |
if submit_button and user_query:
|
48 |
# Fetching response from Meta AI
|
49 |
response = fetch_response(user_query)
|
50 |
+
|
51 |
+
st.write(response.get('message', 'No response message.'))
|
52 |
|
53 |
# Display the AI response in a collapsible section
|
54 |
with st.expander("Show Full Response"):
|
55 |
+
display_sources(response.get('sources', []))
|
56 |
+
|
|
|
|
|
|
|
57 |
if __name__ == "__main__":
|
58 |
main()
|