AfterToolResult

org.llm4s.testkit.AfterToolResult

Matches a conversation whose last message is a tool result, and extracts the name of the tool and the text of its result: the model call after a tool ran.

case AfterToolResult("add_inventory_item", _) => Reply.text("Taken.")

'''The name''' is not in a tool result, which carries only the id of its call. It is read from the call with that id in the assistant message the results answer: the message right before the tool results that end the conversation. When that call is not there - the conversation was cut so that the assistant message is gone, or the id is not one of its calls - the extractor does not match, rather than guess a name. A call with the same id in an earlier turn is never used.

'''Several results.''' When the model called several tools at once the conversation ends with one result for each, and this extracts the last of them. A rule for one of the others, or for all of them, uses AfterToolResults.

Attributes

Source
RuleExtractors.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def unapply(conversation: Conversation): Option[(String, String)]

The tool name and the result text of the last message, when it is a tool result whose call is found.

The tool name and the result text of the last message, when it is a tool result whose call is found.

Attributes

Source
RuleExtractors.scala