1111from openai .types import ChatModel
1212from openai .types .chat import ChatCompletionMessageParam
1313from 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
1515from viur .core .prototypes import List , Singleton , Tree
1616
1717from viur .assistant .config import ASSISTANT_LOGGER , CONFIG
@@ -52,8 +52,8 @@ class Assistant(Singleton):
5252 kindName : t .Final [str ] = "viur-assistant"
5353
5454 @exposed
55- @access ("user-view " )
56- # TODO: @force_post
55+ @access ("admin " )
56+ @force_post
5757 def generate_script (
5858 self ,
5959 * ,
@@ -89,9 +89,6 @@ def generate_script(
8989 - The actual parsing of the generated code (e.g., extracting specific script content)
9090 is currently marked as a TODO and has to be discussed.
9191 """
92-
93- kindName : t .Final [str ] = "viur-assistant"
94-
9592 if not (skel := self .getContents ()):
9693 raise errors .InternalServerError (descr = "Configuration missing" )
9794
@@ -190,14 +187,13 @@ def get_viur_structures(self, modules_to_include: t.Iterable[str]) -> dict[str,
190187 return structures_from_viur
191188
192189 @exposed
193- @access ("user-view " )
194- # TODO: @force_post
190+ @access ("admin " )
191+ @force_post
195192 def translate (
196193 self ,
197194 * ,
198195 text : str ,
199196 language : str ,
200- simplified : bool = False ,
201197 characteristic : t .Optional [str ] = None ,
202198 ):
203199 """
@@ -209,25 +205,16 @@ def translate(
209205
210206 :param text: The source text to translate.
211207 :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.
214208 :param characteristic: Optional translation style (e.g. ``"simplified"``, ``"formal"``, etc.)
215209 as defined in ``CONFIG.translate_language_characteristics``.
216210 :return: Translated text as a plain string. HTML tags from the original text are preserved.
217211
218- :raises BadRequest: If both ``simplified`` and ``characteristic`` are used simultaneously.
219212 :raises InternalServerError: If configuration is missing.
220213
221214 .. note::
222215 - The translation style is determined by merging base rules (`*`) and the selected characteristic.
223216 - The returned translation contains only the translated text, with no explanation or additional formatting.
224217 """
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-
231218 if not (skel := self .getContents ()):
232219 raise errors .InternalServerError (descr = "Configuration missing" )
233220
@@ -252,7 +239,8 @@ def translate(
252239 return self .render_text (message )
253240
254241 @exposed
255- @access ("user-view" )
242+ @access ("admin" , "file-view" )
243+ @force_post
256244 def describe_image (
257245 self ,
258246 filekey : db .Key | str ,
0 commit comments