awacke1 commited on
Commit
6266cf4
·
1 Parent(s): 10c450b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -11,11 +11,13 @@ from gradio import inputs, outputs
11
  import huggingface_hub
12
  from huggingface_hub import Repository, hf_hub_download, upload_file
13
  from datetime import datetime
 
14
  DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/Carddata.csv"
15
  DATASET_REPO_ID = "awacke1/Carddata.csv"
16
  DATA_FILENAME = "Carddata.csv"
17
  DATA_FILE = os.path.join("data", DATA_FILENAME)
18
  HF_TOKEN = os.environ.get("HF_TOKEN")
 
19
  SCRIPT = """
20
  <script>
21
  if (!window.hasBeenRun) {
@@ -25,18 +27,19 @@ if (!window.hasBeenRun) {
25
  }
26
  </script>
27
  """
28
- try:
29
- hf_hub_download(
30
- repo_id=DATASET_REPO_ID,
31
- filename=DATA_FILENAME,
32
- cache_dir=DATA_DIRNAME,
33
- force_filename=DATA_FILENAME
34
- )
35
- except:
36
- print("file not found")
37
- repo = Repository(
38
- local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
39
- )
 
40
  def generate_html() -> str:
41
  with open(DATA_FILE) as csvfile:
42
  reader = csv.DictReader(csvfile)
@@ -120,7 +123,7 @@ def chat(message, history):
120
  history_useful = add_note_to_history(response, history_useful)
121
  list_history = history_useful[0].split('</s> <s>')
122
  history.append((list_history[-2], list_history[-1]))
123
- store_message(message, response) # Save to dataset
124
  return history, history
125
 
126
  gr.Interface(
 
11
  import huggingface_hub
12
  from huggingface_hub import Repository, hf_hub_download, upload_file
13
  from datetime import datetime
14
+
15
  DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/Carddata.csv"
16
  DATASET_REPO_ID = "awacke1/Carddata.csv"
17
  DATA_FILENAME = "Carddata.csv"
18
  DATA_FILE = os.path.join("data", DATA_FILENAME)
19
  HF_TOKEN = os.environ.get("HF_TOKEN")
20
+
21
  SCRIPT = """
22
  <script>
23
  if (!window.hasBeenRun) {
 
27
  }
28
  </script>
29
  """
30
+ #try:
31
+ # hf_hub_download(
32
+ # repo_id=DATASET_REPO_ID,
33
+ # filename=DATA_FILENAME,
34
+ # cache_dir=DATA_DIRNAME,
35
+ # force_filename=DATA_FILENAME
36
+ # )
37
+ #except:
38
+ # print("file not found")
39
+ #repo = Repository(
40
+ # local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
41
+ #)
42
+
43
  def generate_html() -> str:
44
  with open(DATA_FILE) as csvfile:
45
  reader = csv.DictReader(csvfile)
 
123
  history_useful = add_note_to_history(response, history_useful)
124
  list_history = history_useful[0].split('</s> <s>')
125
  history.append((list_history[-2], list_history[-1]))
126
+ # store_message(message, response) # Save to dataset
127
  return history, history
128
 
129
  gr.Interface(