@@ -40,7 +40,9 @@ def rephrase_text(
40
40
self ,
41
41
text : Union [str , Iterable [str ]],
42
42
* ,
43
- target_lang : Union [str , Language ],
43
+ target_lang : Union [None , str , Language ] = None ,
44
+ style : Optional [str ] = None ,
45
+ tone : Optional [str ] = None ,
44
46
) -> Union [WriteResult , List [WriteResult ]]:
45
47
"""Improve the text(s) and optionally convert them to the variant of
46
48
the `target_lang` (requires source lang to match target_lang, excluding
@@ -51,6 +53,10 @@ def rephrase_text(
51
53
generator)
52
54
:param target_lang: language code the final text should be in, for
53
55
example "DE", "EN-US", "FR".
56
+ :param style: Writing style to be used for the improvement. Either
57
+ style OR tone can be used.
58
+ :param tone: Tone to be used for the improvement. Either style OR tone
59
+ can be used.
54
60
:return: List of WriteResult objects containing results, unless input
55
61
text was one string, then a single WriteResult object is returned.
56
62
"""
@@ -68,7 +74,13 @@ def rephrase_text(
68
74
"text parameter must be a string or an iterable of strings"
69
75
)
70
76
71
- request_data = {"target_lang" : target_lang , "text" : text }
77
+ request_data : dict = {"text" : text }
78
+ if target_lang :
79
+ request_data ["target_lang" ] = target_lang
80
+ if style :
81
+ request_data ["writing_style" ] = style
82
+ if tone :
83
+ request_data ["tone" ] = tone
72
84
73
85
status , content , json = self ._api_call (
74
86
"v2/write/rephrase" , json = request_data
0 commit comments