Spaces:
Running
Running
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): | |
st.write("### 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) | |
st.write("### AI Response") | |
st.write(response['message']) | |
# Display sources with clickable links | |
if 'sources' in response: | |
display_sources(response['sources']) | |
# Here you might add further analysis of the response, such as: | |
# - Text analysis for sentiment | |
# - Keyword extraction | |
# - Length of the response | |
# - Etc. | |
# Optionally, save the query and response for historical analysis | |
# Implement data storage if needed | |
if __name__ == "__main__": | |
main() |