Skip to content

Commit 8baa177

Browse files
Error management + prompt updates + new xliffs
1 parent e39e875 commit 8baa177

File tree

8 files changed

+84
-46
lines changed

8 files changed

+84
-46
lines changed

Project/Sources/Forms/D_AI_Prompt/form.4DForm

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -231,30 +231,6 @@
231231
"fill": "transparent",
232232
"fontTheme": "normal"
233233
},
234-
"btn_launch": {
235-
"type": "button",
236-
"text": "",
237-
"top": 530,
238-
"left": 620,
239-
"width": 30,
240-
"height": 30,
241-
"events": [
242-
"onClick"
243-
],
244-
"method": "ObjectMethods/btn_launch.4dm",
245-
"sizingX": "move",
246-
"style": "toolbar",
247-
"borderStyle": "none",
248-
"sizingY": "move",
249-
"shortcutAccel": false,
250-
"shortcutControl": false,
251-
"shortcutShift": false,
252-
"shortcutAlt": false,
253-
"shortcutKey": "[Enter]",
254-
"icon": "/RESOURCES/Images/AI/send_32.png",
255-
"iconFrames": 4,
256-
"tooltip": ":xliff:SendRequest"
257-
},
258234
"btn_InsertAsStyledText": {
259235
"type": "button",
260236
"text": "",
@@ -522,7 +498,7 @@
522498
},
523499
"spinner": {
524500
"type": "picture",
525-
"top": 558,
501+
"top": 528,
526502
"left": 620,
527503
"width": 32,
528504
"height": 32,
@@ -531,11 +507,35 @@
531507
"visibility": "hidden",
532508
"sizingX": "move",
533509
"sizingY": "move"
510+
},
511+
"btn_launch": {
512+
"type": "button",
513+
"text": "",
514+
"top": 530,
515+
"left": 620,
516+
"width": 30,
517+
"height": 30,
518+
"events": [
519+
"onClick"
520+
],
521+
"method": "ObjectMethods/btn_launch.4dm",
522+
"sizingX": "move",
523+
"style": "toolbar",
524+
"borderStyle": "none",
525+
"sizingY": "move",
526+
"shortcutAccel": false,
527+
"shortcutControl": false,
528+
"shortcutShift": false,
529+
"shortcutAlt": false,
530+
"shortcutKey": "[Enter]",
531+
"icon": "/RESOURCES/Images/AI/send_32.png",
532+
"iconFrames": 4,
533+
"tooltip": ":xliff:SendRequest"
534534
}
535535
}
536536
}
537537
],
538-
"geometryStamp": 1814,
538+
"geometryStamp": 1823,
539539
"editor": {
540540
"activeView": "View 1",
541541
"defaultView": "View 1",

Project/Sources/Methods/AI_CallBack.4dm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ If ($result.success)
1111
End if
1212

1313
Else
14-
// Alert($result.errors.formula(Formula(JSON Stringify($1))).join("\n"))
1514

16-
AI_updateForm(""; "") // just change state
15+
If ($result.errors.length>0)
16+
$answer:=""
17+
$answer+="**"+Localized string:C991("ErrorCodeColon")+"**"
18+
$answer+=$result.errors[0].code+"\r"
19+
$answer+="**"+Localized string:C991("ErrorMessageColon")+"**"
20+
$answer+=$result.errors[0].message
21+
Else
22+
$answer:=Localized string:C991("GlobalError")
23+
End if
24+
AI_updateForm($answer; "Error") // just change state
1725

1826
End if
1927

Project/Sources/Methods/AI_updateForm.4dm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ var $newDoc : Object
1616

1717
Case of
1818

19-
: ($action="") // error to be managed
20-
Form:C1466._extra.state:=1 // rub
19+
: ($action="Error") // error to be managed
20+
Form:C1466._extra.state:=0 // Run
21+
AI_updateForm($content; "Set Text"; True:C214)
2122

2223
: ($action="Set Text")
2324

Project/Sources/TableForms/1/InputToolBarBasic/ObjectMethods/Button2.4dm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ If ($file.exists)
77
$ai_pref:=JSON Parse:C1218($file.getText())
88
$apiKey:=$ai_pref.apiKey
99

10-
WP SetAIKey($apiKey)
10+
If (Shift down:C543)
11+
WP SetAIKey("Golf")
12+
Else
13+
WP SetAIKey($apiKey)
14+
End if
15+
1116
WP UpdateWidget("WPtoolbar"; "WParea")
1217

1318
Else

Project/Sources/TableForms/1/InputToolBarBasic/form.4DForm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@
163163
"type": "button",
164164
"text": "Activate AI",
165165
"top": 740,
166-
"left": 240,
167-
"width": 191,
166+
"left": 180,
167+
"width": 131,
168168
"height": 27,
169169
"events": [
170170
"onClick"
@@ -177,8 +177,8 @@
177177
"type": "button",
178178
"text": "Unactivate AI",
179179
"top": 739,
180-
"left": 458,
181-
"width": 191,
180+
"left": 588,
181+
"width": 121,
182182
"height": 27,
183183
"events": [
184184
"onClick"
@@ -209,7 +209,7 @@
209209
"kind": "form"
210210
},
211211
"method": "method.4dm",
212-
"geometryStamp": 444,
212+
"geometryStamp": 476,
213213
"editor": {
214214
"activeView": "View 1",
215215
"defaultView": "View 1",

Resources/4DWP_AI/Prompts/en/prompts.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
3-
"title": "Summarize the section",
4-
"prompt": "Can you summarize this section for me?",
3+
"title": "Summarize the selection",
4+
"prompt": "Can you summarize the selected text for me?",
55
"source": "selection"
66
},
77
{
@@ -13,8 +13,8 @@
1313
"title": "-"
1414
},
1515
{
16-
"title": "Translate the section",
17-
"prompt": "Can you translate this section into french?",
16+
"title": "Translate the selection",
17+
"prompt": "Can you translate the selected text into french?",
1818
"source": "selection"
1919
},
2020
{
@@ -26,8 +26,8 @@
2626
"title": "-"
2727
},
2828
{
29-
"title": "Rewrite the section",
30-
"prompt": "Can you help me improve this section? I'd like it to be clearer and more engaging.",
29+
"title": "Rewrite the selection",
30+
"prompt": "Can you help me improve the selected text? I'd like it to be clearer and more engaging.",
3131
"source": "selection"
3232
},
3333
{
@@ -39,8 +39,8 @@
3939
"title": "-"
4040
},
4141
{
42-
"title": "Check the section grammar",
43-
"prompt": "Can you check the grammar of this section and tell me if there is any error?",
42+
"title": "Check the selection grammar",
43+
"prompt": "Can you check the grammar of the selected text and tell me if there is any error?",
4444
"source": "selection"
4545
},
4646
{

Resources/en.lproj/WPC.xlf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,19 @@ Would you like to replace it?</target>
21132113
<trans-unit id="xx" resname="AI">
21142114
<source>A.I.</source>
21152115
<target>A.I.</target>
2116-
</trans-unit>
2116+
</trans-unit>
2117+
<trans-unit id="xx" resname="ErrorCodeColon">
2118+
<source>Error code: </source>
2119+
<target>Error code: </target>
2120+
</trans-unit>
2121+
<trans-unit id="xx" resname="ErrorMessageColon">
2122+
<source>Error message: </source>
2123+
<target>Error message: </target>
2124+
</trans-unit>
2125+
<trans-unit id="xx" resname="GlobalError">
2126+
<source>An error occured.</source>
2127+
<target>An error occured.</target>
2128+
</trans-unit>
21172129
</group>
21182130

21192131
<group resname="DialogAI_Prompt_Tips">

Resources/fr.lproj/WPC.xlf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,19 @@ Souhaitez-vous le remplacer ?</target>
21132113
<trans-unit id="xx" resname="AI">
21142114
<source>A.I.</source>
21152115
<target>I.A.</target>
2116-
</trans-unit>
2116+
</trans-unit>
2117+
<trans-unit id="xx" resname="ErrorCodeColon">
2118+
<source>Error code: </source>
2119+
<target>Code erreur : </target>
2120+
</trans-unit>
2121+
<trans-unit id="xx" resname="ErrorMessageColon">
2122+
<source>Error message: </source>
2123+
<target>Message d'erreur : </target>
2124+
</trans-unit>
2125+
<trans-unit id="xx" resname="GlobalError">
2126+
<source>An error occured.</source>
2127+
<target>Une erreur est survenue.</target>
2128+
</trans-unit>
21172129
</group>
21182130

21192131
<group resname="DialogAI_Prompt_Tips">

0 commit comments

Comments
 (0)