Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -102,11 +102,15 @@ def initialize_gemini_model():
|
|
102 |
return False # Default case
|
103 |
|
104 |
# --- Helper Functions ---
|
105 |
-
#
|
106 |
-
# call_gemini_api, display_results - remain the same as the optimized version)
|
107 |
-
|
108 |
def estimate_token_count(text):
|
109 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|