peterkros commited on
Commit
9e803bc
·
1 Parent(s): f9b0725

Update app.py

Browse files

added flagging

Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -2,6 +2,18 @@ import gradio as gr
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
  import torch
4
  import pickle
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  level1_to_level2_mapping = {
7
  "General public services": [
@@ -233,7 +245,10 @@ iface = gr.Interface(
233
  title="COFOG AutoClassification",
234
  description=markdown_text,
235
  article=html_table,
236
- allow_flagging="auto" # Enables flagging
 
 
 
237
  )
238
 
239
  # Run the interface
 
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
  import torch
4
  import pickle
5
+ from dotenv import load_dotenv
6
+ import os
7
+
8
+ # Load environment variables from .env file
9
+ load_dotenv()
10
+ HF_TOKEN = os.getenv("HF_TOKEN")
11
+
12
+ # Name of dataset to save flagged data to
13
+ HF_dataset = "peterkros/COFOG-feedback" # <-- Replace with your dataset repo ID
14
+
15
+ # Load the HuggingFaceDatasetSaver logger
16
+ hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, HF_dataset)
17
 
18
  level1_to_level2_mapping = {
19
  "General public services": [
 
245
  title="COFOG AutoClassification",
246
  description=markdown_text,
247
  article=html_table,
248
+ allow_flagging="manual", # Enables flagging
249
+ flagging_options=["Incorect Level1", "Incorect Level2", "Other"],
250
+ flagging_callback=hf_writer,
251
+
252
  )
253
 
254
  # Run the interface