Download src/utils.py from Ajeet001/sample: direct link, hf CLI and curl.
- Browser
- Download file 568 Bytes
-
https://huggingface.co/spaces/Ajeet001/sample/resolve/main/src/utils.py
- Command line
-
hf download hf://spaces/Ajeet001/sample/src/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/Ajeet001/sample/resolve/main/src/utils.py
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) |