Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,8 +17,7 @@ DATASET_REPO_URL = "https://huggingface.co/datasets/peterpull/MediatorBot"
|
|
| 17 |
DATA_FILENAME = "data.txt"
|
| 18 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
| 19 |
|
| 20 |
-
|
| 21 |
-
NEW_FILE = os.path.join(NEW_DIR, DATA_FILENAME)
|
| 22 |
|
| 23 |
# I am guessing we need a write access token.
|
| 24 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
@@ -26,7 +25,7 @@ print("HF TOKEN is none?", HF_TOKEN is None)
|
|
| 26 |
print("HF hub ver", huggingface_hub.__version__)
|
| 27 |
|
| 28 |
repo = Repository(
|
| 29 |
-
local_dir=
|
| 30 |
clone_from=DATASET_REPO_URL,
|
| 31 |
use_auth_token=HF_TOKEN)
|
| 32 |
|
|
@@ -46,18 +45,10 @@ def generate_text() -> str:
|
|
| 46 |
|
| 47 |
def store_message(chatinput: str, chatresponse: str):
|
| 48 |
if chatinput and chatresponse:
|
| 49 |
-
|
| 50 |
-
with open(NEW_FILE, "a") as file:
|
| 51 |
file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
|
| 52 |
print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
|
| 53 |
|
| 54 |
-
repo.clone(NEW_DIR, exist_ok=True)
|
| 55 |
-
print("Cloned remote repository to new directory")
|
| 56 |
-
shutil.copyfile(DATA_FILE, NEW_FILE)
|
| 57 |
-
repo.commit('Update data.txt')
|
| 58 |
-
print("Committed changes to local repository")
|
| 59 |
-
repo.push_to_hub()
|
| 60 |
-
print("Pushed changes to remote repository")
|
| 61 |
|
| 62 |
return generate_text()
|
| 63 |
|
|
|
|
| 17 |
DATA_FILENAME = "data.txt"
|
| 18 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
| 19 |
|
| 20 |
+
|
|
|
|
| 21 |
|
| 22 |
# I am guessing we need a write access token.
|
| 23 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
|
|
| 25 |
print("HF hub ver", huggingface_hub.__version__)
|
| 26 |
|
| 27 |
repo = Repository(
|
| 28 |
+
local_dir='data',
|
| 29 |
clone_from=DATASET_REPO_URL,
|
| 30 |
use_auth_token=HF_TOKEN)
|
| 31 |
|
|
|
|
| 45 |
|
| 46 |
def store_message(chatinput: str, chatresponse: str):
|
| 47 |
if chatinput and chatresponse:
|
| 48 |
+
with open(DATA_FILE, "a") as file:
|
|
|
|
| 49 |
file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
|
| 50 |
print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
return generate_text()
|
| 54 |
|