@@ -16,10 +16,12 @@ if (!process.env.DEEPINFRA_API_KEY) {
16
16
const romanizationSchema = z . object ( {
17
17
translation : z . string ( ) ,
18
18
romanization : z . string ( ) ,
19
+ edited : z . string ( ) ,
19
20
} ) ;
20
21
21
22
const standardSchema = z . object ( {
22
23
translation : z . string ( ) ,
24
+ edited : z . string ( ) ,
23
25
} ) ;
24
26
25
27
const inputSchema = z . object ( {
@@ -34,17 +36,34 @@ export async function POST(request: NextRequest) {
34
36
35
37
const prompt =
36
38
language === Language . CHINESE_CN
37
- ? `Translate the following text into Simplified Chinese (Mandarin).
38
- Make sure to:
39
- 1. Use only Simplified Chinese characters (not Traditional).
40
- 2. Use pinyin with diacritic marks (not numeric).
41
- 3. Return a valid JSON object with:
42
- - "translation" key: Simplified Chinese character translation
43
- - "romanization" key: pinyin romanization with diacritic marks (NOT numeric) and syllables separated by spaces.
39
+ ? `Given the following text, return:
40
+ 1. A grammatically corrected version of the original text with proper punctuation, ensuring complete sentences and avoiding fragments
41
+ 2. A translation into Simplified Chinese (Mandarin)
42
+ 3. Pinyin romanization with diacritic marks
43
+
44
+ When correcting the text:
45
+ - Join sentence fragments into complete thoughts
46
+ - Ensure proper subject-verb relationships
47
+ - Maintain the original meaning while making the text more cohesive
48
+
49
+ Return a valid JSON object with:
50
+ - "edited" key: corrected original text with complete sentences
51
+ - "translation" key: Simplified Chinese character translation
52
+ - "romanization" key: pinyin with diacritic marks (NOT numeric) and syllables separated by spaces
44
53
45
54
Text: ${ text } `
46
- : `Translate the following text into ${ language } .
47
- Return a valid JSON object with a single key "translation" whose value is the translation.
55
+ : `Given the following text, return:
56
+ 1. A grammatically corrected version of the original text with proper punctuation, ensuring complete sentences and avoiding fragments
57
+ 2. A translation into ${ language }
58
+
59
+ When correcting the text:
60
+ - Join sentence fragments into complete thoughts
61
+ - Ensure proper subject-verb relationships
62
+ - Maintain the original meaning while making the text more cohesive
63
+
64
+ Return a valid JSON object with:
65
+ - "edited" key: corrected original text with complete sentences
66
+ - "translation" key: translation
48
67
49
68
Text: ${ text } ` ;
50
69
0 commit comments