-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtranslation.ts
More file actions
141 lines (123 loc) · 5.79 KB
/
translation.ts
File metadata and controls
141 lines (123 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';
export class Translation extends APIResource {
/**
* Translate text from one language to another.
*
* @deprecated Will be removed in a future release. Migrate to `chat.chat` with the translate tool for translation capabilities. See documentation at dev.writer.com for more information.
*/
translate(body: TranslationTranslateParams, options?: RequestOptions): APIPromise<TranslationResponse> {
return this._client.post('/v1/translation', { body, ...options });
}
}
export interface TranslationRequest {
/**
* Whether to use formal or informal language in the translation. See the
* [list of languages that support formality](https://dev.writer.com/api-reference/translation-api/language-support#formality).
* If the language does not support formality, this parameter is ignored.
*/
formality: boolean;
/**
* Whether to control the length of the translated text. See the
* [list of languages that support length control](https://dev.writer.com/api-reference/translation-api/language-support#length-control).
* If the language does not support length control, this parameter is ignored.
*/
length_control: boolean;
/**
* Whether to mask profane words in the translated text. See the
* [list of languages that do not support profanity masking](https://dev.writer.com/api-reference/translation-api/language-support#profanity-masking).
* If the language does not support profanity masking, this parameter is ignored.
*/
mask_profanity: boolean;
/**
* The model to use for translation.
*/
model: 'palmyra-translate';
/**
* The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)
* language code of the original text to translate. For example, `en` for English,
* `zh` for Chinese, `fr` for French, `es` for Spanish. If the language has a
* variant, the code appends the two-digit
* [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes).
* For example, Mexican Spanish is `es-MX`. See the
* [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support).
*/
source_language_code: string;
/**
* The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)
* language code of the target language for the translation. For example, `en` for
* English, `zh` for Chinese, `fr` for French, `es` for Spanish. If the language
* has a variant, the code appends the two-digit
* [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes).
* For example, Mexican Spanish is `es-MX`. See the
* [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support).
*/
target_language_code: string;
/**
* The text to translate. Maximum of 100,000 words.
*/
text: string;
}
export interface TranslationResponse {
/**
* The result of the translation.
*/
data: string;
}
export interface TranslationTranslateParams {
/**
* Whether to use formal or informal language in the translation. See the
* [list of languages that support formality](https://dev.writer.com/api-reference/translation-api/language-support#formality).
* If the language does not support formality, this parameter is ignored.
*/
formality: boolean;
/**
* Whether to control the length of the translated text. See the
* [list of languages that support length control](https://dev.writer.com/api-reference/translation-api/language-support#length-control).
* If the language does not support length control, this parameter is ignored.
*/
length_control: boolean;
/**
* Whether to mask profane words in the translated text. See the
* [list of languages that do not support profanity masking](https://dev.writer.com/api-reference/translation-api/language-support#profanity-masking).
* If the language does not support profanity masking, this parameter is ignored.
*/
mask_profanity: boolean;
/**
* The model to use for translation.
*/
model: 'palmyra-translate';
/**
* The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)
* language code of the original text to translate. For example, `en` for English,
* `zh` for Chinese, `fr` for French, `es` for Spanish. If the language has a
* variant, the code appends the two-digit
* [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes).
* For example, Mexican Spanish is `es-MX`. See the
* [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support).
*/
source_language_code: string;
/**
* The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)
* language code of the target language for the translation. For example, `en` for
* English, `zh` for Chinese, `fr` for French, `es` for Spanish. If the language
* has a variant, the code appends the two-digit
* [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes).
* For example, Mexican Spanish is `es-MX`. See the
* [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support).
*/
target_language_code: string;
/**
* The text to translate. Maximum of 100,000 words.
*/
text: string;
}
export declare namespace Translation {
export {
type TranslationRequest as TranslationRequest,
type TranslationResponse as TranslationResponse,
type TranslationTranslateParams as TranslationTranslateParams,
};
}