generated from MinBZK/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make AI Act profile editable and use a new version of the beslishulp
- Loading branch information
1 parent
1a744b9
commit 2de9e3f
Showing
29 changed files
with
445 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
from starlette.requests import Request | ||
|
||
from amt.api.ai_act_profile import SelectAiProfileItem, get_ai_act_profile_selector | ||
from amt.schema.webform import WebFormOption | ||
|
||
|
||
class EditableValuesProvider(ABC): | ||
@abstractmethod | ||
async def get_values(self, request: Request) -> list[WebFormOption]: | ||
pass | ||
|
||
|
||
class AIActValuesProvider(EditableValuesProvider): | ||
def __init__(self, type: str) -> None: | ||
self.type = type | ||
|
||
async def get_values(self, request: Request) -> list[WebFormOption]: | ||
profile = get_ai_act_profile_selector(request) | ||
target_ai_act_profile: SelectAiProfileItem | None = next( | ||
( | ||
ai_act_profile | ||
for ai_act_profile in (profile.dropdown_select or []) + (profile.multiple_select or []) | ||
if ai_act_profile.target_name == self.type | ||
), | ||
None, | ||
) | ||
if target_ai_act_profile is not None and target_ai_act_profile.options is not None: | ||
return [WebFormOption(value=option, display_value=option) for option in target_ai_act_profile.options] | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.