Skip to content

Commit 1fa9a31

Browse files
committed
feat(LLM-API): Add Pharo Code Executor tool and update tests
- Added new subclass `LLMAPIChatObjectToolPharoExecutor` to execute Pharo/Smalltalk code. - Implemented `executeWithArguments:` method with error handling. - Updated baseline specifications for 'LLM-Spec-Tests'. - Modified testCheckModelExist in LLMAPIChatTest.
1 parent 12b07c4 commit 1fa9a31

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

src/BaselineOfLLMAPI/BaselineOfLLMAPI.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ BaselineOfLLMAPI >> definePackages: spec [
3737
spec package: 'LLM-API' with: [ spec requires: #( 'NeoJSON' ) ].
3838
spec package: 'LLM-API-Tests' with: [ spec requires: #( 'LLM-API' 'Mocketry' ) ].
3939
spec package: 'LLM-API-Example' with: [ spec requires: #( 'LLM-API' ) ].
40-
spec package: 'LLM-Spec' with: [ spec requires: #( 'LLM-API' ) ]
40+
spec package: 'LLM-Spec' with: [ spec requires: #( 'LLM-API' ) ].
41+
spec package: 'LLM-Spec-Tests' with: [ spec requires: #( 'LLM-Spec' ) ]
4142
]

src/LLM-API-Example/LLMAPIChatObjectToolCountClasses.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Class {
88
{ #category : 'execution' }
99
LLMAPIChatObjectToolCountClasses >> executeWithArguments: arguments [
1010
"Implement this if you want to extend tools and use its default mecanism"
11-
11+
1212
^ Smalltalk image allClasses size asString
1313
]
1414

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Class {
2+
#name : 'LLMAPIChatObjectToolPharoExecutor',
3+
#superclass : 'LLMAPIChatObjectTool',
4+
#category : 'LLM-API-Example',
5+
#package : 'LLM-API-Example'
6+
}
7+
8+
{ #category : 'execution' }
9+
LLMAPIChatObjectToolPharoExecutor >> executeWithArguments: arguments [
10+
"Implement this if you want to extend tools and use its default mecanism"
11+
12+
(arguments isNil or: [ arguments isEmpty ]) ifTrue: [
13+
^ 'please provide the code to be executed' ].
14+
^ [ SmalltalkImage current compiler evaluate: arguments first value ]
15+
on: Exception
16+
do: [ :exce | exce message ]
17+
]
18+
19+
{ #category : 'initialization' }
20+
LLMAPIChatObjectToolPharoExecutor >> initialize [
21+
22+
super initialize.
23+
description := 'I execute Pharo/SmallTalk code and return the result'.
24+
name := 'Pharo Code Executor'
25+
]

src/LLM-API-Tests/LLMAPIChatTest.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LLMAPIChatTest >> setUp [
2121

2222
{ #category : 'running' }
2323
LLMAPIChatTest >> testCheckModelExist [
24-
24+
api payload model: nil.
2525
self should: [ api performRequest ] raise: LLMPayloadNoModelError
2626
]
2727

0 commit comments

Comments
 (0)