You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class TranslateProvider implements ISynchronousProvider {
30
31
32
+
publicconstSYSTEM_PROMPT = 'You are a translations expert that ONLY outputs a valid JSON with the translated text in the following format: { "translation": "<translated text>" } .';
33
+
publicconstJSON_RESPONSE_FORMAT = [
34
+
'response_format' => [
35
+
'type' => 'json_schema',
36
+
'json_schema' => [
37
+
'name' => 'TranslationResponse',
38
+
'description' => 'A JSON object containing the translated text',
39
+
'strict' => true,
40
+
'schema' => [
41
+
'type' => 'object',
42
+
'properties' => [
43
+
'translation' => [
44
+
'type' => 'string',
45
+
'description' => 'The translated text',
46
+
],
47
+
],
48
+
'required' => [ 'translation' ],
49
+
'additionalProperties' => false,
50
+
],
51
+
],
52
+
],
53
+
];
54
+
31
55
publicfunction__construct(
32
56
privateOpenAiAPIService$openAiAPIService,
33
57
privateIAppConfig$appConfig,
@@ -144,7 +168,10 @@ public function process(?string $userId, array $input, callable $reportProgress)
144
168
}
145
169
146
170
if (!isset($input['input']) || !is_string($input['input'])) {
0 commit comments