11
11
from openai .types import ChatModel
12
12
from openai .types .chat import ChatCompletionMessageParam
13
13
from viur .core import conf , current , db , errors , exposed , utils
14
- from viur .core .decorators import access
14
+ from viur .core .decorators import access , force_post
15
15
from viur .core .prototypes import List , Singleton , Tree
16
16
17
17
from viur .assistant .config import ASSISTANT_LOGGER , CONFIG
@@ -52,8 +52,8 @@ class Assistant(Singleton):
52
52
kindName : t .Final [str ] = "viur-assistant"
53
53
54
54
@exposed
55
- @access ("user-view " )
56
- # TODO: @force_post
55
+ @access ("admin " )
56
+ @force_post
57
57
def generate_script (
58
58
self ,
59
59
* ,
@@ -89,9 +89,6 @@ def generate_script(
89
89
- The actual parsing of the generated code (e.g., extracting specific script content)
90
90
is currently marked as a TODO and has to be discussed.
91
91
"""
92
-
93
- kindName : t .Final [str ] = "viur-assistant"
94
-
95
92
if not (skel := self .getContents ()):
96
93
raise errors .InternalServerError (descr = "Configuration missing" )
97
94
@@ -190,14 +187,13 @@ def get_viur_structures(self, modules_to_include: t.Iterable[str]) -> dict[str,
190
187
return structures_from_viur
191
188
192
189
@exposed
193
- @access ("user-view " )
194
- # TODO: @force_post
190
+ @access ("admin " )
191
+ @force_post
195
192
def translate (
196
193
self ,
197
194
* ,
198
195
text : str ,
199
196
language : str ,
200
- simplified : bool = False ,
201
197
characteristic : t .Optional [str ] = None ,
202
198
):
203
199
"""
@@ -209,25 +205,16 @@ def translate(
209
205
210
206
:param text: The source text to translate.
211
207
:param language: The target language code (e.g. ``"de"``, ``"en"``, ``"de-x-simple"``).
212
- :param simplified: **Deprecated** – Use ``characteristic="simplified"`` instead.
213
- When ``True``, applies a simplified language style.
214
208
:param characteristic: Optional translation style (e.g. ``"simplified"``, ``"formal"``, etc.)
215
209
as defined in ``CONFIG.translate_language_characteristics``.
216
210
:return: Translated text as a plain string. HTML tags from the original text are preserved.
217
211
218
- :raises BadRequest: If both ``simplified`` and ``characteristic`` are used simultaneously.
219
212
:raises InternalServerError: If configuration is missing.
220
213
221
214
.. note::
222
215
- The translation style is determined by merging base rules (`*`) and the selected characteristic.
223
216
- The returned translation contains only the translated text, with no explanation or additional formatting.
224
217
"""
225
- if simplified :
226
- if characteristic is not None :
227
- raise errors .BadRequest ("Cannot use parameter *simplified* and *characteristic* at the same time" )
228
- logger .warning ('simplified is deprecated, use characteristic="simplified" instead' )
229
- characteristic = "simplified"
230
-
231
218
if not (skel := self .getContents ()):
232
219
raise errors .InternalServerError (descr = "Configuration missing" )
233
220
@@ -252,7 +239,8 @@ def translate(
252
239
return self .render_text (message )
253
240
254
241
@exposed
255
- @access ("user-view" )
242
+ @access ("admin" , "file-view" )
243
+ @force_post
256
244
def describe_image (
257
245
self ,
258
246
filekey : db .Key | str ,
0 commit comments