Galatea007 commited on
Commit
f252750
·
verified ·
1 Parent(s): 9362a6b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from dotenv import load_dotenv
4
+ from AI_Risk_app import retrieval_augmented_qa_chain # Importing the RAG chain
5
+
6
+
7
+ # Load the .env file
8
+ import streamlit as st
9
+ import openai
10
+
11
+ # Get OpenAI API key from Streamlit secrets
12
+ openai.api_key = st.secrets["OPENAI_API_KEY"]
13
+
14
+ # Load environment variables
15
+ load_dotenv()
16
+
17
+ # Set up the Streamlit interface
18
+ st.title("AI Risk Advisory QA")
19
+
20
+ # Get the user query
21
+ user_query = st.text_input("Ask your question:")
22
+
23
+ # Button to trigger the RAG process
24
+ if st.button("Get Answer"):
25
+ if user_query:
26
+ # Pass user query through RAG chain
27
+ result = retrieval_augmented_qa_chain.invoke({"question": user_query})
28
+
29
+ # Extract response content from RAG result
30
+ response_content = result["response"].content
31
+
32
+ # Display the response content in the Streamlit app
33
+ st.write("**Answer:**")
34
+ st.write(response_content)
35
+ else:
36
+ st.write("Please enter a question.")