Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,8 @@ from langchain.schema import (
|
|
| 22 |
|
| 23 |
st.set_page_config(page_title="CFA Level 1", page_icon="📖")
|
| 24 |
|
|
|
|
|
|
|
| 25 |
|
| 26 |
#### sidebar section 1 ####
|
| 27 |
with st.sidebar:
|
|
@@ -120,10 +122,13 @@ def load_chain():
|
|
| 120 |
|
| 121 |
return qa
|
| 122 |
|
|
|
|
| 123 |
|
| 124 |
def get_answer(question):
|
|
|
|
|
|
|
| 125 |
chain = load_chain()
|
| 126 |
-
result = chain({"
|
| 127 |
|
| 128 |
answer = result["result"]
|
| 129 |
|
|
@@ -151,8 +156,6 @@ def get_answer(question):
|
|
| 151 |
|
| 152 |
return answer, pages, extract
|
| 153 |
|
| 154 |
-
##### sidebar section 2 ####
|
| 155 |
-
api_key = os.environ["OPENAI_API_KEY"]
|
| 156 |
|
| 157 |
##### main ####
|
| 158 |
user_input = st.text_input("Your question", "What is an MBS and who are the main issuer and investors of the MBS market?", key="input")
|
|
|
|
| 22 |
|
| 23 |
st.set_page_config(page_title="CFA Level 1", page_icon="📖")
|
| 24 |
|
| 25 |
+
#Load API Key
|
| 26 |
+
api_key = os.environ["OPENAI_API_KEY"]
|
| 27 |
|
| 28 |
#### sidebar section 1 ####
|
| 29 |
with st.sidebar:
|
|
|
|
| 122 |
|
| 123 |
return qa
|
| 124 |
|
| 125 |
+
chat_history = []
|
| 126 |
|
| 127 |
def get_answer(question):
|
| 128 |
+
'''Generate an answer from the chain'''
|
| 129 |
+
|
| 130 |
chain = load_chain()
|
| 131 |
+
result = chain({"question": question, "chat_history": chat_history})
|
| 132 |
|
| 133 |
answer = result["result"]
|
| 134 |
|
|
|
|
| 156 |
|
| 157 |
return answer, pages, extract
|
| 158 |
|
|
|
|
|
|
|
| 159 |
|
| 160 |
##### main ####
|
| 161 |
user_input = st.text_input("Your question", "What is an MBS and who are the main issuer and investors of the MBS market?", key="input")
|