Spaces:
Running
Running
stilljustanobody
commited on
Commit
•
37a869d
1
Parent(s):
0adb182
Update app.py
Browse files
app.py
CHANGED
@@ -33,22 +33,8 @@ def format_prompt(message, history):
|
|
33 |
prompt += f"[INST] {message} [/INST]"
|
34 |
return prompt
|
35 |
|
36 |
-
def log_conversation(user_prompt, bot_response,
|
37 |
-
#
|
38 |
-
os.makedirs(log_directory, exist_ok=True)
|
39 |
-
|
40 |
-
# Find the latest file number
|
41 |
-
latest_file_number = 0
|
42 |
-
for file_name in os.listdir(log_directory):
|
43 |
-
if file_name.endswith(".txt"):
|
44 |
-
file_number = int(file_name.split(".")[0])
|
45 |
-
latest_file_number = max(latest_file_number, file_number)
|
46 |
-
|
47 |
-
# Increment the file number
|
48 |
-
next_file_number = latest_file_number + 1
|
49 |
-
|
50 |
-
# Write conversation to the next file
|
51 |
-
log_file = os.path.join(log_directory, f"{next_file_number}.txt")
|
52 |
with open(log_file, "a") as f:
|
53 |
f.write(f"User: {user_prompt}\n")
|
54 |
f.write(f"Bot: {bot_response}\n")
|
|
|
33 |
prompt += f"[INST] {message} [/INST]"
|
34 |
return prompt
|
35 |
|
36 |
+
def log_conversation(user_prompt, bot_response, log_file="chatinfo.txt", server_url="https://example.com/save-conversation"):
|
37 |
+
# Write conversation to the chatinfo.txt file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
with open(log_file, "a") as f:
|
39 |
f.write(f"User: {user_prompt}\n")
|
40 |
f.write(f"Bot: {bot_response}\n")
|