Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import sys
|
|
| 5 |
import os
|
| 6 |
import datetime
|
| 7 |
import huggingface_hub
|
| 8 |
-
from huggingface_hub import Repository
|
| 9 |
from datetime import datetime
|
| 10 |
import csv
|
| 11 |
|
|
@@ -18,6 +18,9 @@ INDEX_FILENAME = "index2.json"
|
|
| 18 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
| 19 |
INDEX_FILE = os.path.join("data", INDEX_FILENAME)
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
# we need a HF access token - read I think suffices becuase we are cloning the distant repo to local space repo.
|
| 22 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 23 |
print("HF TOKEN is none?", HF_TOKEN is None)
|
|
@@ -54,7 +57,11 @@ def store_message(chatinput: str, chatresponse: str):
|
|
| 54 |
print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
|
| 55 |
|
| 56 |
#need to find a way to push back to dataset repo
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
return generate_text()
|
| 60 |
|
|
|
|
| 5 |
import os
|
| 6 |
import datetime
|
| 7 |
import huggingface_hub
|
| 8 |
+
from huggingface_hub import Repository, HfAPI
|
| 9 |
from datetime import datetime
|
| 10 |
import csv
|
| 11 |
|
|
|
|
| 18 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
| 19 |
INDEX_FILE = os.path.join("data", INDEX_FILENAME)
|
| 20 |
|
| 21 |
+
#this will be called later to upload the chat history back to the dataset
|
| 22 |
+
api=HfAPI()
|
| 23 |
+
|
| 24 |
# we need a HF access token - read I think suffices becuase we are cloning the distant repo to local space repo.
|
| 25 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 26 |
print("HF TOKEN is none?", HF_TOKEN is None)
|
|
|
|
| 57 |
print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
|
| 58 |
|
| 59 |
#need to find a way to push back to dataset repo
|
| 60 |
+
api.upload_file(
|
| 61 |
+
path_or_fileobj=DATA_FILE,
|
| 62 |
+
path_in_repo=DATA_FILENAME,
|
| 63 |
+
repo_id="peterpull/MediatorBot",
|
| 64 |
+
repo_type="dataset")
|
| 65 |
|
| 66 |
return generate_text()
|
| 67 |
|