Spaces:
Sleeping
Sleeping
File size: 1,063 Bytes
f252750 f368d1a f252750 f368d1a f252750 |
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 |
import os
import streamlit as st
from dotenv import load_dotenv
from AI_Risk_app import retrieval_augmented_qa_chain # Importing the RAG chain
# Load the .env file
import streamlit as st
import openai
# Get OpenAI API key from Streamlit secrets
#openai.api_key = st.secrets["OPENAI_API_KEY"]
# Load environment variables
load_dotenv()
# Load environment variables from a .env file
openai_api_key = os.getenv('OPENAI_API_KEY')
# Set up the Streamlit interface
st.title("AI Risk Advisory QA")
# Get the user query
user_query = st.text_input("Ask your question:")
# Button to trigger the RAG process
if st.button("Get Answer"):
if user_query:
# Pass user query through RAG chain
result = retrieval_augmented_qa_chain.invoke({"question": user_query})
# Extract response content from RAG result
response_content = result["response"].content
# Display the response content in the Streamlit app
st.write("**Answer:**")
st.write(response_content)
else:
st.write("Please enter a question.") |