Update app.py
Browse files
app.py
CHANGED
|
@@ -32,6 +32,7 @@ user_db = {os.environ['username1']: os.environ['password1'], os.environ['usernam
|
|
| 32 |
|
| 33 |
messages = [{"role": "system", "content": 'You are a helpful assistant.'}]
|
| 34 |
errors = []
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
|
|
@@ -95,19 +96,44 @@ def delete_pinecone(index_name):
|
|
| 95 |
# Record feed back
|
| 96 |
|
| 97 |
def not_in_error():
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
|
| 101 |
def not_found_error():
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
def list_erros():
|
| 110 |
-
|
|
|
|
| 111 |
|
| 112 |
|
| 113 |
|
|
@@ -129,7 +155,9 @@ def roleChoice(role):
|
|
| 129 |
|
| 130 |
def talk2file(index_name, text):
|
| 131 |
#disable the global message
|
| 132 |
-
|
|
|
|
|
|
|
| 133 |
messages = [{"role": "system", "content": 'You are a helpful assistant.'}]
|
| 134 |
|
| 135 |
#same as filesearch
|
|
@@ -199,7 +227,14 @@ def show():
|
|
| 199 |
# feed back record
|
| 200 |
with gr.Blocks() as FeedBack:
|
| 201 |
gr.Markdown("Record Feedback for the ROCm Usage Tutor, using the following three buttons to record three different errors:\n 1. ROCm-related contexts not included in the ROCm repo.\n 2. Context included in the repo, but the vector server fails to find it.\n 3. The LLM model fails to understand the context.")
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
|
| 205 |
|
|
|
|
| 32 |
|
| 33 |
messages = [{"role": "system", "content": 'You are a helpful assistant.'}]
|
| 34 |
errors = []
|
| 35 |
+
error_recorded = 1
|
| 36 |
|
| 37 |
|
| 38 |
|
|
|
|
| 96 |
# Record feed back
|
| 97 |
|
| 98 |
def not_in_error():
|
| 99 |
+
global error_recorded
|
| 100 |
+
if(error_recorded):
|
| 101 |
+
return
|
| 102 |
+
else:
|
| 103 |
+
global messages
|
| 104 |
+
error_recorded = 1
|
| 105 |
+
error = ("not_in_error", messages)
|
| 106 |
+
errors.append(error)
|
| 107 |
+
return "Thank you, the question has been marked as not in ROCm."
|
| 108 |
|
| 109 |
|
| 110 |
def not_found_error():
|
| 111 |
+
global error_recorded
|
| 112 |
+
if(error_recorded):
|
| 113 |
+
return
|
| 114 |
+
else:
|
| 115 |
+
global messages
|
| 116 |
+
error_recorded = 1
|
| 117 |
+
error = ("not_found_error", messages)
|
| 118 |
+
errors.append(error)
|
| 119 |
+
return "Thank you, the context has been marked as not found in Vector Server."
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def llm_error():
|
| 124 |
+
global error_recorded
|
| 125 |
+
if(error_recorded):
|
| 126 |
+
return
|
| 127 |
+
else:
|
| 128 |
+
global messages
|
| 129 |
+
error_recorded = 1
|
| 130 |
+
error = ("not_found_error", messages)
|
| 131 |
+
errors.append(error)
|
| 132 |
+
return "Thank you, the LLM error has been recorded correctly."
|
| 133 |
|
| 134 |
def list_erros():
|
| 135 |
+
global errors
|
| 136 |
+
return errors
|
| 137 |
|
| 138 |
|
| 139 |
|
|
|
|
| 155 |
|
| 156 |
def talk2file(index_name, text):
|
| 157 |
#disable the global message
|
| 158 |
+
global messages
|
| 159 |
+
global error_recorded
|
| 160 |
+
error_recorded = 0
|
| 161 |
messages = [{"role": "system", "content": 'You are a helpful assistant.'}]
|
| 162 |
|
| 163 |
#same as filesearch
|
|
|
|
| 227 |
# feed back record
|
| 228 |
with gr.Blocks() as FeedBack:
|
| 229 |
gr.Markdown("Record Feedback for the ROCm Usage Tutor, using the following three buttons to record three different errors:\n 1. ROCm-related contexts not included in the ROCm repo.\n 2. Context included in the repo, but the vector server fails to find it.\n 3. The LLM model fails to understand the context.")
|
| 230 |
+
notin_btn = gr.Button("Not_In_Err")
|
| 231 |
+
notin_btn.click(fn=not_in_error, inputs=None, outputs="text", queue=False)
|
| 232 |
+
notfound_btn = gr.Button("Not_Found_Err")
|
| 233 |
+
notfound_btn.click(fn=not_found_error, inputs=None, outputs="text", queue=False)
|
| 234 |
+
llmerr_btn = gr.Button("LLM_Err")
|
| 235 |
+
llmerr_btn.click(fn=llm_error, inputs=None, outputs="text", queue=False)
|
| 236 |
+
listerr_btn = gr.Button("List_Erros")
|
| 237 |
+
listerr_btn.click(fn=list_erros, inputs=None, outputs="text", queue=False)
|
| 238 |
|
| 239 |
|
| 240 |
|