aimodelshare 0.3.7__py3-none-any.whl → 0.3.94__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aimodelshare/moral_compass/__init__.py +51 -2
- aimodelshare/moral_compass/api_client.py +92 -4
- aimodelshare/moral_compass/apps/__init__.py +36 -16
- aimodelshare/moral_compass/apps/ai_consequences.py +98 -88
- aimodelshare/moral_compass/apps/bias_detective_ca.py +2722 -0
- aimodelshare/moral_compass/apps/bias_detective_en.py +2722 -0
- aimodelshare/moral_compass/apps/bias_detective_part1.py +2722 -0
- aimodelshare/moral_compass/apps/bias_detective_part2.py +2465 -0
- aimodelshare/moral_compass/apps/bias_detective_part_es.py +2722 -0
- aimodelshare/moral_compass/apps/ethical_revelation.py +237 -147
- aimodelshare/moral_compass/apps/fairness_fixer.py +1839 -859
- aimodelshare/moral_compass/apps/fairness_fixer_ca.py +1869 -0
- aimodelshare/moral_compass/apps/fairness_fixer_en.py +1869 -0
- aimodelshare/moral_compass/apps/fairness_fixer_es.py +1869 -0
- aimodelshare/moral_compass/apps/judge.py +130 -143
- aimodelshare/moral_compass/apps/justice_equity_upgrade.py +793 -831
- aimodelshare/moral_compass/apps/justice_equity_upgrade_ca.py +815 -0
- aimodelshare/moral_compass/apps/justice_equity_upgrade_en.py +815 -0
- aimodelshare/moral_compass/apps/justice_equity_upgrade_es.py +815 -0
- aimodelshare/moral_compass/apps/mc_integration_helpers.py +227 -745
- aimodelshare/moral_compass/apps/model_building_app_ca.py +4399 -0
- aimodelshare/moral_compass/apps/model_building_app_ca_final.py +3899 -0
- aimodelshare/moral_compass/apps/model_building_app_en.py +4167 -0
- aimodelshare/moral_compass/apps/model_building_app_en_final.py +3869 -0
- aimodelshare/moral_compass/apps/model_building_app_es.py +4351 -0
- aimodelshare/moral_compass/apps/model_building_app_es_final.py +3899 -0
- aimodelshare/moral_compass/apps/model_building_game.py +4211 -935
- aimodelshare/moral_compass/apps/moral_compass_challenge.py +195 -95
- aimodelshare/moral_compass/apps/what_is_ai.py +126 -117
- aimodelshare/moral_compass/challenge.py +98 -17
- {aimodelshare-0.3.7.dist-info → aimodelshare-0.3.94.dist-info}/METADATA +1 -1
- {aimodelshare-0.3.7.dist-info → aimodelshare-0.3.94.dist-info}/RECORD +35 -19
- aimodelshare/moral_compass/apps/bias_detective.py +0 -714
- {aimodelshare-0.3.7.dist-info → aimodelshare-0.3.94.dist-info}/WHEEL +0 -0
- {aimodelshare-0.3.7.dist-info → aimodelshare-0.3.94.dist-info}/licenses/LICENSE +0 -0
- {aimodelshare-0.3.7.dist-info → aimodelshare-0.3.94.dist-info}/top_level.txt +0 -0
|
@@ -21,7 +21,18 @@ try:
|
|
|
21
21
|
create_ai_consequences_app, launch_ai_consequences_app,
|
|
22
22
|
create_what_is_ai_app, launch_what_is_ai_app,
|
|
23
23
|
create_model_building_game_app, launch_model_building_game_app,
|
|
24
|
-
create_model_building_game_beginner_app, launch_model_building_game_beginner_app
|
|
24
|
+
create_model_building_game_beginner_app, launch_model_building_game_beginner_app,
|
|
25
|
+
# Language-specific variants
|
|
26
|
+
create_model_building_game_en_app, launch_model_building_game_en_app,
|
|
27
|
+
create_model_building_game_ca_app, launch_model_building_game_ca_app,
|
|
28
|
+
create_model_building_game_es_app, launch_model_building_game_es_app,
|
|
29
|
+
# NEW: Final language-specific variants
|
|
30
|
+
create_model_building_game_en_final_app, launch_model_building_game_en_final_app,
|
|
31
|
+
create_model_building_game_es_final_app, launch_model_building_game_es_final_app,
|
|
32
|
+
create_model_building_game_ca_final_app, launch_model_building_game_ca_final_app,
|
|
33
|
+
# Bias Detective split apps
|
|
34
|
+
create_bias_detective_part1_app, launch_bias_detective_part1_app,
|
|
35
|
+
create_bias_detective_part2_app, launch_bias_detective_part2_app,
|
|
25
36
|
)
|
|
26
37
|
except Exception: # noqa: BLE001
|
|
27
38
|
# Fallback if Gradio apps have an issue (e.g., Gradio not installed)
|
|
@@ -37,6 +48,25 @@ except Exception: # noqa: BLE001
|
|
|
37
48
|
launch_model_building_game_app = None
|
|
38
49
|
create_model_building_game_beginner_app = None
|
|
39
50
|
launch_model_building_game_beginner_app = None
|
|
51
|
+
# Language-specific variants
|
|
52
|
+
create_model_building_game_en_app = None
|
|
53
|
+
launch_model_building_game_en_app = None
|
|
54
|
+
create_model_building_game_ca_app = None
|
|
55
|
+
launch_model_building_game_ca_app = None
|
|
56
|
+
create_model_building_game_es_app = None
|
|
57
|
+
launch_model_building_game_es_app = None
|
|
58
|
+
# NEW: Final language-specific variants
|
|
59
|
+
create_model_building_game_en_final_app = None
|
|
60
|
+
launch_model_building_game_en_final_app = None
|
|
61
|
+
create_model_building_game_es_final_app = None
|
|
62
|
+
launch_model_building_game_es_final_app = None
|
|
63
|
+
create_model_building_game_ca_final_app = None
|
|
64
|
+
launch_model_building_game_ca_final_app = None
|
|
65
|
+
# Bias Detective split apps
|
|
66
|
+
create_bias_detective_part1_app = None
|
|
67
|
+
launch_bias_detective_part1_app = None
|
|
68
|
+
create_bias_detective_part2_app = None
|
|
69
|
+
launch_bias_detective_part2_app = None
|
|
40
70
|
|
|
41
71
|
__all__ = [
|
|
42
72
|
"__version__",
|
|
@@ -61,5 +91,24 @@ __all__ = [
|
|
|
61
91
|
"create_model_building_game_app",
|
|
62
92
|
"launch_model_building_game_app",
|
|
63
93
|
"create_model_building_game_beginner_app",
|
|
64
|
-
"launch_model_building_game_beginner_app"
|
|
94
|
+
"launch_model_building_game_beginner_app",
|
|
95
|
+
# Language-specific variants
|
|
96
|
+
"create_model_building_game_en_app",
|
|
97
|
+
"launch_model_building_game_en_app",
|
|
98
|
+
"create_model_building_game_ca_app",
|
|
99
|
+
"launch_model_building_game_ca_app",
|
|
100
|
+
"create_model_building_game_es_app",
|
|
101
|
+
"launch_model_building_game_es_app",
|
|
102
|
+
# NEW: Final language-specific variants
|
|
103
|
+
"create_model_building_game_en_final_app",
|
|
104
|
+
"launch_model_building_game_en_final_app",
|
|
105
|
+
"create_model_building_game_es_final_app",
|
|
106
|
+
"launch_model_building_game_es_final_app",
|
|
107
|
+
"create_model_building_game_ca_final_app",
|
|
108
|
+
"launch_model_building_game_ca_final_app",
|
|
109
|
+
# Bias Detective split apps
|
|
110
|
+
"create_bias_detective_part1_app",
|
|
111
|
+
"launch_bias_detective_part1_app",
|
|
112
|
+
"create_bias_detective_part2_app",
|
|
113
|
+
"launch_bias_detective_part2_app",
|
|
65
114
|
]
|
|
@@ -66,6 +66,7 @@ class MoralcompassUserStats:
|
|
|
66
66
|
submission_count: int = 0
|
|
67
67
|
total_count: int = 0
|
|
68
68
|
last_updated: Optional[str] = None
|
|
69
|
+
completed_task_ids: Optional[List[str]] = None
|
|
69
70
|
|
|
70
71
|
|
|
71
72
|
# ============================================================================
|
|
@@ -499,7 +500,8 @@ class MoralcompassApiClient:
|
|
|
499
500
|
username=user_data["username"],
|
|
500
501
|
submission_count=user_data.get("submissionCount", 0),
|
|
501
502
|
total_count=user_data.get("totalCount", 0),
|
|
502
|
-
last_updated=user_data.get("lastUpdated")
|
|
503
|
+
last_updated=user_data.get("lastUpdated"),
|
|
504
|
+
completed_task_ids=user_data.get("completedTaskIds")
|
|
503
505
|
)
|
|
504
506
|
|
|
505
507
|
last_key = response.get("lastKey")
|
|
@@ -527,11 +529,12 @@ class MoralcompassApiClient:
|
|
|
527
529
|
username=data["username"],
|
|
528
530
|
submission_count=data.get("submissionCount", 0),
|
|
529
531
|
total_count=data.get("totalCount", 0),
|
|
530
|
-
last_updated=data.get("lastUpdated")
|
|
532
|
+
last_updated=data.get("lastUpdated"),
|
|
533
|
+
completed_task_ids=data.get("completedTaskIds")
|
|
531
534
|
)
|
|
532
535
|
|
|
533
536
|
def put_user(self, table_id: str, username: str,
|
|
534
|
-
submission_count: int, total_count: int) -> Dict[str, Any]:
|
|
537
|
+
submission_count: int, total_count: int, team_name: Optional[str] = None) -> Dict[str, Any]:
|
|
535
538
|
"""
|
|
536
539
|
Create or update a user's stats in a table.
|
|
537
540
|
|
|
@@ -540,6 +543,7 @@ class MoralcompassApiClient:
|
|
|
540
543
|
username: The username
|
|
541
544
|
submission_count: Number of submissions
|
|
542
545
|
total_count: Total count
|
|
546
|
+
team_name: Optional team name for the user
|
|
543
547
|
|
|
544
548
|
Returns:
|
|
545
549
|
Dict containing update response
|
|
@@ -549,6 +553,9 @@ class MoralcompassApiClient:
|
|
|
549
553
|
"totalCount": total_count
|
|
550
554
|
}
|
|
551
555
|
|
|
556
|
+
if team_name is not None:
|
|
557
|
+
payload["teamName"] = team_name
|
|
558
|
+
|
|
552
559
|
response = self._request("PUT", f"/tables/{table_id}/users/{username}", json=payload)
|
|
553
560
|
return response.json()
|
|
554
561
|
|
|
@@ -558,7 +565,9 @@ class MoralcompassApiClient:
|
|
|
558
565
|
total_tasks: int = 0,
|
|
559
566
|
questions_correct: int = 0,
|
|
560
567
|
total_questions: int = 0,
|
|
561
|
-
primary_metric: Optional[str] = None
|
|
568
|
+
primary_metric: Optional[str] = None,
|
|
569
|
+
team_name: Optional[str] = None,
|
|
570
|
+
completed_task_ids: Optional[List[str]] = None) -> Dict[str, Any]:
|
|
562
571
|
"""
|
|
563
572
|
Update a user's moral compass score with dynamic metrics.
|
|
564
573
|
|
|
@@ -571,6 +580,8 @@ class MoralcompassApiClient:
|
|
|
571
580
|
questions_correct: Number of questions answered correctly (default: 0)
|
|
572
581
|
total_questions: Total number of questions (default: 0)
|
|
573
582
|
primary_metric: Optional primary metric name (defaults to 'accuracy' or first sorted key)
|
|
583
|
+
team_name: Optional team name for the user
|
|
584
|
+
completed_task_ids: Optional list of completed task IDs (e.g., ['t1', 't2'])
|
|
574
585
|
|
|
575
586
|
Returns:
|
|
576
587
|
Dict containing moralCompassScore and other fields
|
|
@@ -586,6 +597,12 @@ class MoralcompassApiClient:
|
|
|
586
597
|
if primary_metric is not None:
|
|
587
598
|
payload["primaryMetric"] = primary_metric
|
|
588
599
|
|
|
600
|
+
if team_name is not None:
|
|
601
|
+
payload["teamName"] = team_name
|
|
602
|
+
|
|
603
|
+
if completed_task_ids is not None:
|
|
604
|
+
payload["completedTaskIds"] = completed_task_ids
|
|
605
|
+
|
|
589
606
|
# Try hyphenated path first
|
|
590
607
|
try:
|
|
591
608
|
response = self._request("PUT", f"/tables/{table_id}/users/{username}/moral-compass", json=payload)
|
|
@@ -599,3 +616,74 @@ class MoralcompassApiClient:
|
|
|
599
616
|
else:
|
|
600
617
|
# Resource-level 404 (e.g., table or user not found), don't retry
|
|
601
618
|
raise
|
|
619
|
+
|
|
620
|
+
def add_tasks(self, table_id: str, username: str, task_ids: List[str]) -> Dict[str, Any]:
|
|
621
|
+
"""
|
|
622
|
+
Add task IDs to user's completedTaskIds list.
|
|
623
|
+
|
|
624
|
+
Args:
|
|
625
|
+
table_id: The table identifier
|
|
626
|
+
username: The username
|
|
627
|
+
task_ids: List of task IDs to add (e.g., ['t1', 't2'])
|
|
628
|
+
|
|
629
|
+
Returns:
|
|
630
|
+
Dict containing updated completedTaskIds
|
|
631
|
+
"""
|
|
632
|
+
payload = {
|
|
633
|
+
"op": "add",
|
|
634
|
+
"taskIds": task_ids
|
|
635
|
+
}
|
|
636
|
+
response = self._request("PATCH", f"/tables/{table_id}/users/{username}/tasks", json=payload)
|
|
637
|
+
return response.json()
|
|
638
|
+
|
|
639
|
+
def remove_tasks(self, table_id: str, username: str, task_ids: List[str]) -> Dict[str, Any]:
|
|
640
|
+
"""
|
|
641
|
+
Remove task IDs from user's completedTaskIds list.
|
|
642
|
+
|
|
643
|
+
Args:
|
|
644
|
+
table_id: The table identifier
|
|
645
|
+
username: The username
|
|
646
|
+
task_ids: List of task IDs to remove (e.g., ['t1', 't2'])
|
|
647
|
+
|
|
648
|
+
Returns:
|
|
649
|
+
Dict containing updated completedTaskIds
|
|
650
|
+
"""
|
|
651
|
+
payload = {
|
|
652
|
+
"op": "remove",
|
|
653
|
+
"taskIds": task_ids
|
|
654
|
+
}
|
|
655
|
+
response = self._request("PATCH", f"/tables/{table_id}/users/{username}/tasks", json=payload)
|
|
656
|
+
return response.json()
|
|
657
|
+
|
|
658
|
+
def reset_tasks(self, table_id: str, username: str, task_ids: Optional[List[str]] = None) -> Dict[str, Any]:
|
|
659
|
+
"""
|
|
660
|
+
Reset user's completedTaskIds list to the provided IDs.
|
|
661
|
+
|
|
662
|
+
Args:
|
|
663
|
+
table_id: The table identifier
|
|
664
|
+
username: The username
|
|
665
|
+
task_ids: List of task IDs to set (default: empty list)
|
|
666
|
+
|
|
667
|
+
Returns:
|
|
668
|
+
Dict containing updated completedTaskIds
|
|
669
|
+
"""
|
|
670
|
+
payload = {
|
|
671
|
+
"op": "reset",
|
|
672
|
+
"taskIds": task_ids or []
|
|
673
|
+
}
|
|
674
|
+
response = self._request("PATCH", f"/tables/{table_id}/users/{username}/tasks", json=payload)
|
|
675
|
+
return response.json()
|
|
676
|
+
|
|
677
|
+
def clear_tasks(self, table_id: str, username: str) -> Dict[str, Any]:
|
|
678
|
+
"""
|
|
679
|
+
Clear all task IDs from user's completedTaskIds list.
|
|
680
|
+
|
|
681
|
+
Args:
|
|
682
|
+
table_id: The table identifier
|
|
683
|
+
username: The username
|
|
684
|
+
|
|
685
|
+
Returns:
|
|
686
|
+
Dict containing empty completedTaskIds
|
|
687
|
+
"""
|
|
688
|
+
response = self._request("DELETE", f"/tables/{table_id}/users/{username}/tasks")
|
|
689
|
+
return response.json()
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Lazy export layer for Moral Compass Gradio app factories.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
Includes language-specific model building game variants:
|
|
5
|
+
- model_building_app_en.py
|
|
6
|
+
- model_building_app_ca.py
|
|
7
|
+
- model_building_app_es.py
|
|
8
|
+
- model_building_app_en_final.py
|
|
9
|
+
- model_building_app_ca_final.py
|
|
10
|
+
- model_building_app_es_final.py
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Usage:
|
|
11
|
-
from aimodelshare.moral_compass.apps.tutorial import create_tutorial_app
|
|
12
|
-
(or) from aimodelshare.moral_compass.apps import create_tutorial_app # lazy
|
|
12
|
+
If you rename files to model_building_game_<lang>.py, update _EXPORT_MAP accordingly.
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
import importlib
|
|
@@ -17,7 +17,6 @@ import logging
|
|
|
17
17
|
|
|
18
18
|
logger = logging.getLogger(__name__)
|
|
19
19
|
|
|
20
|
-
# Map exported attribute -> (module_name, symbol)
|
|
21
20
|
_EXPORT_MAP = {
|
|
22
21
|
"create_tutorial_app": ("tutorial", "create_tutorial_app"),
|
|
23
22
|
"launch_tutorial_app": ("tutorial", "launch_tutorial_app"),
|
|
@@ -27,16 +26,42 @@ _EXPORT_MAP = {
|
|
|
27
26
|
"launch_ai_consequences_app": ("ai_consequences", "launch_ai_consequences_app"),
|
|
28
27
|
"create_what_is_ai_app": ("what_is_ai", "create_what_is_ai_app"),
|
|
29
28
|
"launch_what_is_ai_app": ("what_is_ai", "launch_what_is_ai_app"),
|
|
29
|
+
# Legacy generic game
|
|
30
30
|
"create_model_building_game_app": ("model_building_game", "create_model_building_game_app"),
|
|
31
31
|
"launch_model_building_game_app": ("model_building_game", "launch_model_building_game_app"),
|
|
32
|
+
# Beginner variant
|
|
32
33
|
"create_model_building_game_beginner_app": ("model_building_game_beginner", "create_model_building_game_beginner_app"),
|
|
33
34
|
"launch_model_building_game_beginner_app": ("model_building_game_beginner", "launch_model_building_game_beginner_app"),
|
|
35
|
+
# Language-specific (adjusted to actual filenames model_building_app_<lang>.py)
|
|
36
|
+
"create_model_building_game_en_app": ("model_building_app_en", "create_model_building_game_en_app"),
|
|
37
|
+
"launch_model_building_game_en_app": ("model_building_app_en", "launch_model_building_game_en_app"),
|
|
38
|
+
"create_model_building_game_ca_app": ("model_building_app_ca", "create_model_building_game_ca_app"),
|
|
39
|
+
"launch_model_building_game_ca_app": ("model_building_app_ca", "launch_model_building_game_ca_app"),
|
|
40
|
+
"create_model_building_game_es_app": ("model_building_app_es", "create_model_building_game_es_app"),
|
|
41
|
+
"launch_model_building_game_es_app": ("model_building_app_es", "launch_model_building_game_es_app"),
|
|
42
|
+
|
|
43
|
+
# NEW: Final language-specific variants
|
|
44
|
+
"create_model_building_game_en_final_app": ("model_building_app_en_final", "create_model_building_game_en_final_app"),
|
|
45
|
+
"launch_model_building_game_en_final_app": ("model_building_app_en_final", "launch_model_building_game_en_final_app"),
|
|
46
|
+
"create_model_building_game_ca_final_app": ("model_building_app_ca_final", "create_model_building_game_ca_final_app"),
|
|
47
|
+
"launch_model_building_game_ca_final_app": ("model_building_app_ca_final", "launch_model_building_game_ca_final_app"),
|
|
48
|
+
"create_model_building_game_es_final_app": ("model_building_app_es_final", "create_model_building_game_es_final_app"),
|
|
49
|
+
"launch_model_building_game_es_final_app": ("model_building_app_es_final", "launch_model_building_game_es_final_app"),
|
|
50
|
+
|
|
51
|
+
# Other apps
|
|
34
52
|
"create_ethical_revelation_app": ("ethical_revelation", "create_ethical_revelation_app"),
|
|
35
53
|
"launch_ethical_revelation_app": ("ethical_revelation", "launch_ethical_revelation_app"),
|
|
36
54
|
"create_moral_compass_challenge_app": ("moral_compass_challenge", "create_moral_compass_challenge_app"),
|
|
37
55
|
"launch_moral_compass_challenge_app": ("moral_compass_challenge", "launch_moral_compass_challenge_app"),
|
|
38
|
-
|
|
39
|
-
|
|
56
|
+
|
|
57
|
+
# NEW: split Bias Detective into two explicit modules (part1 uses current code;
|
|
58
|
+
# part2 is the temporary placeholder module). Ensure files bias_detective_part1.py
|
|
59
|
+
# and bias_detective_part2.py exist under this package.
|
|
60
|
+
"create_bias_detective_part1_app": ("bias_detective_part1", "create_bias_detective_part1_app"),
|
|
61
|
+
"launch_bias_detective_part1_app": ("bias_detective_part1", "launch_bias_detective_part1_app"),
|
|
62
|
+
"create_bias_detective_part2_app": ("bias_detective_part2", "create_bias_detective_part2_app"),
|
|
63
|
+
"launch_bias_detective_part2_app": ("bias_detective_part2", "launch_bias_detective_part2_app"),
|
|
64
|
+
|
|
40
65
|
"create_fairness_fixer_app": ("fairness_fixer", "create_fairness_fixer_app"),
|
|
41
66
|
"launch_fairness_fixer_app": ("fairness_fixer", "launch_fairness_fixer_app"),
|
|
42
67
|
"create_justice_equity_upgrade_app": ("justice_equity_upgrade", "create_justice_equity_upgrade_app"),
|
|
@@ -45,12 +70,9 @@ _EXPORT_MAP = {
|
|
|
45
70
|
|
|
46
71
|
__all__ = list(_EXPORT_MAP.keys())
|
|
47
72
|
|
|
48
|
-
|
|
49
73
|
def __getattr__(name: str):
|
|
50
|
-
"""Dynamically import requested factory/launcher."""
|
|
51
74
|
if name not in _EXPORT_MAP:
|
|
52
75
|
raise AttributeError(f"Module '{__name__}' has no attribute '{name}'")
|
|
53
|
-
|
|
54
76
|
mod_name, symbol = _EXPORT_MAP[name]
|
|
55
77
|
try:
|
|
56
78
|
module = importlib.import_module(f".{mod_name}", __name__)
|
|
@@ -63,7 +85,5 @@ def __getattr__(name: str):
|
|
|
63
85
|
logger.error(f"Symbol '{symbol}' not found in module '{mod_name}': {e}")
|
|
64
86
|
raise
|
|
65
87
|
|
|
66
|
-
|
|
67
88
|
def list_available_apps():
|
|
68
|
-
"""Utility: return list of logical app names (for diagnostics)."""
|
|
69
89
|
return sorted({m for (m, _) in _EXPORT_MAP.values()})
|