Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,27 +43,17 @@ def generate_text() -> str:
|
|
| 43 |
user, chatbot, time = row_parts
|
| 44 |
text += f"Time: {time}\nUser: {user}\nChatbot: {chatbot}\n\n"
|
| 45 |
return text if text else "No messages yet"
|
| 46 |
-
|
| 47 |
|
| 48 |
def store_message(chatinput: str, chatresponse: str):
|
| 49 |
if chatinput and chatresponse:
|
| 50 |
with open(DATA_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 |
-
# Add the updated data file to the staged changes
|
| 55 |
-
repo.git_add(DATA_FILENAME)
|
| 56 |
-
|
| 57 |
-
# Commit the changes with a commit message
|
| 58 |
-
commit_message = "Added new data"
|
| 59 |
-
repo.git_commit(commit_message)
|
| 60 |
-
|
| 61 |
-
# Push the changes to the remote repository
|
| 62 |
-
repo.push(remote_name='origin', branch_name='main', use_auth_token=HF_TOKEN)
|
| 63 |
|
| 64 |
return generate_text()
|
| 65 |
|
| 66 |
-
|
| 67 |
#gets the index file which is the context data
|
| 68 |
def get_index(index_file_path):
|
| 69 |
if os.path.exists(index_file_path):
|
|
@@ -92,10 +82,12 @@ with open('about.txt', 'r') as file:
|
|
| 92 |
|
| 93 |
iface = Interface(
|
| 94 |
fn=chatbot,
|
| 95 |
-
inputs=Textbox("
|
| 96 |
outputs="text",
|
| 97 |
title="AI Chatbot trained on J. Haynes mediation material, v0.5",
|
| 98 |
description=about)
|
| 99 |
|
| 100 |
iface.launch()
|
| 101 |
|
|
|
|
|
|
|
|
|
| 43 |
user, chatbot, time = row_parts
|
| 44 |
text += f"Time: {time}\nUser: {user}\nChatbot: {chatbot}\n\n"
|
| 45 |
return text if text else "No messages yet"
|
| 46 |
+
|
| 47 |
|
| 48 |
def store_message(chatinput: str, chatresponse: str):
|
| 49 |
if chatinput and chatresponse:
|
| 50 |
with open(DATA_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 |
return generate_text()
|
| 55 |
|
| 56 |
+
|
| 57 |
#gets the index file which is the context data
|
| 58 |
def get_index(index_file_path):
|
| 59 |
if os.path.exists(index_file_path):
|
|
|
|
| 82 |
|
| 83 |
iface = Interface(
|
| 84 |
fn=chatbot,
|
| 85 |
+
inputs=Textbox("Enter your question"),
|
| 86 |
outputs="text",
|
| 87 |
title="AI Chatbot trained on J. Haynes mediation material, v0.5",
|
| 88 |
description=about)
|
| 89 |
|
| 90 |
iface.launch()
|
| 91 |
|
| 92 |
+
|
| 93 |
+
|