for876543 commited on
Commit
69e6c8d
1 Parent(s): 971425d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -12,6 +12,8 @@ from huggingface_hub import Repository
12
  DATASET_REPO_URL = "https://huggingface.co/datasets/for876543/OpenAI-test1-logs"
13
  DATA_FILENAME = "data.csv"
14
  DATA_FILE = os.path.join("data", DATA_FILENAME)
 
 
15
 
16
  HF_TOKEN = os.environ.get("hf")
17
  print("is none?", HF_TOKEN is None)
@@ -28,12 +30,22 @@ def generate_text(input_text):
28
  output_text = "Processed: " + input_text
29
 
30
 
31
-
32
 
 
 
 
 
 
 
 
 
 
33
  with open(DATA_FILE, mode='a', newline='') as file:
34
  writer = csv.writer(file)
35
  writer.writerow([input_text, output_text, datetime.now().strftime("%Y-%m-%d %H:%M:%S")])
 
36
  commit_url = repo.push_to_hub()
 
37
  return output_text
38
 
39
  interface = gr.Interface(
@@ -48,7 +60,8 @@ interface = gr.Interface(
48
  ["Example input 2"]
49
  ],
50
  allow_flagging = 'manual',
51
- flagging_options=["Correct","Incorrect", "Ambiguous"]
 
52
  )
53
 
54
  interface.launch(debug = True)
 
12
  DATASET_REPO_URL = "https://huggingface.co/datasets/for876543/OpenAI-test1-logs"
13
  DATA_FILENAME = "data.csv"
14
  DATA_FILE = os.path.join("data", DATA_FILENAME)
15
+ FLAG_FILENAME = "flags.csv"
16
+ FLAG_FILE = os.path.join("data", FLAG_FILENAME)
17
 
18
  HF_TOKEN = os.environ.get("hf")
19
  print("is none?", HF_TOKEN is None)
 
30
  output_text = "Processed: " + input_text
31
 
32
 
 
33
 
34
+
35
+ with open("/home/user/app/logs.csv", 'r') as file:
36
+ reader = csv.reader(file)
37
+ logs = list(reader)
38
+
39
+ with open(FLAG_FILE, mode='w', newline='') as file:
40
+ writer = csv.writer(file)
41
+ writer.writerows(logs)
42
+
43
  with open(DATA_FILE, mode='a', newline='') as file:
44
  writer = csv.writer(file)
45
  writer.writerow([input_text, output_text, datetime.now().strftime("%Y-%m-%d %H:%M:%S")])
46
+
47
  commit_url = repo.push_to_hub()
48
+
49
  return output_text
50
 
51
  interface = gr.Interface(
 
60
  ["Example input 2"]
61
  ],
62
  allow_flagging = 'manual',
63
+ flagging_options=["Correct","Incorrect", "Ambiguous"],
64
+ flagging_dir = '/home/user/app/'
65
  )
66
 
67
  interface.launch(debug = True)