Skip to content

Commit 85cc1bd

Browse files
3 bug bug fixes (declared in the spec #596)
+ .title in prompts.json
1 parent 24c4de0 commit 85cc1bd

File tree

8 files changed

+48
-13
lines changed

8 files changed

+48
-13
lines changed

Project/Sources/Forms/D_AI_Prompt/ObjectMethods/Button.4dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var $x1; $y1; $x2; $y2 : Integer
55

66
GET WINDOW RECT:C443($winLeft; $winTop; $winRight; $WinBottom; Form:C1466.windowID)
77

8-
OBJECT GET COORDINATES:C663(*; "Rect_Frame"; $x1; $y1; $x2; $y2)
8+
OBJECT GET COORDINATES:C663(*; "history_area"; $x1; $y1; $x2; $y2)
99

1010
If (Form:C1466._extra.expanded)
1111
//FORM SET SIZE($x1; $y2)

Project/Sources/Forms/D_AI_Prompt/ObjectMethods/LB_Bookmarks.4dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If (Form:C1466.bookmarks.length>0)
1616
WP SELECT:C1348(*; "WParea"; $range) //$range.start; $range.start)
1717

1818
GOTO OBJECT:C206(*; "WParea")
19-
//SET TIMER(-1)
19+
SET TIMER:C645(-1) // to enable buttons
2020

2121
//Form.WPai:=Form.WPai
2222

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
"left": 90,
229229
"top": 530,
230230
"width": 530,
231-
"height": 49,
231+
"height": 59,
232232
"dataSource": "Form:C1466.prompt",
233233
"hideFocusRing": true,
234234
"borderStyle": "none",
@@ -262,7 +262,7 @@
262262
"shortcutControl": false,
263263
"shortcutShift": false,
264264
"shortcutAlt": false,
265-
"shortcutKey": "[Return]",
265+
"shortcutKey": "[Enter]",
266266
"icon": "/RESOURCES/Images/AI/send_32.png",
267267
"iconFrames": 4,
268268
"tooltip": ":xliff:SendRequest"
@@ -535,7 +535,7 @@
535535
}
536536
}
537537
],
538-
"geometryStamp": 1780,
538+
"geometryStamp": 1781,
539539
"editor": {
540540
"activeView": "View 1",
541541
"defaultView": "View 1",

Project/Sources/Forms/D_AI_Prompt/method.4dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Case of
1010

1111
Form:C1466._extra:={}
1212
Form:C1466._extra.expanded:=True:C214
13-
Form:C1466._extra.state:=-1 // -1 : désabled (run not allowed) 0: "run" / 1: "running" / 2:"rerun"
13+
Form:C1466._extra.state:=-1 // -1 : desabled (run not allowed) 0: "run" / 1: "running" / 2:"rerun"
1414

1515

1616
Form:C1466.openAI:=cs:C1710.AIKit.OpenAI.new(oform.aiKey) // PRIVATE KEY
@@ -46,7 +46,7 @@ Case of
4646
Form:C1466.promptMenu:=Create menu:C408
4747
$i:=0
4848
For each ($item; Form:C1466.prompts)
49-
APPEND MENU ITEM:C411(Form:C1466.promptMenu; $item.prompt)
49+
APPEND MENU ITEM:C411(Form:C1466.promptMenu; $item.title)
5050
SET MENU ITEM PARAMETER:C1004(Form:C1466.promptMenu; -1; String:C10($i))
5151
$i+=1
5252
End for each

Project/Sources/Methods/AI Call.4dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Case of
3636
Form:C1466._extra.count:=0 // used to detect first answer
3737
Form:C1466._extra.answer:="" // use to cumulate answer
3838

39-
Form:C1466.chat.prompt($aiParameters.prompt)
39+
Form:C1466.chat.prompt($aiParameters.prompt) //<----- CALL
4040

4141
//$messages:=[]
4242
//$messages.push({role: "system"; content: "You are a helpful assistant."})

Project/Sources/Methods/AI_updateForm.4dm

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
var $file : 4D:C1709.File
55
var $_breaks : Collection
6-
var $tempoThems : Collection
6+
var $tempoThems; $breaks : Collection
77
var $result; $p : Integer
88
var $memoRange1; $memoRange2; $promptRange; $answerRange; $breakRange : Object
9-
var $break; $bm; $elem : Object
9+
var $break; $bm; $elem; $range : Object
1010
var $picture; $pictureL; $pictureS : Picture
1111
var $filePath; $prompt : Text
1212
var $newDoc : Object
@@ -16,6 +16,9 @@ var $newDoc : Object
1616

1717
Case of
1818

19+
: ($action="") // error to be managed
20+
Form:C1466._extra.state:=1 // rub
21+
1922
: ($action="Set Text")
2023

2124
If (Form:C1466._extra.count=0)
@@ -26,6 +29,14 @@ Case of
2629
$memoRange2:=WP Text range:C1341(Form:C1466.WPai; wk end text:K81:164; wk end text:K81:164)
2730

2831
$promptRange:=WP Text range:C1341(Form:C1466.WPai; $memoRange1.end; $memoRange2.end)
32+
33+
// link paragraphs if more than one in the prompt (transform § breaks into line breaks)
34+
$breaks:=WP Get breaks:C1768($promptRange; wk paragraph break:K81:259)
35+
For each ($break; $breaks)
36+
$range:=WP Text range:C1341(Form:C1466.WPai; $break.start; $break.end)
37+
WP Insert break:C1413($range; wk line break:K81:186; wk replace:K81:177)
38+
End for each
39+
2940
WP SET ATTRIBUTES:C1342($promptRange; wk style sheet:K81:63; "Prompt")
3041

3142
WP Insert break:C1413(Form:C1466.WPai; wk paragraph break:K81:259; wk append:K81:179)
@@ -77,6 +88,8 @@ Case of
7788
WP SELECT:C1348(*; "WParea"; $bm.answerRange)
7889
GOTO OBJECT:C206(*; "WParea") // to avoid the light grey highlight
7990

91+
Form:C1466._extra.state:=2 // re-run
92+
8093
End if
8194

8295
Form:C1466._extra.count+=1
@@ -123,7 +136,5 @@ Case of
123136

124137
End case
125138

126-
127-
Form:C1466._extra.state:=2
128139
SET TIMER:C645(-1)
129140

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
[
22
{
3+
"title": "Summarize the section",
34
"prompt": "Can you summarize this section for me?",
45
"source": "selection"
56
},
67
{
8+
"title": "Summarize the document",
79
"prompt": "Can you summarize the whole document for me?",
810
"source": "document"
911
},
1012
{
11-
"prompt": "Can you translate this this section into french?",
13+
"title": "-"
14+
},
15+
{
16+
"title": "Translate the section",
17+
"prompt": "Can you translate this section into french?",
1218
"source": "selection"
1319
},
1420
{
21+
"title": "Translate the document",
1522
"prompt": "Can you translate the whole document into french?",
1623
"source": "document"
1724
},
1825
{
26+
"title": "-"
27+
},
28+
{
29+
"title": "Check the section grammar",
1930
"prompt": "Can you check the grammar of this section and tell me if there is any error?",
2031
"source": "selection"
2132
},
2233
{
34+
"title": "Check the document grammar",
2335
"prompt": "Can you check the grammar of this document and tell me if there is any error?",
2436
"source": "document"
2537
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
[
22

33
{
4+
"title": "Résumer la sélection",
45
"prompt": "Pouvez-vous résumer le texte sélectionné ?",
56
"source": "selection"
67
},
78
{
9+
"title": "Résumer le document",
810
"prompt": "Pouvez-vous résumer le document entier ?",
911
"source": "document"
1012
},
1113
{
14+
"title": "-"
15+
},
16+
{
17+
"title": "Traduire la sélection",
1218
"prompt": "Pouvez-vous traduite le texte sélectionné en anglais ?",
1319
"source": "selection"
1420
},
1521
{
22+
"title": "Traduire le document",
1623
"prompt": "Pouvez-vous traduite le document entier en anglais ?",
1724
"source": "document"
1825
},
1926
{
27+
"title": "-"
28+
},
29+
{
30+
"title": "Vérifier la sélection",
2031
"prompt": "Pouvez-vous vérifier la grammaire du texte sélectionné et me signaler les erreurs ?",
2132
"source": "selection"
2233
},
2334
{
35+
"title": "Vérifier le document",
2436
"prompt": "Pouvez-vous vérifier la grammaire du document entier et me signaler les erreurs ?",
2537
"source": "document"
2638
}

0 commit comments

Comments
 (0)