ScriptedLLMClient

org.llm4s.testkit.ScriptedLLMClient
See theScriptedLLMClient companion class

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

A client that gives the same reply to every call.

A client that gives the same reply to every call.

Attributes

def respondingTo(rules: PartialFunction[Conversation, Reply]): ScriptedLLMClient

A client that chooses each reply from the conversation. A conversation no case matches returns a Left(UnscriptedCallError) that names the call.

A client that chooses each reply from the conversation. A conversation no case matches returns a Left(UnscriptedCallError) that names the call.

The rules run under the client's lock, so they must not block on another call to the same client, and an exception a rule throws is not caught: it propagates from complete or streamComplete.

ScriptedLLMClient.respondingTo {
 case c if c.messages.lastOption.exists(_.content.contains("capital")) => Reply.text("Paris")
}

Attributes

def sequence(replies: Reply*): ScriptedLLMClient

A client that answers call 1 with the first reply, call 2 with the second, and so on. A call past the end of the script returns a Left(UnscriptedCallError) that names the call.

A client that answers call 1 with the first reply, call 2 with the second, and so on. A call past the end of the script returns a Left(UnscriptedCallError) that names the call.

Attributes