Skip to content

Commit

Permalink
Improve toolkit usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
imclerran committed Dec 31, 2024
1 parent 3a6cc0a commit ff4ee03
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 24 deletions.
5 changes: 2 additions & 3 deletions package/Toolkit/FileSystem.roc
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
## (writeFileContents.name, writeFileContents.handler),
## ]
## client = Client.init { apiKey, model: "tool-capable/model", tools }
##
## #...
##
## messages = Chat.appendUserMessage previousMessages newMessage
## response = Http.send (Chat.buildHttpRequest client messages {}) |> Task.result!
## updatedMessages = updateMessagesFromResponse response messages |> Tools.handleToolCalls! client toolHandlerMap
## updatedMessages = updateMessagesFromResponse response messages
## |> Tools.handleToolCalls! client toolHandlerMap
## ```
module { pathFromStr, pathToStr, listDir, isDir, readFile, writeUtf8 } -> [
listDirectory,
Expand Down
5 changes: 2 additions & 3 deletions package/Toolkit/OpenWeatherMap.roc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
## (currentWeather.name, currentWeather.handler),
## ]
## client = Client.init { apiKey, model: "tool-capable/model", tools }
##
## #...
##
## messages = Chat.appendUserMessage previousMessages newMessage
## response = Http.send (Chat.buildHttpRequest client messages {}) |> Task.result!
## updatedMessages = updateMessagesFromResponse response messages |> Tools.handleToolCalls! client toolHandlerMap
## updatedMessages = updateMessagesFromResponse response messages
## |> Tools.handleToolCalls! client toolHandlerMap
## ```
module { sendHttpReq, getEnvVar } -> [geocoding, currentWeather]

Expand Down
5 changes: 2 additions & 3 deletions package/Toolkit/Roc.roc
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
## (rocStart.name, rocStart.handler),
## ]
## client = Client.init { apiKey, model: "tool-capable/model", tools }
##
## #...
##
## messages = Chat.appendUserMessage previousMessages newMessage
## response = Http.send (Chat.buildHttpRequest client messages {}) |> Task.result!
## updatedMessages = updateMessagesFromResponse response messages |> Tools.handleToolCalls! client toolHandlerMap
## updatedMessages = updateMessagesFromResponse response messages
## |> Tools.handleToolCalls! client toolHandlerMap
## ```
module { cmdNew, cmdArg, cmdOutput } -> [roc, rocCheck, rocTest, rocStart]

Expand Down
5 changes: 2 additions & 3 deletions package/Toolkit/Serper.roc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
## # Tool handler map is passed to Tools.handleToolCalls!
## toolHandlerMap = Dict.fromList [(serper.name, serper.handler)]
## client = Client.init { apiKey, model: "tool-capable/model", tools }
##
## #...
##
## messages = Chat.appendUserMessage previousMessages newMessage
## response = Http.send (Chat.buildHttpRequest client messages {}) |> Task.result!
## updatedMessages = updateMessagesFromResponse response messages |> Tools.handleToolCalls! client toolHandlerMap
## updatedMessages = updateMessagesFromResponse response messages
## |> Tools.handleToolCalls! client toolHandlerMap
## ```

module { sendHttpReq, getEnvVar } -> [serper]
Expand Down
5 changes: 2 additions & 3 deletions package/Toolkit/UtcTime.roc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
## # Tool handler map is passed to Tools.handleToolCalls!
## toolHandlerMap = Dict.fromList [(utcNow.name, utcNow.handler)]
## client = Client.init { apiKey, model: "tool-capable/model", tools }
##
## #...
##
## messages = Chat.appendUserMessage previousMessages newMessage
## response = Http.send (Chat.buildHttpRequest client messages {}) |> Task.result!
## updatedMessages = updateMessagesFromResponse response messages |> Tools.handleToolCalls! client toolHandlerMap
## updatedMessages = updateMessagesFromResponse response messages
## |> Tools.handleToolCalls! client toolHandlerMap
## ```
module { getUtcNow, utcToNanos } -> [utcNow]

Expand Down
5 changes: 2 additions & 3 deletions package/Toolkit/Wikipedia.roc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
## (wikipediaParse.name, wikipediaParse.handler),
## ]
## client = Client.init { apiKey, model: "tool-capable/model", tools }
##
## #...
##
## messages = Chat.appendUserMessage previousMessages newMessage
## response = Http.send (Chat.buildHttpRequest client messages {}) |> Task.result!
## updatedMessages = updateMessagesFromResponse response messages |> Tools.handleToolCalls! client toolHandlerMap
## updatedMessages = updateMessagesFromResponse response messages
## |> Tools.handleToolCalls! client toolHandlerMap
## ```
module { sendHttpReq } -> [wikipediaSearch, wikipediaParse]

Expand Down
5 changes: 2 additions & 3 deletions package/Toolkit/WolframAlpha.roc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
## (wolframShortAnswer.name, wolframShortAnswer.handler),
## ]
## client = Client.init { apiKey, model: "tool-capable/model", tools }
##
## #...
##
## messages = Chat.appendUserMessage previousMessages newMessage
## response = Http.send (Chat.buildHttpRequest client messages {}) |> Task.result!
## updatedMessages = updateMessagesFromResponse response messages |> Tools.handleToolCalls! client toolHandlerMap
## updatedMessages = updateMessagesFromResponse response messages
## |> Tools.handleToolCalls! client toolHandlerMap
## ```
module { sendHttpReq, getEnvVar } -> [wolframShortAnswer]

Expand Down
5 changes: 2 additions & 3 deletions package/Toolkit/WorldTimeApi.roc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
## # Tool handler map is passed to Tools.handleToolCalls!
## toolHandlerMap = Dict.fromList [(currentTime.name, currentTime.handler)]
## client = Client.init { apiKey, model: "tool-capable/model", tools }
##
## #...
##
## messages = Chat.appendUserMessage previousMessages newMessage
## response = Http.send (Chat.buildHttpRequest client messages {}) |> Task.result!
## updatedMessages = updateMessagesFromResponse response messages |> Tools.handleToolCalls! client toolHandlerMap
## updatedMessages = updateMessagesFromResponse response messages
## |> Tools.handleToolCalls! client toolHandlerMap
## ```
module { sendHttpReq } -> [currentTime]

Expand Down

0 comments on commit ff4ee03

Please sign in to comment.