cyberandy commited on
Commit
645bb63
1 Parent(s): aac7c38

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from meta_ai_api import MetaAI
3
+
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
+ st.write("### Sources")
13
+ for source in sources:
14
+ st.markdown(f"[{source['title']}]({source['link']})")
15
+
16
+ def main():
17
+ st.title("AI Response Analytics Tool")
18
+
19
+ # User input
20
+ user_query = st.text_area("Enter your query:", height=150)
21
+ submit_button = st.button("Analyze Query")
22
+
23
+ if submit_button and user_query:
24
+ # Fetching response from Meta AI
25
+ response = fetch_response(user_query)
26
+ st.write("### AI Response")
27
+ st.write(response['message'])
28
+
29
+ # Display sources with clickable links
30
+ if 'sources' in response:
31
+ display_sources(response['sources'])
32
+
33
+ # Here you might add further analysis of the response, such as:
34
+ # - Text analysis for sentiment
35
+ # - Keyword extraction
36
+ # - Length of the response
37
+ # - Etc.
38
+
39
+ # Optionally, save the query and response for historical analysis
40
+ # Implement data storage if needed
41
+
42
+ if __name__ == "__main__":
43
+ main()