Update app.py
Browse files
app.py
CHANGED
@@ -55,13 +55,13 @@ test = str(vectorstore_persisted.get())[:20]
|
|
55 |
log_file = Path("logs/") / f"data_{uuid.uuid4()}.json"
|
56 |
log_folder = log_file.parent
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
|
66 |
# Define the Q&A system message
|
67 |
qna_system_message = """
|
@@ -95,7 +95,7 @@ Answer:
|
|
95 |
Source:
|
96 |
[Source]
|
97 |
|
98 |
-
Page Number:
|
99 |
[Page Number]
|
100 |
"""
|
101 |
|
@@ -155,16 +155,16 @@ def predict(user_input,company):
|
|
155 |
# While writing to the log file, ensure that the commit scheduler is locked to avoid parallel
|
156 |
# access
|
157 |
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
|
169 |
return prediction
|
170 |
|
|
|
55 |
log_file = Path("logs/") / f"data_{uuid.uuid4()}.json"
|
56 |
log_folder = log_file.parent
|
57 |
|
58 |
+
scheduler = CommitScheduler(
|
59 |
+
repo_id="MJackman-Project3-logs",
|
60 |
+
repo_type="dataset",
|
61 |
+
folder_path=log_folder,
|
62 |
+
path_in_repo="data",
|
63 |
+
every=2
|
64 |
+
)
|
65 |
|
66 |
# Define the Q&A system message
|
67 |
qna_system_message = """
|
|
|
95 |
Source:
|
96 |
[Source]
|
97 |
|
98 |
+
Page Number(s):
|
99 |
[Page Number]
|
100 |
"""
|
101 |
|
|
|
155 |
# While writing to the log file, ensure that the commit scheduler is locked to avoid parallel
|
156 |
# access
|
157 |
|
158 |
+
with scheduler.lock:
|
159 |
+
with log_file.open("a") as f:
|
160 |
+
f.write(json.dumps(
|
161 |
+
{
|
162 |
+
'user_input': user_input,
|
163 |
+
'retrieved_context': context_for_query,
|
164 |
+
'model_response': prediction
|
165 |
+
}
|
166 |
+
))
|
167 |
+
f.write("\n")
|
168 |
|
169 |
return prediction
|
170 |
|