Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,6 +33,8 @@ repo = Repository(
|
|
| 33 |
print(f"Repo local_dir: {repo.local_dir}")
|
| 34 |
print(f"Repo files: {os.listdir(repo.local_dir)}")
|
| 35 |
|
|
|
|
|
|
|
| 36 |
def generate_text() -> str:
|
| 37 |
with open(DATA_FILE) as file:
|
| 38 |
text = ""
|
|
@@ -49,9 +51,18 @@ def store_message(chatinput: str, chatresponse: str):
|
|
| 49 |
with open(DATA_FILE, "a") as file:
|
| 50 |
file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
|
| 51 |
print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
return generate_text()
|
| 54 |
|
|
|
|
|
|
|
| 55 |
|
| 56 |
#gets the index file which is the context data
|
| 57 |
def get_index(index_file_path):
|
|
|
|
| 33 |
print(f"Repo local_dir: {repo.local_dir}")
|
| 34 |
print(f"Repo files: {os.listdir(repo.local_dir)}")
|
| 35 |
|
| 36 |
+
store_message.count_calls = 1 #initiases the count at one. We want to count how many messages stored.
|
| 37 |
+
|
| 38 |
def generate_text() -> str:
|
| 39 |
with open(DATA_FILE) as file:
|
| 40 |
text = ""
|
|
|
|
| 51 |
with open(DATA_FILE, "a") as file:
|
| 52 |
file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
|
| 53 |
print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
|
| 54 |
+
|
| 55 |
+
# Push back to hub every 10th time the function is called
|
| 56 |
+
if store_message.count_calls % 10 == 0:
|
| 57 |
+
print("Pushing back to Hugging Face model hub")
|
| 58 |
+
# Call the push_to_hub() function to push the changes to the hub
|
| 59 |
+
push_to_hub(commit_message="Added new chat data")
|
| 60 |
+
store_message.count_calls += 1
|
| 61 |
|
| 62 |
return generate_text()
|
| 63 |
|
| 64 |
+
|
| 65 |
+
|
| 66 |
|
| 67 |
#gets the index file which is the context data
|
| 68 |
def get_index(index_file_path):
|