pentarosarium commited on
Commit
e4c8347
·
1 Parent(s): ded1fc2

fixed modal API

Browse files
Files changed (2) hide show
  1. app.py +14 -4
  2. requirements.txt +1 -2
app.py CHANGED
@@ -2,11 +2,16 @@ import streamlit as st
2
  import pandas as pd
3
  from modal import Function
4
  import os
5
- import modal
6
 
7
- # Initialize Modal with token
8
- if 'MODAL_TOKEN' in os.environ:
9
- modal.config.auth.token = os.environ['MODAL_TOKEN']
 
 
 
 
 
 
10
 
11
  def main():
12
  st.title("Financial Statement Analyzer")
@@ -15,6 +20,10 @@ def main():
15
  if 'MODAL_TOKEN' not in os.environ:
16
  st.error("Modal token not found. Please add MODAL_TOKEN to Space secrets.")
17
  return
 
 
 
 
18
 
19
  uploaded_files = st.file_uploader(
20
  "Choose PDF files",
@@ -56,6 +65,7 @@ def main():
56
 
57
  except Exception as e:
58
  status.error(f"Error: {str(e)}")
 
59
  progress_bar.empty()
60
 
61
  if __name__ == "__main__":
 
2
  import pandas as pd
3
  from modal import Function
4
  import os
 
5
 
6
+ def init_modal():
7
+ """Initialize Modal with token from environment"""
8
+ try:
9
+ from modal.config import config
10
+ config.cli.token = os.environ.get('MODAL_TOKEN')
11
+ return True
12
+ except Exception as e:
13
+ st.error(f"Failed to initialize Modal: {str(e)}")
14
+ return False
15
 
16
  def main():
17
  st.title("Financial Statement Analyzer")
 
20
  if 'MODAL_TOKEN' not in os.environ:
21
  st.error("Modal token not found. Please add MODAL_TOKEN to Space secrets.")
22
  return
23
+
24
+ # Initialize Modal
25
+ if not init_modal():
26
+ return
27
 
28
  uploaded_files = st.file_uploader(
29
  "Choose PDF files",
 
65
 
66
  except Exception as e:
67
  status.error(f"Error: {str(e)}")
68
+ st.error("Full error message: " + str(e))
69
  progress_bar.empty()
70
 
71
  if __name__ == "__main__":
requirements.txt CHANGED
@@ -1,5 +1,4 @@
1
- modal>=0.56.4
2
- modal-client>=0.56.4
3
  streamlit>=1.32.0
4
  pandas>=2.2.0
5
  python-dotenv>=1.0.0
 
1
+ modal==0.56.4
 
2
  streamlit>=1.32.0
3
  pandas>=2.2.0
4
  python-dotenv>=1.0.0