-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inline traits in LLM core [feenkcom/gtoolkit#4322]
- Loading branch information
Showing
13 changed files
with
1,028 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Extension { #name : #GtLlmActionMessage } | ||
|
||
{ #category : #'*Gt4Llm-GToolkit' } | ||
GtLlmActionMessage >> gtActionFor: aView [ | ||
<gtView> | ||
<gtLlmMessageView> | ||
| view | | ||
self action isEmptyOrNil ifTrue: [ ^ aView empty ]. | ||
|
||
view := aView textEditor | ||
title: 'Action'; | ||
priority: 3; | ||
text: [ self action ]. | ||
self chat | ||
ifNotNil: [ view | ||
actionButtonLabel: 'Action' | ||
action: [ :aButton | aButton phlow spawnObject: (self chat tutor actionNamed: self action) ]; | ||
styler: [ BlCompositeStyler new | ||
stylers: {GtLlmMessageStyler new threadMessageViewModel: self asViewModel. | ||
GtLlmThreadMessageStyler new annotations: self annotations. | ||
GtLlmTutorFormatTextStyler new tutor: self chat tutor} ] ]. | ||
^ view | ||
] | ||
|
||
{ #category : #'*Gt4Llm-GToolkit' } | ||
GtLlmActionMessage >> gtInspectActionFor: anAction [ | ||
<gtLlmAction> | ||
self actionModel ifNil: [ ^ anAction noAction ]. | ||
|
||
^ anAction button | ||
priority: 1; | ||
icon: BrGlamorousVectorIcons inspect; | ||
label: 'Action'; | ||
action: [ :aButton | aButton phlow spawnObject: (self chat tutor actionNamed: self action) ] | ||
] | ||
|
||
{ #category : #'*Gt4Llm-GToolkit' } | ||
GtLlmActionMessage >> gtReifyActionFor: anAction [ | ||
<gtLlmAction> | ||
(self isAssistantRole | ||
and: [ self action = 'Answer a chat request' | ||
or: [ (self action beginsWith: 'Chat request: ') or: [ self actionModel isNil ] ] ]) | ||
ifFalse: [ ^ anAction noAction ]. | ||
|
||
^ anAction dropdown | ||
priority: 5; | ||
label: 'Reify action'; | ||
content: [ :anElement | | ||
GtLlmActionTemplateElement new | ||
example: (GtLlmTutorActionExample new | ||
input: self ancestor contentJson; | ||
output: self contentJson); | ||
onActionCreated: [ :action | | ||
self chat tutor class compile: action. | ||
self chat tutor recomputeActions. | ||
anElement phlow fireToolUpdateWish. | ||
anElement fireEvent: BrDropdownHideWish new ]; | ||
padding: (BlInsets all: 5) ] | ||
] | ||
|
||
{ #category : #'*Gt4Llm-GToolkit' } | ||
GtLlmActionMessage >> gtReifyMessageActionFor: anAction [ | ||
<gtLlmAction> | ||
^ anAction dropdown | ||
priority: 1; | ||
label: 'Reify'; | ||
content: [ :aButton | | ||
(GtLlmReificationForm new | ||
message: self; | ||
onAccept: [ :aValue | | ||
aButton | ||
enqueueTask: (BlTaskAction new | ||
action: [ aButton phlow fireToolUpdateWish. | ||
aButton fireEvent: BrDropdownHideWish new ]) ]) asElement | ||
margin: (BlInsets all: 5) ] | ||
] | ||
|
||
{ #category : #'*Gt4Llm-GToolkit' } | ||
GtLlmActionMessage >> gtTextFor: aView [ | ||
<gtView> | ||
<gtLlmMessageView> | ||
self textBlock isEmptyOrNil ifTrue: [ ^ aView empty ]. | ||
|
||
^ aView textEditor | ||
title: 'Text'; | ||
priority: 1; | ||
styler: (GtLlmMessageStyler new | ||
threadMessageViewModel: (GtLlmNewThreadMessageViewModel new threadMessage: GtLlmNewThreadMessage new)); | ||
text: [ self textBlock ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,54 @@ | ||
Class { | ||
#name : #GtLlmActionMessage, | ||
#superclass : #GtLlmChatMessage, | ||
#traits : 'TGtActionMessage', | ||
#classTraits : 'TGtActionMessage classTrait', | ||
#category : #Gt4Llm | ||
} | ||
|
||
{ #category : #'as yet unclassified' } | ||
GtLlmActionMessage class >> defaultRole [ | ||
^ nil | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
GtLlmActionMessage >> actionModel [ | ||
^ (self chat tutor actionNamed: self action) | ||
ifNil: [ self isUserRole | ||
ifTrue: [ (self chat descendantOf: self) ifNotNil: #actionModel ] | ||
ifFalse: [ nil ] ] | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
GtLlmActionMessage >> contentSummary [ | ||
^ self action | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
GtLlmActionMessage >> gtContentFor: aView [ | ||
<gtView> | ||
<gtLlmMessageView> | ||
^ aView empty | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
GtLlmActionMessage >> gtPromoteToExampleActionFor: anAction [ | ||
<gtLlmAction> | ||
self isAssistantRole ifFalse: [ ^ anAction noAction ]. | ||
|
||
^ anAction dropdown | ||
priority: 5; | ||
label: 'Promote example'; | ||
content: [ :aButton | | ||
| action example | | ||
action := self chat tutor actionNamed: self action. | ||
example := GtLlmTutorActionExample new | ||
input: self ancestor contentJson; | ||
output: self contentJson. | ||
action addExample: example. | ||
action persist. | ||
example asGtMagritteViewModel asElement ] | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
GtLlmActionMessage >> textBlock [ | ||
^ self contentJson at: 'Text' ifAbsent: [ '' ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.