Skip to content

Commit b34a854

Browse files
committed
feat: bone action identifier
1 parent e49da15 commit b34a854

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

src/viur/assistant/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
from .bones.image import ImageBone, ImageBoneRelSkel
88
from .modules.assistant import Assistant
99
from .skeletons.assistant import AssistantSkel
10+
from .bones.actions import BONE_ACTION_KEY, BoneAction
1011
from .config import CONFIG
1112

1213
__all__ = [
1314
"Assistant",
15+
"BONE_ACTION_KEY",
16+
"BoneAction",
1417
"CONFIG",
1518
"ImageBone",
1619
"ImageBoneRelSkel",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Bone Actions
3+
4+
This module defines identifiers as they are used in vi-admin
5+
to activate certain additional actions on a bone.
6+
7+
Examples:
8+
~~~~~~~~~
9+
10+
.. code-block:: python
11+
12+
descr = TextBone(
13+
languages=["de", "en"],
14+
params={
15+
BONE_ACTION_KEY: [BoneAction.TRANSLATE],
16+
},
17+
)
18+
19+
descr = ImageBone(
20+
params={
21+
BONE_ACTION_KEY: [BoneAction.DESCRIBE_IMAGE],
22+
},
23+
)
24+
"""
25+
26+
import typing as t
27+
28+
BONE_ACTION_KEY: t.Final[str] = "actions"
29+
"""The key of the parameter"""
30+
31+
32+
class BoneAction:
33+
TRANSLATE: t.Final[str] = "translate"
34+
"""Translate text"""
35+
36+
DESCRIBE_IMAGE: t.Final[str] = "describe_image"
37+
"""Describe image with an alt text"""

src/viur/assistant/bones/image.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class ImageBone(FileBone):
1818
type = FileBone.type + ".image"
1919

2020
def __init__(
21-
self,
22-
*,
23-
using: t.Optional[RelSkel] = ImageBoneRelSkel,
24-
validMimeTypes: None | t.Iterable[str] = ["image/*"],
25-
**kwargs,
21+
self,
22+
*,
23+
using: t.Type[RelSkel] = ImageBoneRelSkel,
24+
validMimeTypes: None | t.Iterable[str] = ("image/*",),
25+
**kwargs,
2626
):
2727
super().__init__(
2828
using=using,

0 commit comments

Comments
 (0)