File size: 1,299 Bytes
645bb63
 
 
 
 
 
 
 
 
 
 
a030ddc
 
 
645bb63
 
a030ddc
645bb63
 
 
 
 
 
 
 
 
 
a030ddc
 
 
 
 
645bb63
 
 
a030ddc
 
645bb63
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import streamlit as st
from meta_ai_api import MetaAI

# Initialize Meta AI API
ai = MetaAI()

def fetch_response(query):
    response = ai.prompt(message=query)
    return response

def display_sources(sources):
    with st.expander("Show Sources"):
        for source in sources:
            st.markdown(f"[{source['title']}]({source['link']})")

def main():

    st.title("AI Response Analytics Tool")

    # User input
    user_query = st.text_area("Enter your query:", height=150)
    submit_button = st.button("Analyze Query")

    if submit_button and user_query:
        # Fetching response from Meta AI
        response = fetch_response(user_query)

        # Display the full AI response in a collapsible section
        with st.expander("Show Full Response"):
            st.write(response['message'])

        # Display sources with clickable links in a collapsible section
        if 'sources' in response:
            display_sources(response['sources'])

        # Further features for processing and visualizing the response could be added here
        # Examples: sentiment analysis, keyword extraction, response length, etc.

        # Optionally, save the query and response for historical analysis
        # Implement data storage if needed

if __name__ == "__main__":
    main()