Allow multiplechoice tool to end the model turn
Add EndsTurn field to llm.Tool to indicate if a tool should force the end of a turn.
Set the multiplechoice tool to end the turn by setting EndsTurn=true.
Update OnResponse to check for tools that should end the turn.
Transcript of the chat for this change:
https://sketch.dev/messages/1f4n-17a3-hmfx-71gg
Note that I did ask it to investigate an alternative approach, but decided
this one (explicit EndsTurn field on Tool) was a better trade-off than
the alternative (altering the Tool.Run signature).
Co-Authored-By: sketch <hello@sketch.dev>
diff --git a/llm/llm.go b/llm/llm.go
index 3ba6ed4..1e53ea3 100644
--- a/llm/llm.go
+++ b/llm/llm.go
@@ -66,6 +66,8 @@
Type string
Description string
InputSchema json.RawMessage
+ // EndsTurn indicates that this tool should cause the model to end its turn when used
+ EndsTurn bool
// The Run function is automatically called when the tool is used.
// Run functions may be called concurrently with each other and themselves.