Spaces:
Runtime error
Runtime error
Michelle Lam
commited on
Commit
•
9696318
1
Parent(s):
f769ab1
Fixes format of AVID Report credit field; adds optional name field in form; reverts style change
Browse files
audit_utils.py
CHANGED
@@ -336,6 +336,10 @@ def format_description(indie_label_json):
|
|
336 |
text_entry = indie_label_json["text_entry"]
|
337 |
return f"Title: {title}\nError Type: {error_type}\nSummary/Suggestions: {text_entry}"
|
338 |
|
|
|
|
|
|
|
|
|
339 |
# Convert indielabel json to AVID json format.
|
340 |
# See the AVID format in https://avidml.org/avidtools/reference/report
|
341 |
#
|
@@ -349,7 +353,7 @@ def format_description(indie_label_json):
|
|
349 |
# user_rating personal_model_score 0.92
|
350 |
# user_decision user_decision "Non-toxic"
|
351 |
# Note that this is at the individual report level.
|
352 |
-
def convert_indie_label_json_to_avid_json(indie_label_json, cur_user, email, sep_selection):
|
353 |
|
354 |
# Setting up the structure with a dict to enable programmatic additions
|
355 |
avid_json_dict = {
|
@@ -398,17 +402,16 @@ def convert_indie_label_json_to_avid_json(indie_label_json, cur_user, email, sep
|
|
398 |
"taxonomy_version": "0.2"
|
399 |
}
|
400 |
},
|
401 |
-
"credit":
|
|
|
|
|
|
|
402 |
"reported_date": "" # Leaving empty so that it can be dynamically filled in
|
403 |
}
|
404 |
|
405 |
-
avid_json_dict["description"] = format_description(indie_label_json)
|
406 |
-
avid_json_dict["reported_date"] = str(date.today())
|
407 |
-
|
408 |
-
if email != "":
|
409 |
-
avid_json_dict["credit"] = email
|
410 |
-
else:
|
411 |
-
avid_json_dict["credit"] = cur_user
|
412 |
|
413 |
sep_enum = get_sep_enum(sep_selection)
|
414 |
avid_json_dict["impact"]["avid"]["sep_view"] = [sep_enum]
|
|
|
336 |
text_entry = indie_label_json["text_entry"]
|
337 |
return f"Title: {title}\nError Type: {error_type}\nSummary/Suggestions: {text_entry}"
|
338 |
|
339 |
+
# Format the credit field for the report with the current user's username, optional name, and optional email address
|
340 |
+
def format_credit(cur_user, name, email):
|
341 |
+
return f"Username: {cur_user}, Name: {name}, Email: {email}"
|
342 |
+
|
343 |
# Convert indielabel json to AVID json format.
|
344 |
# See the AVID format in https://avidml.org/avidtools/reference/report
|
345 |
#
|
|
|
353 |
# user_rating personal_model_score 0.92
|
354 |
# user_decision user_decision "Non-toxic"
|
355 |
# Note that this is at the individual report level.
|
356 |
+
def convert_indie_label_json_to_avid_json(indie_label_json, cur_user, name, email, sep_selection):
|
357 |
|
358 |
# Setting up the structure with a dict to enable programmatic additions
|
359 |
avid_json_dict = {
|
|
|
402 |
"taxonomy_version": "0.2"
|
403 |
}
|
404 |
},
|
405 |
+
"credit": {
|
406 |
+
"lang": "eng", # TODO: Make language selectable
|
407 |
+
"value": "" # Leaving empty so that credit can be assigned
|
408 |
+
},
|
409 |
"reported_date": "" # Leaving empty so that it can be dynamically filled in
|
410 |
}
|
411 |
|
412 |
+
avid_json_dict["description"]["value"] = format_description(indie_label_json)
|
413 |
+
avid_json_dict["reported_date"] = str(date.today())
|
414 |
+
avid_json_dict["credit"]["value"] = format_credit(cur_user, name, email)
|
|
|
|
|
|
|
|
|
415 |
|
416 |
sep_enum = get_sep_enum(sep_selection)
|
417 |
avid_json_dict["impact"]["avid"]["sep_view"] = [sep_enum]
|
indie_label_svelte/public/bundle.css
DELETED
The diff for this file is too large to render.
See raw diff
|
|
indie_label_svelte/public/index.html
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
|
10 |
<link rel='icon' type='image/png' href='/favicon.png'>
|
11 |
<link rel='stylesheet' href='/global.css'>
|
12 |
-
<link rel='stylesheet' href='/bundle.css'>
|
13 |
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
|
14 |
|
15 |
<link
|
|
|
9 |
|
10 |
<link rel='icon' type='image/png' href='/favicon.png'>
|
11 |
<link rel='stylesheet' href='/global.css'>
|
12 |
+
<link rel='stylesheet' href='/build/bundle.css'>
|
13 |
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
|
14 |
|
15 |
<link
|
indie_label_svelte/src/SubmitReportDialog.svelte
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
export let open;
|
9 |
export let cur_user;
|
10 |
export let all_reports;
|
|
|
11 |
let email = "";
|
12 |
let all_sep_options = [
|
13 |
"Accuracy",
|
@@ -26,6 +27,7 @@
|
|
26 |
let req_params = {
|
27 |
cur_user: cur_user,
|
28 |
reports: JSON.stringify(all_reports),
|
|
|
29 |
email: email,
|
30 |
sep_selection: sep_selection,
|
31 |
};
|
@@ -51,7 +53,7 @@
|
|
51 |
<!-- Description -->
|
52 |
<div>
|
53 |
<b>When you are ready to send all of your audit reports to the <a href="https://avidml.org/" target="_blank">AI Vulnerability Database</a> (AVID), please fill out the following information.</b>
|
54 |
-
Only your submitted reports will be stored in the database for further analysis. While you can submit reports anonymously, we encourage you to provide your email so that we can contact you if we have any questions.
|
55 |
</div>
|
56 |
|
57 |
<!-- Summary of complete reports -->
|
@@ -79,6 +81,9 @@
|
|
79 |
{/each}
|
80 |
</Select>
|
81 |
</div>
|
|
|
|
|
|
|
82 |
<div>
|
83 |
<Textfield bind:value={email} label="(Optional) Contact email" style="width: 90%" />
|
84 |
</div>
|
|
|
8 |
export let open;
|
9 |
export let cur_user;
|
10 |
export let all_reports;
|
11 |
+
let name = "";
|
12 |
let email = "";
|
13 |
let all_sep_options = [
|
14 |
"Accuracy",
|
|
|
27 |
let req_params = {
|
28 |
cur_user: cur_user,
|
29 |
reports: JSON.stringify(all_reports),
|
30 |
+
name: name,
|
31 |
email: email,
|
32 |
sep_selection: sep_selection,
|
33 |
};
|
|
|
53 |
<!-- Description -->
|
54 |
<div>
|
55 |
<b>When you are ready to send all of your audit reports to the <a href="https://avidml.org/" target="_blank">AI Vulnerability Database</a> (AVID), please fill out the following information.</b>
|
56 |
+
Only your submitted reports will be stored in the database for further analysis. While you can submit reports anonymously, we encourage you to provide your name and/or email so that we can contact you if we have any questions.
|
57 |
</div>
|
58 |
|
59 |
<!-- Summary of complete reports -->
|
|
|
81 |
{/each}
|
82 |
</Select>
|
83 |
</div>
|
84 |
+
<div>
|
85 |
+
<Textfield bind:value={name} label="(Optional) Name" style="width: 90%" />
|
86 |
+
</div>
|
87 |
<div>
|
88 |
<Textfield bind:value={email} label="(Optional) Contact email" style="width: 90%" />
|
89 |
</div>
|
server.py
CHANGED
@@ -648,7 +648,7 @@ def get_eligible_reports(reports):
|
|
648 |
|
649 |
# Submit all reports to AVID
|
650 |
# Logs the responses
|
651 |
-
def submit_reports_to_AVID(reports, cur_user, email, sep_selection, debug=DEBUG):
|
652 |
# Set up the connection to AVID
|
653 |
root = os.environ.get('AVID_API_URL')
|
654 |
api_key = os.environ.get('AVID_API_KEY')
|
@@ -659,7 +659,7 @@ def submit_reports_to_AVID(reports, cur_user, email, sep_selection, debug=DEBUG)
|
|
659 |
print("Num eligible reports:", len(reports))
|
660 |
|
661 |
for r in reports:
|
662 |
-
new_report = utils.convert_indie_label_json_to_avid_json(r, cur_user, email, sep_selection)
|
663 |
url = root + "submit"
|
664 |
response = requests.post(url, json=json.loads(new_report), headers=key) # The loads ensures type compliance
|
665 |
uuid = response.json()
|
@@ -693,6 +693,7 @@ def save_reports(debug=DEBUG):
|
|
693 |
@app.route("/submit_avid_report")
|
694 |
def submit_avid_report():
|
695 |
cur_user = request.args.get("cur_user")
|
|
|
696 |
email = request.args.get("email")
|
697 |
sep_selection = request.args.get("sep_selection")
|
698 |
reports_json = request.args.get("reports")
|
@@ -700,7 +701,7 @@ def submit_avid_report():
|
|
700 |
reports = json.loads(reports_json)
|
701 |
|
702 |
# Submit reports to AVID
|
703 |
-
submit_reports_to_AVID(reports, cur_user, email, sep_selection)
|
704 |
|
705 |
results = {
|
706 |
"status": "success",
|
|
|
648 |
|
649 |
# Submit all reports to AVID
|
650 |
# Logs the responses
|
651 |
+
def submit_reports_to_AVID(reports, cur_user, name, email, sep_selection, debug=DEBUG):
|
652 |
# Set up the connection to AVID
|
653 |
root = os.environ.get('AVID_API_URL')
|
654 |
api_key = os.environ.get('AVID_API_KEY')
|
|
|
659 |
print("Num eligible reports:", len(reports))
|
660 |
|
661 |
for r in reports:
|
662 |
+
new_report = utils.convert_indie_label_json_to_avid_json(r, cur_user, name, email, sep_selection)
|
663 |
url = root + "submit"
|
664 |
response = requests.post(url, json=json.loads(new_report), headers=key) # The loads ensures type compliance
|
665 |
uuid = response.json()
|
|
|
693 |
@app.route("/submit_avid_report")
|
694 |
def submit_avid_report():
|
695 |
cur_user = request.args.get("cur_user")
|
696 |
+
name = request.args.get("name")
|
697 |
email = request.args.get("email")
|
698 |
sep_selection = request.args.get("sep_selection")
|
699 |
reports_json = request.args.get("reports")
|
|
|
701 |
reports = json.loads(reports_json)
|
702 |
|
703 |
# Submit reports to AVID
|
704 |
+
submit_reports_to_AVID(reports, cur_user, name, email, sep_selection)
|
705 |
|
706 |
results = {
|
707 |
"status": "success",
|