CHAT_WITH_PDF / src /utils.py
Ajeet001's picture
added source code files
8b37bdb verified
Raw History Blame Contribute Delete
568 Bytes
import json
import os
def log_interaction(question, response, params):
"""Log interaction details to a JSON file."""
log_entry = {
"question": question,
"response": response,
"params": params
}
log_file_path = "interaction_log.json"
logs = []
if os.path.exists(log_file_path):
with open(log_file_path, "r") as log_file:
logs = json.load(log_file)
logs.append(log_entry)
with open(log_file_path, "w") as log_file:
json.dump(logs, log_file, indent=4)