Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,21 @@ import streamlit as st
|
|
3 |
|
4 |
from langchain.embeddings import HuggingFaceInstructEmbeddings, HuggingFaceEmbeddings
|
5 |
from langchain.vectorstores.faiss import FAISS
|
6 |
-
from langchain.chains import
|
7 |
from huggingface_hub import snapshot_download
|
8 |
-
from langchain import
|
9 |
-
from langchain import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
st.set_page_config(page_title="CFA Level 1", page_icon="π")
|
@@ -144,7 +155,7 @@ def get_answer(question):
|
|
144 |
api_key = os.environ["OPENAI_API_KEY"]
|
145 |
|
146 |
##### main ####
|
147 |
-
user_input = st.text_input("Your question", "
|
148 |
|
149 |
col1, col2 = st.columns([10, 1])
|
150 |
|
@@ -160,8 +171,8 @@ if ask:
|
|
160 |
with st.spinner("this can take about a minute for your first question because some models have to be downloaded π₯Ίππ»ππ»"):
|
161 |
try:
|
162 |
answer, pages, extract = get_answer(question=user_input)
|
163 |
-
except:
|
164 |
-
st.write(f"Error with Download")
|
165 |
st.stop()
|
166 |
|
167 |
st.write(f"{answer}")
|
|
|
3 |
|
4 |
from langchain.embeddings import HuggingFaceInstructEmbeddings, HuggingFaceEmbeddings
|
5 |
from langchain.vectorstores.faiss import FAISS
|
6 |
+
from langchain.chains import ChatVectorDBChain
|
7 |
from huggingface_hub import snapshot_download
|
8 |
+
from langchain.chat_models import ChatOpenAI
|
9 |
+
from langchain.prompts.chat import (
|
10 |
+
ChatPromptTemplate,
|
11 |
+
SystemMessagePromptTemplate,
|
12 |
+
AIMessagePromptTemplate,
|
13 |
+
HumanMessagePromptTemplate,
|
14 |
+
)
|
15 |
+
from langchain.schema import (
|
16 |
+
AIMessage,
|
17 |
+
HumanMessage,
|
18 |
+
SystemMessage
|
19 |
+
)
|
20 |
+
|
21 |
|
22 |
|
23 |
st.set_page_config(page_title="CFA Level 1", page_icon="π")
|
|
|
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")
|
159 |
|
160 |
col1, col2 = st.columns([10, 1])
|
161 |
|
|
|
171 |
with st.spinner("this can take about a minute for your first question because some models have to be downloaded π₯Ίππ»ππ»"):
|
172 |
try:
|
173 |
answer, pages, extract = get_answer(question=user_input)
|
174 |
+
except as e:
|
175 |
+
st.write(f"Error with Download: {e}")
|
176 |
st.stop()
|
177 |
|
178 |
st.write(f"{answer}")
|