Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,24 +8,9 @@ import json
|
|
8 |
# Set the OpenAI API key
|
9 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
10 |
|
11 |
-
class CustomHuggingFaceDatasetSaver(gr.FlaggingCallback):
|
12 |
-
def __init__(self, hf_token, dataset_name):
|
13 |
-
super().__init__()
|
14 |
-
self.hf_token = hf_token
|
15 |
-
self.dataset_name = dataset_name
|
16 |
-
|
17 |
-
def flag(self, sample):
|
18 |
-
if len(sample["output"]) > 1000:
|
19 |
-
sample["output"] = sample["output"][:1000] # Truncate output to 1000 characters
|
20 |
-
|
21 |
-
super().flag(sample)
|
22 |
-
|
23 |
-
def setup(self):
|
24 |
-
pass
|
25 |
-
|
26 |
# Set up flagging callback function
|
27 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
28 |
-
hf_writer =
|
29 |
|
30 |
# Define the authentication function
|
31 |
def check_auth(username, password):
|
|
|
8 |
# Set the OpenAI API key
|
9 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# Set up flagging callback function
|
12 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
13 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "CannaTech/Flagged")
|
14 |
|
15 |
# Define the authentication function
|
16 |
def check_auth(username, password):
|