WillyCodesInit commited on
Commit
1cf86cb
·
verified ·
1 Parent(s): 9539702

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +19 -11
src/streamlit_app.py CHANGED
@@ -1,16 +1,24 @@
1
- app.py
 
 
 
2
 
3
- import streamlit as st from embedding import setup_embeddings, load_data from model_utils import load_llama_model, is_finance_question, ask_finance_bot
 
 
 
4
 
5
- Load data and embeddings
6
-
7
- questions, answers = load_data() embedding_model, index = setup_embeddings(answers) tokenizer, model = load_llama_model()
8
-
9
- Streamlit UI
10
-
11
- st.set_page_config(page_title="DiMowkayBot - Finance Assistant", layout="centered") st.title("🤖 DiMowkayBot - Your Finance Q&A Assistant")
12
 
13
  user_query = st.text_input("Ask a finance-related question:")
14
 
15
- if user_query: with st.spinner("Thinking..."): if not is_finance_question(user_query, tokenizer, model): st.warning("I'm specialized in finance and can't help with that. How can I assist you with a finance-related question today?") else: answer = ask_finance_bot(user_query, answers, embedding_model, index, tokenizer, model) st.success("Response:") st.write(answer)
16
-
 
 
 
 
 
 
 
1
+ # app.py
2
+ import streamlit as st
3
+ from embedding import setup_embeddings, load_data
4
+ from model_utils import load_llama_model, is_finance_question, ask_finance_bot
5
 
6
+ # Load data and embeddings
7
+ questions, answers = load_data()
8
+ embedding_model, index = setup_embeddings(answers)
9
+ tokenizer, model = load_llama_model()
10
 
11
+ # Streamlit UI
12
+ st.set_page_config(page_title="DiMowkayBot - Finance Assistant", layout="centered")
13
+ st.title("DiMowkayBot - Your Finance Q&A Assistant")
 
 
 
 
14
 
15
  user_query = st.text_input("Ask a finance-related question:")
16
 
17
+ if user_query:
18
+ with st.spinner("Thinking..."):
19
+ if not is_finance_question(user_query, tokenizer, model):
20
+ st.warning("I'm specialized in finance and can't help with that. How can I assist you with a finance-related question today?")
21
+ else:
22
+ answer = ask_finance_bot(user_query, answers, embedding_model, index, tokenizer, model)
23
+ st.success("Response:")
24
+ st.write(answer)