-
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.
Use GToolkit-specific packages for Ollama and OpenAI [feenkcom/gtoolk…
- Loading branch information
Showing
42 changed files
with
298 additions
and
277 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,27 @@ | ||
Extension { #name : #GtOllamaClient } | ||
|
||
{ #category : #'*Gt4Ollama-GToolkit' } | ||
GtOllamaClient >> initializeClient [ | ||
| aClient | | ||
aClient := ZnClient new. | ||
aClient forJsonREST. | ||
aClient timeout: 600. | ||
^ aClient | ||
] | ||
|
||
{ #category : #'*Gt4Ollama-GToolkit' } | ||
GtOllamaClient >> postStreaming: aString withEntity: anEntity [ | ||
| aClient aResult | | ||
aClient := self initializeClient | ||
accept: 'application/jsonl,application/x-ndjson'; | ||
contentReader: [ :entity | (NeoJSONReader on: entity readStream) upToEnd ]. | ||
aClient url: self baseUrl / aString. | ||
|
||
aClient contents: anEntity. | ||
|
||
aResult := aClient post. | ||
|
||
aResult size > 0 ifTrue: [ self checkForErrors: aResult first ]. | ||
|
||
^ aResult | ||
] |
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,31 @@ | ||
Extension { #name : #GtOllamaModelsGroup } | ||
|
||
{ #category : #'*Gt4Ollama-GToolkit' } | ||
GtOllamaModelsGroup >> gtModelsFor: aView [ | ||
<gtView> | ||
^ aView columnedList | ||
title: 'Models'; | ||
priority: 1; | ||
items: [ self items ]; | ||
column: 'Name' text: #name; | ||
column: 'Model' text: #model; | ||
column: 'Modified at' | ||
text: #modifiedAt | ||
weight: 2; | ||
column: 'Actions' | ||
stencil: [ :aModel | | ||
| aToolbar | | ||
aToolbar := BrToolbar new | ||
aptitude: (BrGlamorousToolbarAptitude new spacing: 5); | ||
fitContent; | ||
addItem: (BrButton new beTinySize | ||
aptitude: BrGlamorousButtonWithIconAptitude; | ||
icon: BrGlamorousVectorIcons inspect; | ||
label: 'Get model information'; | ||
action: [ aToolbar phlow spawnObject: (self client getModelInformationFor: aModel name) ]); | ||
addItem: (BrButton new beTinySize | ||
aptitude: BrGlamorousButtonWithIconAptitude; | ||
icon: BrGlamorousVectorIcons cancel; | ||
label: 'Delete model'; | ||
action: [ self client deleteModel: aModel name ]) ] | ||
] |
4 changes: 2 additions & 2 deletions
4
...ma/GtOllamaThreadMessageExamples.class.st → ...it/GtOllamaThreadMessageExamples.class.st
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
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
2 changes: 1 addition & 1 deletion
2
src/Gt4OpenAI/Gt4LlmHomeSection.extension.st → ...I-GToolkit/Gt4LlmHomeSection.extension.st
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
2 changes: 1 addition & 1 deletion
2
src/Gt4OpenAI/GtLlmWardleyMapTutor.class.st → ...AI-GToolkit/GtLlmWardleyMapTutor.class.st
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
15 changes: 15 additions & 0 deletions
15
src/Gt4OpenAI-GToolkit/GtOllamaEmbeddingsGroup.extension.st
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,15 @@ | ||
Extension { #name : #GtOllamaEmbeddingsGroup } | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOllamaEmbeddingsGroup >> gtEmbeddingsFor: aView [ | ||
<gtView> | ||
^ aView columnedList | ||
title: 'Embeddings'; | ||
priority: 1; | ||
items: [ self items withIndexCollect: [ :anItem :anIndex | anIndex -> anItem ] ]; | ||
column: 'Index' | ||
text: [ :aPair | aPair key asRopedText foreground: BrGlamorousColors disabledButtonTextColor ] | ||
width: 50; | ||
column: 'Size' text: [ :aPair | aPair value size ]; | ||
send: #value | ||
] |
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,10 @@ | ||
Extension { #name : #GtOllamaModel } | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOllamaModel >> gtDeleteModelActionFor: anAction [ | ||
<gtAction> | ||
^ anAction button | ||
label: 'Delete'; | ||
icon: BrGlamorousVectorIcons cancel; | ||
action: [ :aButton | self client deleteModel: self name ] | ||
] |
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,26 @@ | ||
Extension { #name : #GtOllamaProvider } | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOllamaProvider >> gtModelFileFor: aView [ | ||
<gtView> | ||
modelfile ifNil: [ ^ aView empty ]. | ||
|
||
^ aView forward | ||
title: 'Modelfile'; | ||
priority: 1; | ||
object: [ modelfile ]; | ||
view: #gtContentFor:; | ||
actionButtonIcon: BrGlamorousVectorIcons playinspect | ||
tooltip: 'Inspect modelfile' | ||
action: [ :aButton | aButton phlow spawnObject: modelfile ] | ||
] | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOllamaProvider >> gtTriggerAssistantActionFor: anAction [ | ||
<gtAction> | ||
^ anAction button | ||
priority: 1; | ||
tooltip: 'Trigger'; | ||
icon: BrGlamorousVectorIcons refresh; | ||
action: [ self triggerAssistant ] | ||
] |
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,17 @@ | ||
Extension { #name : #GtOpenAIActionMessage } | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOpenAIActionMessage >> gtTextFor: aView [ | ||
<gtView> | ||
<gtLlmMessageView> | ||
self textBlock isEmptyOrNil ifTrue: [ ^ aView empty ]. | ||
|
||
^ aView textEditor | ||
title: 'Text'; | ||
priority: 1; | ||
styler: (BlCompositeStyler new | ||
stylers: {GtLlmMessageStyler new | ||
threadMessageViewModel: (GtLlmNewThreadMessageViewModel new threadMessage: GtLlmNewThreadMessage new). | ||
GtLlmThreadMessageStyler new annotations: self annotations}); | ||
text: [ self textBlock ] | ||
] |
9 changes: 9 additions & 0 deletions
9
src/Gt4OpenAI-GToolkit/GtOpenAIAssistantProvider.extension.st
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,9 @@ | ||
Extension { #name : #GtOpenAIAssistantProvider } | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOpenAIAssistantProvider >> executeWait [ | ||
future := (self runFuture | ||
then: [ :aRun | | ||
self updateMessages. | ||
chat signalRunIsDone ]) await: GtOpenAIUtilities executionConfiguration | ||
] |
15 changes: 15 additions & 0 deletions
15
src/Gt4OpenAI-GToolkit/GtOpenAIBlogPostMessage.extension.st
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,15 @@ | ||
Extension { #name : #GtOpenAIBlogPostMessage } | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOpenAIBlogPostMessage >> gtDiffFor: aView [ | ||
<gtView> | ||
<gtLlmMessageView> | ||
(self contentJson includesKey: 'Post') ifFalse: [ ^ aView empty ]. | ||
^ aView diff | ||
title: 'Diff'; | ||
priority: 2; | ||
from: [ self chat serializer instance value asString ]; | ||
to: [ self contentJson at: 'Post' ]; | ||
actionButtonIcon: BrGlamorousVectorIcons accept | ||
action: [ :b | self chat serializer instance updateContent: (self contentJson at: 'Post') ] | ||
] |
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,6 @@ | ||
Extension { #name : #GtOpenAIClient } | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOpenAIClient class >> withApiKeyFromClipboard [ | ||
^ self new apiKey: Clipboard clipboardText | ||
] |
15 changes: 15 additions & 0 deletions
15
src/Gt4OpenAI-GToolkit/GtOpenAIEmbeddingsGroup.extension.st
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,15 @@ | ||
Extension { #name : #GtOpenAIEmbeddingsGroup } | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOpenAIEmbeddingsGroup >> gtEmbeddingsFor: aView [ | ||
<gtView> | ||
^ aView columnedList | ||
title: 'Embeddings'; | ||
priority: 1; | ||
items: [ self items withIndexCollect: [ :anItem :anIndex | anIndex -> anItem ] ]; | ||
column: 'Index' | ||
text: [ :aPair | aPair key asRopedText foreground: BrGlamorousColors disabledButtonTextColor ] | ||
width: 50; | ||
column: 'Size' text: [ :aPair | aPair value size ]; | ||
send: #value | ||
] |
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,15 @@ | ||
Extension { #name : #GtOpenAIFile } | ||
|
||
{ #category : #'*Gt4OpenAI-GToolkit' } | ||
GtOpenAIFile >> gtFileFor: aView [ | ||
<gtView> | ||
^ aView explicit | ||
title: 'File'; | ||
priority: 1; | ||
stencil: [ (self contents gtViewsFor: GtPhlowEmptyView new) | ||
asElementDo: [ :e | | ||
e | ||
margin: (BlInsets all: 15); | ||
background: Color white; | ||
addAptitude: BrShadowAptitude ] ] | ||
] |
Oops, something went wrong.