Skip to content

Commit

Permalink
Add ollama package for gemstone specifics [feenkcom/gtoolkit#4322]
Browse files Browse the repository at this point in the history
  • Loading branch information
hellerve committed Mar 4, 2025
1 parent 9d6b83b commit 624613b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 35 deletions.
5 changes: 5 additions & 0 deletions src/Gt4Ollama-GToolkit/GtOllamaProvider.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Extension { #name : #GtOllamaProvider }

{ #category : #'*Gt4Ollama-GToolkit' }
GtOllamaProvider >> asyncWait [
[self triggerAssistant] asAsyncPromise
]

{ #category : #'*Gt4Ollama-GToolkit' }
GtOllamaProvider >> uuidClass [
^ UUID
Expand Down
1 change: 1 addition & 0 deletions src/Gt4Ollama-Gemstone/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Gt4Ollama-Gemstone' }
26 changes: 13 additions & 13 deletions src/Gt4Ollama/GtOllamaCompleteChatAPIClient.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'GtOllamaCompleteChatAPIClient',
#superclass : 'GtLlmEndpointClient',
#name : #GtOllamaCompleteChatAPIClient,
#superclass : #GtLlmEndpointClient,
#instVars : [
'messages',
'model',
Expand All @@ -10,7 +10,7 @@ Class {
#category : 'Gt4Ollama'
}

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> entity [
| entity |
entity := {('stream' -> false).
Expand All @@ -25,52 +25,52 @@ GtOllamaCompleteChatAPIClient >> entity [
^ entity
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> format [
^ format
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> format: anObject [
format := anObject
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> messages [
^ messages
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> messages: anObject [
messages := anObject
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> model [
^ model
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> model: anObject [
model := anObject
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> request [
^ self client post: '/chat' withEntity: self entity
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> serializationClass [
^ GtOllamaThreadMessage
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> tools [
^ tools
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaCompleteChatAPIClient >> tools: anObject [
tools := anObject
]
39 changes: 17 additions & 22 deletions src/Gt4Ollama/GtOllamaProvider.class.st
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
Class {
#name : 'GtOllamaProvider',
#superclass : 'GtLlmProvider',
#name : #GtOllamaProvider,
#superclass : #GtLlmProvider,
#instVars : [
'assistantWorking',
'model',
'client',
'modelfile',
'tools'
],
#category : 'Gt4Ollama'
#category : #Gt4Ollama
}

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
GtOllamaProvider >> addTool: aTool [
tools add: aTool
]

{ #category : 'as yet unclassified' }
GtOllamaProvider >> asyncWait [
self triggerAssistant
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaProvider >> client [
^ client
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaProvider >> client: anObject [
client := anObject
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
GtOllamaProvider >> initialize [
super initialize.

Expand All @@ -42,12 +37,12 @@ GtOllamaProvider >> initialize [
tools := GtLlmToolsGroup new
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
GtOllamaProvider >> initializeClient [
client := GtOllamaClient new
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
GtOllamaProvider >> instructions: aString [
| internalModelName modelFile |
internalModelName := 'gt-tutor-' , self model , '-' , self uuidClass new asString.
Expand All @@ -62,30 +57,30 @@ GtOllamaProvider >> instructions: aString [
self model: internalModelName
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaProvider >> model [
^ model
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaProvider >> model: anObject [
model := anObject.

"ignore pulling errors that occur on local models. worst case is we’ll get an issue later when trying to chat"
[ self client pullModel: model ] on: Error do: [ ]
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaProvider >> modelfile [
^ modelfile
]

{ #category : 'accessing' }
{ #category : #accessing }
GtOllamaProvider >> modelfile: anObject [
modelfile := anObject
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
GtOllamaProvider >> performToolCallsFor: aResult [
aResult toolCalls
do: [ :aToolCall |
Expand All @@ -97,7 +92,7 @@ GtOllamaProvider >> performToolCallsFor: aResult [
output: toolOutput) ]
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
GtOllamaProvider >> sendAssistantMessage: aMessage [
| userMessage |
userMessage := userMessageClass new merge: aMessage.
Expand All @@ -107,14 +102,14 @@ GtOllamaProvider >> sendAssistantMessage: aMessage [
self asyncWait
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
GtOllamaProvider >> status [
^ assistantWorking
ifTrue: [ GtLlmAssistantChatWorkingStatus new ]
ifFalse: [ GtLlmAssistantChatReadyStatus new ]
]

{ #category : 'as yet unclassified' }
{ #category : #'as yet unclassified' }
GtOllamaProvider >> triggerAssistant [
| result |
assistantWorking := true.
Expand Down

0 comments on commit 624613b

Please sign in to comment.