Spaces:
Sleeping
Sleeping
jjz5463
commited on
Commit
·
cf6a08c
1
Parent(s):
6f2d9ff
random pick an incomplete task instead of go with sequential order
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from chatbot_simulator import ChatbotSimulation
|
| 3 |
-
from huggingface_hub import HfApi, create_repo
|
| 4 |
from datasets import load_dataset
|
| 5 |
import json_repair
|
| 6 |
import random
|
|
@@ -18,23 +17,25 @@ db = firestore.client()
|
|
| 18 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
| 19 |
|
| 20 |
|
| 21 |
-
def
|
| 22 |
|
| 23 |
collection_ref = db.collection(app_name)
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
smallest_incomplete_idx = None
|
| 27 |
-
for doc in docs:
|
| 28 |
-
doc_id = doc.id
|
| 29 |
-
_, idx = doc_id.split('_')
|
| 30 |
-
idx = int(idx)
|
| 31 |
|
|
|
|
| 32 |
task_data = doc.to_dict()
|
| 33 |
if task_data['task_completed'] is None and task_data['task_completed_steps'] is None:
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
def write_task_data(app_name, idx, task, task_complete, task_completed_step):
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from chatbot_simulator import ChatbotSimulation
|
|
|
|
| 3 |
from datasets import load_dataset
|
| 4 |
import json_repair
|
| 5 |
import random
|
|
|
|
| 17 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
| 18 |
|
| 19 |
|
| 20 |
+
def find_random_incomplete_task(app_name):
|
| 21 |
|
| 22 |
collection_ref = db.collection(app_name)
|
| 23 |
+
incomplete_indices = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
for doc in collection_ref.stream():
|
| 26 |
task_data = doc.to_dict()
|
| 27 |
if task_data['task_completed'] is None and task_data['task_completed_steps'] is None:
|
| 28 |
+
_, idx = doc.id.split('_')
|
| 29 |
+
idx = int(idx)
|
| 30 |
+
incomplete_indices.append(idx)
|
| 31 |
+
|
| 32 |
+
# Check if any incomplete tasks found
|
| 33 |
+
if not incomplete_indices:
|
| 34 |
+
return None
|
| 35 |
|
| 36 |
+
# Pick a random incomplete index from the list
|
| 37 |
+
random_idx = random.choice(incomplete_indices)
|
| 38 |
+
return random_idx
|
| 39 |
|
| 40 |
|
| 41 |
def write_task_data(app_name, idx, task, task_complete, task_completed_step):
|