Spaces:
Running
Running
logs
Browse files- .gitignore +1 -1
- app.py +16 -37
- app_interactions.jsonl +7 -0
- auditqa/reader.py +1 -1
- auditqa/utils.py +9 -38
- logs/app.log +109 -0
.gitignore
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/testing/
|
4 |
|
5 |
/data/
|
6 |
-
|
7 |
|
8 |
# Python cache files
|
9 |
__pycache__/
|
|
|
3 |
/testing/
|
4 |
|
5 |
/data/
|
6 |
+
/json_dataset
|
7 |
|
8 |
# Python cache files
|
9 |
__pycache__/
|
app.py
CHANGED
@@ -31,44 +31,25 @@ logger.setLevel(logging.DEBUG) # Ensure debug logging is enabled
|
|
31 |
load_dotenv()
|
32 |
|
33 |
# # fetch tokens and model config params
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
# # create the local logs repo
|
38 |
-
# JSON_DATASET_DIR = Path("json_dataset")
|
39 |
-
# JSON_DATASET_DIR.mkdir(parents=True, exist_ok=True)
|
40 |
-
# JSON_DATASET_PATH = JSON_DATASET_DIR / f"logs-{uuid4()}.json"
|
41 |
-
|
42 |
-
# # the logs are written to dataset repo periodically from local logs
|
43 |
-
# # https://huggingface.co/spaces/Wauplin/space_to_dataset_saver
|
44 |
-
# scheduler = CommitScheduler(
|
45 |
-
# repo_id="GIZ/spaces_logs",
|
46 |
-
# repo_type="dataset",
|
47 |
-
# folder_path=JSON_DATASET_DIR,
|
48 |
-
# path_in_repo="audit_chatbot",
|
49 |
-
# token=SPACES_LOG )
|
50 |
-
|
51 |
-
# Make logging optional
|
52 |
-
JSON_DATASET_PATH = "test_log.json" # TESTING: local logging setup
|
53 |
-
model_config = getconfig("model_params.cfg")
|
54 |
|
55 |
-
|
56 |
-
# class LocalScheduler:
|
57 |
-
# def __init__(self, filepath):
|
58 |
-
# self.filepath = Path(filepath)
|
59 |
-
# self.lock = Lock()
|
60 |
-
|
61 |
-
# # Create the file if it doesn't exist
|
62 |
-
# if not self.filepath.exists():
|
63 |
-
# with self.filepath.open('w') as f:
|
64 |
-
# f.write('')
|
65 |
|
66 |
-
#
|
67 |
-
|
68 |
-
|
|
|
69 |
|
70 |
# the logs are written to dataset repo periodically from local logs
|
71 |
# https://huggingface.co/spaces/Wauplin/space_to_dataset_saver
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
#####--------------- VECTOR STORE -------------------------------------------------
|
74 |
# Configure cloud Qdrant client
|
@@ -126,8 +107,7 @@ def submit_feedback(feedback, logs_data):
|
|
126 |
logger.error("No logs data available for feedback")
|
127 |
return gr.update(visible=False), gr.update(visible=True)
|
128 |
|
129 |
-
|
130 |
-
save_logs(JSON_DATASET_PATH, logs_data, feedback)
|
131 |
return gr.update(visible=False), gr.update(visible=True)
|
132 |
except Exception as e:
|
133 |
logger.error(f"Error saving feedback: {e}")
|
@@ -325,8 +305,7 @@ async def chat(query, history, sources, reports, subtype, year, client_ip=None,
|
|
325 |
|
326 |
try:
|
327 |
# Save log after streaming is complete
|
328 |
-
|
329 |
-
save_logs(JSON_DATASET_PATH, logs_data)
|
330 |
except Exception as e:
|
331 |
logging.error(e)
|
332 |
|
|
|
31 |
load_dotenv()
|
32 |
|
33 |
# # fetch tokens and model config params
|
34 |
+
SPACES_LOG = os.environ["SPACES_LOG"]
|
35 |
+
SPACES_LOG = os.getenv('SPACES_LOG')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
model_config = getconfig("model_params.cfg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
# create the local logs repo
|
40 |
+
JSON_DATASET_DIR = Path("json_dataset")
|
41 |
+
JSON_DATASET_DIR.mkdir(parents=True, exist_ok=True)
|
42 |
+
JSON_DATASET_PATH = JSON_DATASET_DIR / f"logs-{uuid4()}.json"
|
43 |
|
44 |
# the logs are written to dataset repo periodically from local logs
|
45 |
# https://huggingface.co/spaces/Wauplin/space_to_dataset_saver
|
46 |
+
scheduler = CommitScheduler(
|
47 |
+
repo_id="mtyrrell/spaces_log",
|
48 |
+
repo_type="dataset",
|
49 |
+
folder_path=JSON_DATASET_DIR,
|
50 |
+
path_in_repo=".",
|
51 |
+
token=SPACES_LOG,
|
52 |
+
every=2)
|
53 |
|
54 |
#####--------------- VECTOR STORE -------------------------------------------------
|
55 |
# Configure cloud Qdrant client
|
|
|
107 |
logger.error("No logs data available for feedback")
|
108 |
return gr.update(visible=False), gr.update(visible=True)
|
109 |
|
110 |
+
save_logs(scheduler, JSON_DATASET_PATH, logs_data, feedback)
|
|
|
111 |
return gr.update(visible=False), gr.update(visible=True)
|
112 |
except Exception as e:
|
113 |
logger.error(f"Error saving feedback: {e}")
|
|
|
305 |
|
306 |
try:
|
307 |
# Save log after streaming is complete
|
308 |
+
save_logs(scheduler, JSON_DATASET_PATH, logs_data)
|
|
|
309 |
except Exception as e:
|
310 |
logging.error(e)
|
311 |
|
app_interactions.jsonl
CHANGED
@@ -1 +1,8 @@
|
|
1 |
{"session_id": "fa279ca0-b89b-474e-817b-563ac9b88ac2", "client_ip": "127.0.0.1", "client_location": {"city": null, "region": null, "country": null, "latitude": null, "longitude": null}, "session_duration_seconds": 3e-06, "year": ["2023"], "question": "What are the key findings of this audit report?", "retriever": "BAAI/bge-large-en-v1.5", "endpoint_type": "DEDICATED", "reader": "meta-llama/Llama-3.1-8B-Instruct", "answer": "The audit reports provided cover the financial statements of Kifamba District Local Government and Buhweju District Local Government for the year ended 30th June 2023. The key findings from these reports are: 1. Management of Government Salary Payroll: * The Minister of Finance, Planning and Economic Development highlighted that expenditure on wage is a substantial percentage of all entity budgets, but significant results have not been achieved despite reforms <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. * A special audit on wage payroll in Local Government entities was carried out to establish the root causes of delays in salary payments and propose remedial measures. The audit covered four FYs from 2019/2020 to 2022/2023, and a separate detailed audit report was issued <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. 2. Implementation of Budget: * The Auditor General's report for Kifamba District Local Government found that the implementation of the approved budget was partially implemented, with some projects still ongoing <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. 3 Despite the Codeua ", "time": "1739438928.855079"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
{"session_id": "fa279ca0-b89b-474e-817b-563ac9b88ac2", "client_ip": "127.0.0.1", "client_location": {"city": null, "region": null, "country": null, "latitude": null, "longitude": null}, "session_duration_seconds": 3e-06, "year": ["2023"], "question": "What are the key findings of this audit report?", "retriever": "BAAI/bge-large-en-v1.5", "endpoint_type": "DEDICATED", "reader": "meta-llama/Llama-3.1-8B-Instruct", "answer": "The audit reports provided cover the financial statements of Kifamba District Local Government and Buhweju District Local Government for the year ended 30th June 2023. The key findings from these reports are: 1. Management of Government Salary Payroll: * The Minister of Finance, Planning and Economic Development highlighted that expenditure on wage is a substantial percentage of all entity budgets, but significant results have not been achieved despite reforms <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. * A special audit on wage payroll in Local Government entities was carried out to establish the root causes of delays in salary payments and propose remedial measures. The audit covered four FYs from 2019/2020 to 2022/2023, and a separate detailed audit report was issued <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. 2. Implementation of Budget: * The Auditor General's report for Kifamba District Local Government found that the implementation of the approved budget was partially implemented, with some projects still ongoing <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. 3 Despite the Codeua ", "time": "1739438928.855079"}
|
2 |
+
{"session_id": "e7df9e7f-b24d-4b3f-ba1f-368af70c4bae", "client_ip": "127.0.0.1", "client_location": {"city": null, "region": null, "country": null, "latitude": null, "longitude": null}, "session_duration_seconds": 4e-06, "year": ["2023"], "question": "What are the key findings of this audit report?", "retriever": "BAAI/bge-large-en-v1.5", "endpoint_type": "DEDICATED", "reader": "meta-llama/Llama-3.1-8B-Instruct", "answer": "The audit report highlights several key findings, which are summarized below: **Management of Government Salary Payroll** The report notes that despite various reforms introduced to mitigate supplementary requests for additional funds to cater for wage shortfalls, there has not been significant results, and expenditure on wage is a substantial percentage of all entity budgets <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. The report also highlights payments for non-existent employees, underpayments to staff, and irregular overpayments to staff, among others <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. **Implementation of Approved Budget** The report notes that the implementation of the approved budget has not been effective, with several projects still in progress <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. **Management of Non-Current Assets** The report highlights changes in accounting treatment for non-current assets, which is essential for proper financial reporting [Docs 1 and 2]. **Implementation of Key Government Grants/Programmes** The report highlights the implementation of key government grants and programmes, including the District Rural Water Supply and Sanitation Conditional Grant, the Uganda Intergovernmental Fiscal Transfers Program, and the Education Development Grant [Docs 1 and 2]. **Implementation of Parish Development Model** The report highlights the implementation of the Parish Development Model, which is an important initiative aimed at improving service delivery at the parish level <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. Overall, the key findings of this audit report highlight several areas that require improvement, including the management of government salary payroll, the implementation of approved budgets, and the management of non-current assets. These findings are important for ensuring that local governments effectively manage their resources and deliver services to their constituents. ", "time": "1739452675.134787"}
|
3 |
+
{"session_id": "e7df9e7f-b24d-4b3f-ba1f-368af70c4bae", "client_ip": "127.0.0.1", "client_location": {"city": null, "region": null, "country": null, "latitude": null, "longitude": null}, "session_duration_seconds": 4e-06, "year": ["2023"], "question": "What are the key findings of this audit report?", "retriever": "BAAI/bge-large-en-v1.5", "endpoint_type": "DEDICATED", "reader": "meta-llama/Llama-3.1-8B-Instruct", "answer": "The audit report highlights several key findings, which are summarized below: **Management of Government Salary Payroll** The report notes that despite various reforms introduced to mitigate supplementary requests for additional funds to cater for wage shortfalls, there has not been significant results, and expenditure on wage is a substantial percentage of all entity budgets <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. The report also highlights payments for non-existent employees, underpayments to staff, and irregular overpayments to staff, among others <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. **Implementation of Approved Budget** The report notes that the implementation of the approved budget has not been effective, with several projects still in progress <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. **Management of Non-Current Assets** The report highlights changes in accounting treatment for non-current assets, which is essential for proper financial reporting [Docs 1 and 2]. **Implementation of Key Government Grants/Programmes** The report highlights the implementation of key government grants and programmes, including the District Rural Water Supply and Sanitation Conditional Grant, the Uganda Intergovernmental Fiscal Transfers Program, and the Education Development Grant [Docs 1 and 2]. **Implementation of Parish Development Model** The report highlights the implementation of the Parish Development Model, which is an important initiative aimed at improving service delivery at the parish level <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. Overall, the key findings of this audit report highlight several areas that require improvement, including the management of government salary payroll, the implementation of approved budgets, and the management of non-current assets. These findings are important for ensuring that local governments effectively manage their resources and deliver services to their constituents. ", "time": "1739452675.134787", "feedback": "okay"}
|
4 |
+
{"session_id": "36194e83-cd6e-4ded-97ee-a09e3df06713", "client_ip": "127.0.0.1", "client_location": {"city": null, "region": null, "country": null, "latitude": null, "longitude": null}, "session_duration_seconds": 3e-06, "year": ["2023"], "question": "What were the most significant areas of non-compliance in this audit?", "retriever": "BAAI/bge-large-en-v1.5", "endpoint_type": "DEDICATED", "reader": "meta-llama/Llama-3.1-8B-Instruct", "answer": "0 comparable ", "time": "1739453128.23646"}
|
5 |
+
{"session_id": "36194e83-cd6e-4ded-97ee-a09e3df06713", "client_ip": "127.0.0.1", "client_location": {"city": null, "region": null, "country": null, "latitude": null, "longitude": null}, "session_duration_seconds": 103.374957, "year": ["2023"], "question": "What are the key findings of this audit report?", "retriever": "BAAI/bge-large-en-v1.5", "endpoint_type": "DEDICATED", "reader": "meta-llama/Llama-3.1-8B-Instruct", "answer": "The audit report highlights several key findings, which are summarized below: **Management of Government Salary Payroll** The report notes that despite various reforms introduced to mitigate supplementary requests for additional funds to cater for wage shortfalls, there has not been significant results, and expenditure on wage is a substantial percentage of all entity budgets <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. The report also highlights payments for non-existent employees, underpayments to staff, and irregular overpayments to staff, among others <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. **Implementation of Approved Budget** The report notes that the implementation of the approved budget has not been effective, with several projects still in progress <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. **Management of Non-Current Assets** The report highlights changes in accounting treatment for non-current assets, which is essential for proper financial reporting [Docs 1 and 2]. **Implementation of Key Government Grants/Programmes** The report highlights the implementation of key government grants and programmes, including the District Rural Water Supply and Sanitation Conditional Grant, the Uganda Intergovernmental Fiscal Transfers Program, and the Education Development Grant [Docs 1 and 2]. **Implementation of Parish Development Model** The report highlights the implementation of the Parish Development Model, which is an important initiative aimed at improving service delivery at the parish level <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. Overall, the key findings of this audit report highlight several areas that require improvement, including the management of government salary payroll, the implementation of approved budgets, and the management of non-current assets. These findings are important for ensuring that local governments effectively manage their resources and deliver services to their constituents. ", "time": "1739453230.082439"}
|
6 |
+
{"session_id": "02fffa38-18e4-4fa1-9562-d220ca22689f", "client_ip": "127.0.0.1", "client_location": {"city": null, "region": null, "country": null, "latitude": null, "longitude": null}, "session_duration_seconds": 4e-06, "year": ["2023"], "question": "What are the key findings of this audit report?", "retriever": "BAAI/bge-large-en-v1.5", "endpoint_type": "DEDICATED", "reader": "meta-llama/Llama-3.1-8B-Instruct", "answer": "The audit report highlights several key findings, which are summarized below: **Management of Government Salary Payroll** The report notes that despite various reforms introduced to mitigate supplementary requests for additional funds to cater for wage shortfalls, there has not been significant results, and expenditure on wage is a substantial percentage of all entity budgets <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. The report also highlights payments for non-existent employees, underpayments to staff, and irregular overpayments to staff, among others <a href=\"#doc2\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>2</sup></span></a>. **Implementation of Approved Budget** The report notes that the implementation of the approved budget has not been effective, with several projects still in progress <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. **Management of Non-Current Assets** The report highlights changes in accounting treatment for non-current assets, which is essential for proper financial reporting [Docs 1 and 2]. **Implementation of Key Government Grants/Programmes** The report highlights the implementation of key government grants and programmes, including the District Rural Water Supply and Sanitation Conditional Grant, the Uganda Intergovernmental Fiscal Transfers Program, and the Education Development Grant [Docs 1 and 2]. **Implementation of Parish Development Model** The report highlights the implementation of the Parish Development Model, which is an important initiative aimed at improving service delivery at the parish level <a href=\"#doc1\" class=\"a-doc-ref\" target=\"_self\"><span class='doc-ref'><sup>1</sup></span></a>. Overall, the key findings of this audit report highlight several areas that require improvement, including the management of government salary payroll, the implementation of approved budgets, and the management of non-current assets. These findings are important for ensuring that local governments effectively manage their resources and deliver services to their constituents. ", "time": "1739453480.730711"}
|
7 |
+
{"session_id": "d71bbb2e-fdd0-4cfb-9548-be7172e4dd92", "client_ip": "127.0.0.1", "client_location": {"city": null, "region": null, "country": null, "latitude": null, "longitude": null}, "session_duration_seconds": 4e-06, "year": ["2023"], "question": "Did this audit highlight any issues with financial management or budgeting?", "retriever": "BAAI/bge-large-en-v1.5", "endpoint_type": "DEDICATED", "reader": "meta-llama/Llama-3.1-8B-Instruct", "answer": "Last, Summary: https://1, for 19 and So,760Are corresponding to the 2 jsonp ", "time": "1739453555.950608"}
|
8 |
+
{"session_id": "d71bbb2e-fdd0-4cfb-9548-be7172e4dd92", "client_ip": "127.0.0.1", "client_location": {"city": null, "region": null, "country": null, "latitude": null, "longitude": null}, "session_duration_seconds": 4e-06, "year": ["2023"], "question": "Did this audit highlight any issues with financial management or budgeting?", "retriever": "BAAI/bge-large-en-v1.5", "endpoint_type": "DEDICATED", "reader": "meta-llama/Llama-3.1-8B-Instruct", "answer": "Last, Summary: https://1, for 19 and So,760Are corresponding to the 2 jsonp ", "time": "1739453555.950608", "feedback": "okay"}
|
auditqa/reader.py
CHANGED
@@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
|
|
16 |
model_config = getconfig("model_params.cfg")
|
17 |
# NVIDIA_SERVER = os.environ["NVIDIA_SERVERLESS"]
|
18 |
# HF_token = os.environ["LLAMA_3_1"]
|
19 |
-
HF_token = os.getenv('LLAMA_3_1') # TESTING
|
20 |
|
21 |
def nvidia_client():
|
22 |
logger.info("NVIDIA client activated")
|
|
|
16 |
model_config = getconfig("model_params.cfg")
|
17 |
# NVIDIA_SERVER = os.environ["NVIDIA_SERVERLESS"]
|
18 |
# HF_token = os.environ["LLAMA_3_1"]
|
19 |
+
# HF_token = os.getenv('LLAMA_3_1') # TESTING
|
20 |
|
21 |
def nvidia_client():
|
22 |
logger.info("NVIDIA client activated")
|
auditqa/utils.py
CHANGED
@@ -9,63 +9,34 @@ import requests
|
|
9 |
from datetime import datetime
|
10 |
from uuid import uuid4
|
11 |
|
|
|
12 |
# TESTING DEBUG LOG
|
13 |
from auditqa.logging_config import setup_logging
|
14 |
setup_logging()
|
15 |
import logging
|
16 |
logger = logging.getLogger(__name__)
|
17 |
-
logger.setLevel(logging.DEBUG) # Ensure debug logging is enabled
|
18 |
-
|
19 |
-
|
20 |
-
# def save_logs(scheduler, JSON_DATASET_PATH, logs, feedback=None) -> None:
|
21 |
-
# """ Every interaction with app saves the log of question and answer,
|
22 |
-
# this is to get the usage statistics of app and evaluate model performances.
|
23 |
-
# Also saves user feedback (when provided).
|
24 |
-
# """
|
25 |
-
# if feedback:
|
26 |
-
# logs["feedback"] = feedback #optional
|
27 |
-
|
28 |
-
# with scheduler.lock:
|
29 |
-
# with open(JSON_DATASET_PATH, 'a') as f:
|
30 |
-
# json.dump(logs, f)
|
31 |
-
# f.write("\n")
|
32 |
-
# print("logging done")
|
33 |
-
|
34 |
|
35 |
-
import os
|
36 |
-
from pathlib import Path
|
37 |
|
38 |
-
def save_logs(JSON_DATASET_PATH
|
39 |
""" Every interaction with app saves the log of question and answer,
|
40 |
this is to get the usage statistics of app and evaluate model performances.
|
41 |
Also saves user feedback (when provided).
|
42 |
"""
|
43 |
try:
|
44 |
-
# Debug logging to verify path
|
45 |
-
logger.debug(f"Attempting to save logs to path: '{JSON_DATASET_PATH}'")
|
46 |
-
|
47 |
-
# Validate path
|
48 |
-
if not JSON_DATASET_PATH:
|
49 |
-
raise ValueError("JSON_DATASET_PATH cannot be empty")
|
50 |
-
|
51 |
-
# Create directory if it doesn't exist (using the current directory if no path specified)
|
52 |
-
path = Path(JSON_DATASET_PATH)
|
53 |
-
if str(path.parent) != '.':
|
54 |
-
path.parent.mkdir(parents=True, exist_ok=True)
|
55 |
-
|
56 |
if feedback:
|
57 |
-
logs["feedback"] = feedback
|
58 |
-
logging.debug(f"Adding feedback to logs: {feedback}")
|
59 |
|
60 |
-
with
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
64 |
except Exception as e:
|
65 |
logger.error(f"Failed to save logs to {JSON_DATASET_PATH}: {str(e)}")
|
66 |
raise
|
67 |
|
68 |
|
|
|
69 |
def get_message_template(type, SYSTEM_PROMPT, USER_PROMPT):
|
70 |
if type == 'NVIDIA':
|
71 |
messages = [{"role": "system", "content": SYSTEM_PROMPT},
|
|
|
9 |
from datetime import datetime
|
10 |
from uuid import uuid4
|
11 |
|
12 |
+
|
13 |
# TESTING DEBUG LOG
|
14 |
from auditqa.logging_config import setup_logging
|
15 |
setup_logging()
|
16 |
import logging
|
17 |
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
|
|
|
|
19 |
|
20 |
+
def save_logs(scheduler, JSON_DATASET_PATH, logs, feedback=None) -> None:
|
21 |
""" Every interaction with app saves the log of question and answer,
|
22 |
this is to get the usage statistics of app and evaluate model performances.
|
23 |
Also saves user feedback (when provided).
|
24 |
"""
|
25 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
if feedback:
|
27 |
+
logs["feedback"] = feedback #optional
|
|
|
28 |
|
29 |
+
with scheduler.lock:
|
30 |
+
with open(JSON_DATASET_PATH, 'a') as f:
|
31 |
+
json.dump(logs, f)
|
32 |
+
f.write("\n")
|
33 |
+
logger.info("logging done")
|
34 |
except Exception as e:
|
35 |
logger.error(f"Failed to save logs to {JSON_DATASET_PATH}: {str(e)}")
|
36 |
raise
|
37 |
|
38 |
|
39 |
+
|
40 |
def get_message_template(type, SYSTEM_PROMPT, USER_PROMPT):
|
41 |
if type == 'NVIDIA':
|
42 |
messages = [{"role": "system", "content": SYSTEM_PROMPT},
|
logs/app.log
CHANGED
@@ -1258,3 +1258,112 @@ Make sure your token has the correct permissions.
|
|
1258 |
2025-02-13 09:28:48,855 - auditqa.reader - INFO - Serverless endpoint activated
|
1259 |
2025-02-13 09:28:48,855 - auditqa.reader - INFO - Initializing InferenceClient with model: meta-llama/Meta-Llama-3-8B-Instruct
|
1260 |
2025-02-13 09:28:48,855 - auditqa.reader - INFO - Serverless InferenceClient initialization successful
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1258 |
2025-02-13 09:28:48,855 - auditqa.reader - INFO - Serverless endpoint activated
|
1259 |
2025-02-13 09:28:48,855 - auditqa.reader - INFO - Initializing InferenceClient with model: meta-llama/Meta-Llama-3-8B-Instruct
|
1260 |
2025-02-13 09:28:48,855 - auditqa.reader - INFO - Serverless InferenceClient initialization successful
|
1261 |
+
2025-02-13 13:17:13,057 - __main__ - INFO - App launched
|
1262 |
+
2025-02-13 13:17:25,747 - datasets - INFO - PyTorch version 2.4.0 available.
|
1263 |
+
2025-02-13 13:17:25,846 - sentence_transformers.SentenceTransformer - INFO - Load pretrained SentenceTransformer: BAAI/bge-large-en-v1.5
|
1264 |
+
2025-02-13 13:17:28,233 - httpx - INFO - HTTP Request: GET https://checkip.amazonaws.com/ "HTTP/1.1 200 "
|
1265 |
+
2025-02-13 13:17:28,236 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7861/startup-events "HTTP/1.1 200 OK"
|
1266 |
+
2025-02-13 13:17:28,247 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7861/ "HTTP/1.1 200 OK"
|
1267 |
+
2025-02-13 13:17:28,801 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
1268 |
+
2025-02-13 13:17:41,050 - __main__ - DEBUG - Chat function called with query: What are the key findings of this audit report?
|
1269 |
+
2025-02-13 13:17:41,054 - __main__ - DEBUG - Client IP: 127.0.0.1
|
1270 |
+
2025-02-13 13:17:41,055 - __main__ - DEBUG - Session ID: None
|
1271 |
+
2025-02-13 13:17:41,378 - __main__ - DEBUG - Created new session: e7df9e7f-b24d-4b3f-ba1f-368af70c4bae
|
1272 |
+
2025-02-13 13:17:41,378 - __main__ - DEBUG - Session duration: 4e-06
|
1273 |
+
2025-02-13 13:17:41,379 - auditqa.retriever - INFO - Retriever activated
|
1274 |
+
2025-02-13 13:17:42,963 - sentence_transformers.cross_encoder.CrossEncoder - INFO - Use pytorch device: mps
|
1275 |
+
2025-02-13 13:17:46,569 - httpx - INFO - HTTP Request: POST https://ff3f0448-0a00-470e-9956-49efa3071db3.europe-west3-0.gcp.cloud.qdrant.io:6333/collections/allreports/points/search "HTTP/1.1 200 OK"
|
1276 |
+
2025-02-13 13:17:54,937 - auditqa.retriever - INFO - retrieved paragraphs:3
|
1277 |
+
2025-02-13 13:17:55,134 - auditqa.reader - INFO - Serverless endpoint activated
|
1278 |
+
2025-02-13 13:17:55,135 - auditqa.reader - INFO - Initializing InferenceClient with model: meta-llama/Meta-Llama-3-8B-Instruct
|
1279 |
+
2025-02-13 13:17:55,135 - auditqa.reader - INFO - Serverless InferenceClient initialization successful
|
1280 |
+
2025-02-13 13:25:20,803 - __main__ - DEBUG - Chat function called with query: What were the most significant areas of non-compliance in this audit?
|
1281 |
+
2025-02-13 13:25:20,804 - __main__ - DEBUG - Client IP: 127.0.0.1
|
1282 |
+
2025-02-13 13:25:20,805 - __main__ - DEBUG - Session ID: None
|
1283 |
+
2025-02-13 13:25:21,132 - __main__ - DEBUG - Created new session: 36194e83-cd6e-4ded-97ee-a09e3df06713
|
1284 |
+
2025-02-13 13:25:21,132 - __main__ - DEBUG - Session duration: 3e-06
|
1285 |
+
2025-02-13 13:25:21,133 - auditqa.retriever - INFO - Retriever activated
|
1286 |
+
2025-02-13 13:25:22,284 - sentence_transformers.cross_encoder.CrossEncoder - INFO - Use pytorch device: mps
|
1287 |
+
2025-02-13 13:25:25,299 - httpx - INFO - HTTP Request: POST https://ff3f0448-0a00-470e-9956-49efa3071db3.europe-west3-0.gcp.cloud.qdrant.io:6333/collections/allreports/points/search "HTTP/1.1 200 OK"
|
1288 |
+
2025-02-13 13:25:28,041 - auditqa.retriever - INFO - retrieved paragraphs:3
|
1289 |
+
2025-02-13 13:25:28,236 - auditqa.reader - INFO - Serverless endpoint activated
|
1290 |
+
2025-02-13 13:25:28,236 - auditqa.reader - INFO - Initializing InferenceClient with model: meta-llama/Meta-Llama-3-8B-Instruct
|
1291 |
+
2025-02-13 13:25:28,236 - auditqa.reader - INFO - Serverless InferenceClient initialization successful
|
1292 |
+
2025-02-13 13:27:04,178 - __main__ - DEBUG - Chat function called with query: What are the key findings of this audit report?
|
1293 |
+
2025-02-13 13:27:04,180 - __main__ - DEBUG - Client IP: 127.0.0.1
|
1294 |
+
2025-02-13 13:27:04,180 - __main__ - DEBUG - Session ID: 36194e83-cd6e-4ded-97ee-a09e3df06713
|
1295 |
+
2025-02-13 13:27:04,180 - __main__ - DEBUG - Updated existing session: 36194e83-cd6e-4ded-97ee-a09e3df06713
|
1296 |
+
2025-02-13 13:27:04,180 - __main__ - DEBUG - Session duration: 103.374957
|
1297 |
+
2025-02-13 13:27:04,181 - auditqa.retriever - INFO - Retriever activated
|
1298 |
+
2025-02-13 13:27:05,440 - sentence_transformers.cross_encoder.CrossEncoder - INFO - Use pytorch device: mps
|
1299 |
+
2025-02-13 13:27:07,465 - httpx - INFO - HTTP Request: POST https://ff3f0448-0a00-470e-9956-49efa3071db3.europe-west3-0.gcp.cloud.qdrant.io:6333/collections/allreports/points/search "HTTP/1.1 200 OK"
|
1300 |
+
2025-02-13 13:27:09,928 - auditqa.retriever - INFO - retrieved paragraphs:3
|
1301 |
+
2025-02-13 13:27:10,082 - auditqa.reader - INFO - Serverless endpoint activated
|
1302 |
+
2025-02-13 13:27:10,082 - auditqa.reader - INFO - Initializing InferenceClient with model: meta-llama/Meta-Llama-3-8B-Instruct
|
1303 |
+
2025-02-13 13:27:10,082 - auditqa.reader - INFO - Serverless InferenceClient initialization successful
|
1304 |
+
2025-02-13 13:30:35,153 - __main__ - INFO - App launched
|
1305 |
+
2025-02-13 13:30:43,141 - datasets - INFO - PyTorch version 2.4.0 available.
|
1306 |
+
2025-02-13 13:30:43,252 - sentence_transformers.SentenceTransformer - INFO - Load pretrained SentenceTransformer: BAAI/bge-large-en-v1.5
|
1307 |
+
2025-02-13 13:30:45,039 - httpx - INFO - HTTP Request: GET https://checkip.amazonaws.com/ "HTTP/1.1 200 "
|
1308 |
+
2025-02-13 13:30:45,075 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7861/startup-events "HTTP/1.1 200 OK"
|
1309 |
+
2025-02-13 13:30:45,088 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7861/ "HTTP/1.1 200 OK"
|
1310 |
+
2025-02-13 13:30:45,644 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
1311 |
+
2025-02-13 13:31:13,135 - __main__ - DEBUG - Chat function called with query: What are the key findings of this audit report?
|
1312 |
+
2025-02-13 13:31:13,137 - __main__ - DEBUG - Client IP: 127.0.0.1
|
1313 |
+
2025-02-13 13:31:13,137 - __main__ - DEBUG - Session ID: None
|
1314 |
+
2025-02-13 13:31:13,429 - __main__ - DEBUG - Created new session: 02fffa38-18e4-4fa1-9562-d220ca22689f
|
1315 |
+
2025-02-13 13:31:13,430 - __main__ - DEBUG - Session duration: 4e-06
|
1316 |
+
2025-02-13 13:31:13,432 - auditqa.retriever - INFO - Retriever activated
|
1317 |
+
2025-02-13 13:31:14,595 - sentence_transformers.cross_encoder.CrossEncoder - INFO - Use pytorch device: mps
|
1318 |
+
2025-02-13 13:31:18,041 - httpx - INFO - HTTP Request: POST https://ff3f0448-0a00-470e-9956-49efa3071db3.europe-west3-0.gcp.cloud.qdrant.io:6333/collections/allreports/points/search "HTTP/1.1 200 OK"
|
1319 |
+
2025-02-13 13:31:20,460 - auditqa.retriever - INFO - retrieved paragraphs:3
|
1320 |
+
2025-02-13 13:31:20,730 - auditqa.reader - INFO - Serverless endpoint activated
|
1321 |
+
2025-02-13 13:31:20,731 - auditqa.reader - INFO - Initializing InferenceClient with model: meta-llama/Meta-Llama-3-8B-Instruct
|
1322 |
+
2025-02-13 13:31:20,731 - auditqa.reader - INFO - Serverless InferenceClient initialization successful
|
1323 |
+
2025-02-13 13:32:29,628 - __main__ - DEBUG - Chat function called with query: Did this audit highlight any issues with financial management or budgeting?
|
1324 |
+
2025-02-13 13:32:29,628 - __main__ - DEBUG - Client IP: 127.0.0.1
|
1325 |
+
2025-02-13 13:32:29,629 - __main__ - DEBUG - Session ID: None
|
1326 |
+
2025-02-13 13:32:29,951 - __main__ - DEBUG - Created new session: d71bbb2e-fdd0-4cfb-9548-be7172e4dd92
|
1327 |
+
2025-02-13 13:32:29,952 - __main__ - DEBUG - Session duration: 4e-06
|
1328 |
+
2025-02-13 13:32:29,953 - auditqa.retriever - INFO - Retriever activated
|
1329 |
+
2025-02-13 13:32:31,023 - sentence_transformers.cross_encoder.CrossEncoder - INFO - Use pytorch device: mps
|
1330 |
+
2025-02-13 13:32:33,388 - httpx - INFO - HTTP Request: POST https://ff3f0448-0a00-470e-9956-49efa3071db3.europe-west3-0.gcp.cloud.qdrant.io:6333/collections/allreports/points/search "HTTP/1.1 200 OK"
|
1331 |
+
2025-02-13 13:32:35,776 - auditqa.retriever - INFO - retrieved paragraphs:3
|
1332 |
+
2025-02-13 13:32:35,950 - auditqa.reader - INFO - Serverless endpoint activated
|
1333 |
+
2025-02-13 13:32:35,950 - auditqa.reader - INFO - Initializing InferenceClient with model: meta-llama/Meta-Llama-3-8B-Instruct
|
1334 |
+
2025-02-13 13:32:35,950 - auditqa.reader - INFO - Serverless InferenceClient initialization successful
|
1335 |
+
2025-02-13 13:38:04,160 - __main__ - INFO - App launched
|
1336 |
+
2025-02-13 13:38:47,642 - datasets - INFO - PyTorch version 2.4.0 available.
|
1337 |
+
2025-02-13 13:38:47,747 - sentence_transformers.SentenceTransformer - INFO - Load pretrained SentenceTransformer: BAAI/bge-large-en-v1.5
|
1338 |
+
2025-02-13 13:38:49,468 - httpx - INFO - HTTP Request: GET https://checkip.amazonaws.com/ "HTTP/1.1 200 "
|
1339 |
+
2025-02-13 13:38:49,487 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7860/startup-events "HTTP/1.1 200 OK"
|
1340 |
+
2025-02-13 13:38:49,499 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
1341 |
+
2025-02-13 13:38:50,052 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
1342 |
+
2025-02-13 13:38:57,260 - __main__ - DEBUG - Chat function called with query: What are the key findings of this audit report?
|
1343 |
+
2025-02-13 13:38:57,261 - __main__ - DEBUG - Client IP: 127.0.0.1
|
1344 |
+
2025-02-13 13:38:57,261 - __main__ - DEBUG - Session ID: None
|
1345 |
+
2025-02-13 13:38:57,554 - __main__ - DEBUG - Created new session: d1474d8d-fbb3-4ee2-a5f7-1072a7988e19
|
1346 |
+
2025-02-13 13:38:57,554 - __main__ - DEBUG - Session duration: 2e-06
|
1347 |
+
2025-02-13 13:38:57,554 - auditqa.retriever - INFO - Retriever activated
|
1348 |
+
2025-02-13 13:38:58,659 - sentence_transformers.cross_encoder.CrossEncoder - INFO - Use pytorch device: mps
|
1349 |
+
2025-02-13 13:39:01,094 - httpx - INFO - HTTP Request: POST https://ff3f0448-0a00-470e-9956-49efa3071db3.europe-west3-0.gcp.cloud.qdrant.io:6333/collections/allreports/points/search "HTTP/1.1 200 OK"
|
1350 |
+
2025-02-13 13:39:03,167 - auditqa.retriever - INFO - retrieved paragraphs:3
|
1351 |
+
2025-02-13 13:39:03,336 - auditqa.reader - INFO - Serverless endpoint activated
|
1352 |
+
2025-02-13 13:39:03,336 - auditqa.reader - INFO - Initializing InferenceClient with model: meta-llama/Meta-Llama-3-8B-Instruct
|
1353 |
+
2025-02-13 13:39:03,336 - auditqa.reader - INFO - Serverless InferenceClient initialization successful
|
1354 |
+
2025-02-13 13:39:17,031 - auditqa.utils - INFO - logging done
|
1355 |
+
2025-02-13 13:39:20,010 - auditqa.utils - INFO - logging done
|
1356 |
+
2025-02-13 13:39:37,524 - __main__ - DEBUG - Chat function called with query: Were there any procurement or contract management concerns raised in this audit?
|
1357 |
+
2025-02-13 13:39:37,525 - __main__ - DEBUG - Client IP: 127.0.0.1
|
1358 |
+
2025-02-13 13:39:37,526 - __main__ - DEBUG - Session ID: d1474d8d-fbb3-4ee2-a5f7-1072a7988e19
|
1359 |
+
2025-02-13 13:39:37,526 - __main__ - DEBUG - Updated existing session: d1474d8d-fbb3-4ee2-a5f7-1072a7988e19
|
1360 |
+
2025-02-13 13:39:37,526 - __main__ - DEBUG - Session duration: 40.264755
|
1361 |
+
2025-02-13 13:39:37,528 - auditqa.retriever - INFO - Retriever activated
|
1362 |
+
2025-02-13 13:39:38,620 - sentence_transformers.cross_encoder.CrossEncoder - INFO - Use pytorch device: mps
|
1363 |
+
2025-02-13 13:39:41,124 - httpx - INFO - HTTP Request: POST https://ff3f0448-0a00-470e-9956-49efa3071db3.europe-west3-0.gcp.cloud.qdrant.io:6333/collections/allreports/points/search "HTTP/1.1 200 OK"
|
1364 |
+
2025-02-13 13:39:43,955 - auditqa.retriever - INFO - retrieved paragraphs:3
|
1365 |
+
2025-02-13 13:39:44,129 - auditqa.reader - INFO - Serverless endpoint activated
|
1366 |
+
2025-02-13 13:39:44,129 - auditqa.reader - INFO - Initializing InferenceClient with model: meta-llama/Meta-Llama-3-8B-Instruct
|
1367 |
+
2025-02-13 13:39:44,129 - auditqa.reader - INFO - Serverless InferenceClient initialization successful
|
1368 |
+
2025-02-13 13:40:00,385 - auditqa.utils - INFO - logging done
|
1369 |
+
2025-02-13 13:40:05,605 - auditqa.utils - INFO - logging done
|