app.py
Browse files
app.py
CHANGED
@@ -47,15 +47,29 @@ if not OPENAI_API_KEY:
|
|
47 |
# Tabs
|
48 |
tab1, tab2 = st.tabs(["Contract", "Technical"])
|
49 |
|
50 |
-
|
|
|
51 |
def save_flagged_response(user_query, ai_response):
|
52 |
flagged_data = {
|
53 |
"query": user_query,
|
54 |
"response": ai_response,
|
55 |
"timestamp": datetime.now().isoformat()
|
56 |
}
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
st.success("Response flagged for review.")
|
60 |
|
61 |
# Contract Chat Section
|
@@ -121,4 +135,10 @@ ASSISTANT_CONTRACT_ID = "asst_rd9h8PfYuOmHbkvOF3RTmVfn"
|
|
121 |
ASSISTANT_TECHNICAL_ID = "asst_xizNZBCJuy4TqdjqjwkxbAki"
|
122 |
|
123 |
contract_chat_section(tab1, ASSISTANT_CONTRACT_ID, "contract_messages", "contract_input")
|
124 |
-
contract_chat_section(tab2, ASSISTANT_TECHNICAL_ID, "technical_messages", "technical_input")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
# Tabs
|
48 |
tab1, tab2 = st.tabs(["Contract", "Technical"])
|
49 |
|
50 |
+
FLAGGED_RESPONSES_FILE = "/mnt/data/flagged_responses.json"
|
51 |
+
|
52 |
def save_flagged_response(user_query, ai_response):
|
53 |
flagged_data = {
|
54 |
"query": user_query,
|
55 |
"response": ai_response,
|
56 |
"timestamp": datetime.now().isoformat()
|
57 |
}
|
58 |
+
|
59 |
+
if os.path.exists(FLAGGED_RESPONSES_FILE):
|
60 |
+
with open(FLAGGED_RESPONSES_FILE, "r") as file:
|
61 |
+
try:
|
62 |
+
existing_data = json.load(file)
|
63 |
+
except json.JSONDecodeError:
|
64 |
+
existing_data = []
|
65 |
+
else:
|
66 |
+
existing_data = []
|
67 |
+
|
68 |
+
existing_data.append(flagged_data)
|
69 |
+
|
70 |
+
with open(FLAGGED_RESPONSES_FILE, "w") as file:
|
71 |
+
json.dump(existing_data, file, indent=4)
|
72 |
+
|
73 |
st.success("Response flagged for review.")
|
74 |
|
75 |
# Contract Chat Section
|
|
|
135 |
ASSISTANT_TECHNICAL_ID = "asst_xizNZBCJuy4TqdjqjwkxbAki"
|
136 |
|
137 |
contract_chat_section(tab1, ASSISTANT_CONTRACT_ID, "contract_messages", "contract_input")
|
138 |
+
contract_chat_section(tab2, ASSISTANT_TECHNICAL_ID, "technical_messages", "technical_input")
|
139 |
+
|
140 |
+
# Provide download option for flagged responses
|
141 |
+
if os.path.exists(FLAGGED_RESPONSES_FILE):
|
142 |
+
with open(FLAGGED_RESPONSES_FILE, "r") as file:
|
143 |
+
flagged_responses = file.read()
|
144 |
+
st.download_button("Download Flagged Responses", data=flagged_responses, file_name="flagged_responses.json", mime="application/json")
|