mgbam commited on
Commit
ad3750e
·
verified ·
1 Parent(s): 94dc448

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -102,11 +102,15 @@ def initialize_gemini_model():
102
  return False # Default case
103
 
104
  # --- Helper Functions ---
105
- # (estimate_token_count, process_zip_file_cached, construct_analysis_prompt,
106
- # call_gemini_api, display_results - remain the same as the optimized version)
107
-
108
  def estimate_token_count(text):
109
- """Estimates the number of tokens based on text length."""
 
 
 
 
 
 
110
  return len(text) // 3
111
 
112
  @st.cache_data(max_entries=5)
 
102
  return False # Default case
103
 
104
  # --- Helper Functions ---
105
+ # Updated estimate_token_count to support integers and strings
 
 
106
  def estimate_token_count(text):
107
+ """
108
+ Estimates the token count.
109
+ If a string is provided, it calculates based on its length.
110
+ If an integer is provided (e.g., total character count), it uses that directly.
111
+ """
112
+ if isinstance(text, int):
113
+ return text // 3
114
  return len(text) // 3
115
 
116
  @st.cache_data(max_entries=5)