Spaces:
Sleeping
Sleeping
Fixing questions storage issue and adding logs
Browse files- app.py +12 -5
- questions_store.py +12 -7
app.py
CHANGED
|
@@ -34,11 +34,11 @@ You have two tools to notify Sushmitha: send_pushover_notification (instant push
|
|
| 34 |
"""
|
| 35 |
|
| 36 |
UNCERTAINTY_MARKERS = [
|
| 37 |
-
"
|
| 38 |
"i don't have", "i do not have",
|
| 39 |
-
"i'm not sure", "i am not sure",
|
| 40 |
"i don't know", "i do not know",
|
| 41 |
-
"not mentioned", "
|
|
|
|
| 42 |
]
|
| 43 |
|
| 44 |
def update_hf_dataset(new_doc: dict):
|
|
@@ -155,11 +155,18 @@ def respond_ai(message, history):
|
|
| 155 |
|
| 156 |
# Log unanswered questions and notify via Pushover
|
| 157 |
if any(m in full_content.lower() for m in UNCERTAINTY_MARKERS):
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
try:
|
| 160 |
send_pushover_notification(f"Unanswered: {message[:100]}")
|
| 161 |
except Exception as e:
|
| 162 |
-
print(f"Pushover failed: {e}")
|
|
|
|
|
|
|
| 163 |
|
| 164 |
# After full response, generate and show suggestion chips
|
| 165 |
suggestions = generate_suggestions(message, full_content, context, client)
|
|
|
|
| 34 |
"""
|
| 35 |
|
| 36 |
UNCERTAINTY_MARKERS = [
|
| 37 |
+
"uncertain", "not sure", "not certain", "not fully",
|
| 38 |
"i don't have", "i do not have",
|
|
|
|
| 39 |
"i don't know", "i do not know",
|
| 40 |
+
"not mentioned", "cannot provide", "can't provide",
|
| 41 |
+
"don't have enough", "limited information",
|
| 42 |
]
|
| 43 |
|
| 44 |
def update_hf_dataset(new_doc: dict):
|
|
|
|
| 155 |
|
| 156 |
# Log unanswered questions and notify via Pushover
|
| 157 |
if any(m in full_content.lower() for m in UNCERTAINTY_MARKERS):
|
| 158 |
+
print(f"*** UNCERTAINTY DETECTED — logging question: {message[:80]}")
|
| 159 |
+
try:
|
| 160 |
+
log_question(message)
|
| 161 |
+
print("*** Question logged successfully")
|
| 162 |
+
except Exception as e:
|
| 163 |
+
print(f"*** log_question failed: {e}")
|
| 164 |
try:
|
| 165 |
send_pushover_notification(f"Unanswered: {message[:100]}")
|
| 166 |
except Exception as e:
|
| 167 |
+
print(f"*** Pushover failed: {e}")
|
| 168 |
+
else:
|
| 169 |
+
print("*** No uncertainty detected in response")
|
| 170 |
|
| 171 |
# After full response, generate and show suggestion chips
|
| 172 |
suggestions = generate_suggestions(message, full_content, context, client)
|
questions_store.py
CHANGED
|
@@ -26,13 +26,18 @@ def _fetch_from_hf() -> list[str]:
|
|
| 26 |
|
| 27 |
def _upload_to_hf(questions: list[str]):
|
| 28 |
from huggingface_hub import HfApi
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
def log_question(question: str):
|
|
|
|
| 26 |
|
| 27 |
def _upload_to_hf(questions: list[str]):
|
| 28 |
from huggingface_hub import HfApi
|
| 29 |
+
try:
|
| 30 |
+
HfApi().upload_file(
|
| 31 |
+
path_or_fileobj=json.dumps(questions, indent=2).encode(),
|
| 32 |
+
path_in_repo=_HF_FILENAME,
|
| 33 |
+
repo_id=os.getenv("HF_DATASET_REPO"),
|
| 34 |
+
repo_type="dataset",
|
| 35 |
+
token=os.getenv("HF_TOKEN"),
|
| 36 |
+
)
|
| 37 |
+
print(f"*** questions.json uploaded to HF ({len(questions)} questions)")
|
| 38 |
+
except Exception as e:
|
| 39 |
+
print(f"*** HF questions upload failed: {e}")
|
| 40 |
+
raise
|
| 41 |
|
| 42 |
|
| 43 |
def log_question(question: str):
|