Skip to content

Commit 3cceefe

Browse files
committed
"Refactor LLM-Spec layout and commands; add 'Open LLM Chat' world menu item"
1 parent ce8da5e commit 3cceefe

3 files changed

Lines changed: 32 additions & 8 deletions

File tree

src/LLM-Spec/LLMAPISpec.class.st

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ Class {
1818
#package : 'LLM-Spec'
1919
}
2020

21+
{ #category : 'examples' }
22+
LLMAPISpec class >> menuCommandOn: aBuilder [
23+
24+
<worldMenu>
25+
(aBuilder item: #'Open LLM Chat')
26+
order: 1000;
27+
action: [ self open ];
28+
help: 'Open an LLM Chat wincow'
29+
]
30+
2131
{ #category : 'examples' }
2232
LLMAPISpec class >> open [
2333
<example>

src/LLM-Spec/LLMAPISpecChatBubble.class.st

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,24 @@ LLMAPISpecChatBubble class >> from: aMessage [
2525
yourself
2626
]
2727

28+
{ #category : 'initialization' }
29+
LLMAPISpecChatBubble >> contentArea [
30+
31+
^ contentArea
32+
]
33+
2834
{ #category : 'layout' }
2935
LLMAPISpecChatBubble >> defaultLayout [
3036

3137
^ SpBoxLayout newTopToBottom
38+
beNotHomogeneous;
3239
add: self model role expand: false;
33-
"add: roleText expand: false;"add: contentArea
34-
withConstraints: [ :constraints |
35-
constraints height: (self class inputTextHeight) * 4 ];
40+
add: contentArea withConstraints: [ :constraints |
41+
self contentArea build.
42+
constraints
43+
height:
44+
((self contentArea text lineHeightsWrappingAtWidth:
45+
self extent x) sum) + (self class inputTextHeight * 1.5) ];
3646
yourself
3747
]
3848

src/LLM-Spec/LLMAPISpecChatHistory.class.st

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,25 @@ LLMAPISpecChatHistory >> addMessage: aMessage [
3030

3131
self model add: aMessage.
3232
aMessage role = 'system' ifFalse: [
33-
panel add: (LLMAPISpecChatBubble from: aMessage) ]
33+
panel addPresenter: (LLMAPISpecChatBubble from: aMessage) ]
3434
]
3535

3636
{ #category : 'layout' }
3737
LLMAPISpecChatHistory >> defaultLayout [
3838

39-
^ SpScrollableLayout with: panel
39+
| scrollPane |
40+
scrollPane := SpBoxLayout new
41+
add: panel;
42+
yourself.
43+
^ scrollPane
4044
]
4145

4246
{ #category : 'initialization' }
4347
LLMAPISpecChatHistory >> initializePresenters [
4448

45-
panel := SpBoxLayout newTopToBottom.
49+
panel := SpComponentListPresenter new.
4650

4751
self model do: [ :message |
48-
message role = 'system' ifFalse: [
49-
panel add: (LLMAPISpecChatBubble from: message) expand: true ] ]
52+
message role = 'system' ifFalse: [
53+
panel addPresenter: (LLMAPISpecChatBubble from: message) ] ]
5054
]

0 commit comments

Comments
 (0)