Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
from transformers import AutoTokenizer, AutoModelForTableQuestionAnswering
|
4 |
-
from datetime import datetime
|
5 |
import requests
|
|
|
|
|
6 |
|
7 |
class InterestCalculatorApp:
|
8 |
def __init__(self):
|
@@ -106,28 +106,19 @@ class InterestCalculatorApp:
|
|
106 |
|
107 |
def ask_tapas(self, query, table):
|
108 |
if isinstance(table, pd.DataFrame):
|
109 |
-
# Tokenize the query
|
110 |
tokenized_query = self.tokenizer.tokenize(query)
|
111 |
-
|
112 |
-
# Tokenize each cell in the table
|
113 |
tokenized_table = [[self.tokenizer.tokenize(str(cell)) for cell in row] for row in table.values]
|
114 |
-
|
115 |
-
|
116 |
-
inputs = self.tokenizer(table=tokenized_table, queries=tokenized_query, return_tensors="pt", padding=True)
|
117 |
-
|
118 |
return inputs
|
119 |
else:
|
120 |
raise TypeError("Table must be of type pd.DataFrame")
|
121 |
|
122 |
-
|
123 |
-
|
124 |
def main():
|
125 |
st.title("Interest Calculation App")
|
126 |
|
127 |
app = InterestCalculatorApp()
|
128 |
|
129 |
-
app.download_boe_rates() # Download base rates first
|
130 |
-
|
131 |
file_path = st.file_uploader("Upload Invoices File", type=["xlsx"])
|
132 |
|
133 |
if file_path is not None:
|
@@ -150,5 +141,7 @@ def main():
|
|
150 |
if st.button("Calculate Interest"):
|
151 |
app.calculate_interest()
|
152 |
|
|
|
|
|
153 |
if __name__ == "__main__":
|
154 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
|
|
3 |
import requests
|
4 |
+
from datetime import datetime
|
5 |
+
from transformers import AutoTokenizer, AutoModelForTableQuestionAnswering
|
6 |
|
7 |
class InterestCalculatorApp:
|
8 |
def __init__(self):
|
|
|
106 |
|
107 |
def ask_tapas(self, query, table):
|
108 |
if isinstance(table, pd.DataFrame):
|
|
|
109 |
tokenized_query = self.tokenizer.tokenize(query)
|
|
|
|
|
110 |
tokenized_table = [[self.tokenizer.tokenize(str(cell)) for cell in row] for row in table.values]
|
111 |
+
|
112 |
+
inputs = self.tokenizer(table=tokenized_table, queries=[tokenized_query], return_tensors="pt", padding=True)
|
|
|
|
|
113 |
return inputs
|
114 |
else:
|
115 |
raise TypeError("Table must be of type pd.DataFrame")
|
116 |
|
|
|
|
|
117 |
def main():
|
118 |
st.title("Interest Calculation App")
|
119 |
|
120 |
app = InterestCalculatorApp()
|
121 |
|
|
|
|
|
122 |
file_path = st.file_uploader("Upload Invoices File", type=["xlsx"])
|
123 |
|
124 |
if file_path is not None:
|
|
|
141 |
if st.button("Calculate Interest"):
|
142 |
app.calculate_interest()
|
143 |
|
144 |
+
app.download_boe_rates()
|
145 |
+
|
146 |
if __name__ == "__main__":
|
147 |
main()
|